Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// This file is part of Moodle - http://moodle.org/
2
//
3
// Moodle is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// Moodle is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
import BulkActions from "core/bulkactions/bulk_actions";
17
import GradebookEditTreeBulkMove from "core_grades/bulkactions/edit/tree/move";
18
 
19
/**
20
 * Class for defining the bulk actions area in the gradebook setup page.
21
 *
22
 * @module     core_grades/bulkactions/edit/tree/bulk_actions
23
 * @copyright  2023 Mihail Geshoski <mihail@moodle.com>
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
26
 
27
const Selectors = {
28
    selectBulkItemCheckbox: 'input[type="checkbox"].itemselect'
29
};
30
 
31
export default class GradebookEditTreeBulkActions extends BulkActions {
32
 
33
    /** @property {int|null} courseID The course ID. */
34
    courseID = null;
35
 
36
    /**
37
     * Returns the instance of the class.
38
     *
39
     * @param {int} courseID
40
     * @returns {GradebookEditTreeBulkActions}
41
     */
42
    static init(courseID) {
43
        return new this(courseID);
44
    }
45
 
46
    /**
47
     * The class constructor.
48
     *
49
     * @param {int} courseID The course ID.
50
     * @returns {void}
51
     */
52
    constructor(courseID) {
53
        super();
54
        this.courseID = courseID;
55
    }
56
 
57
    /**
58
     * Returns the array of the relevant bulk action objects for the gradebook setup page.
59
     *
60
     * @method getBulkActions
61
     * @returns {Array}
62
     */
63
    getBulkActions() {
64
        return [
65
            new GradebookEditTreeBulkMove(this.courseID)
66
        ];
67
    }
68
 
69
    /**
70
     * Returns the array of selected items.
71
     *
72
     * @method getSelectedItems
73
     * @returns {Array}
74
     */
75
    getSelectedItems() {
76
        return document.querySelectorAll(`${Selectors.selectBulkItemCheckbox}:checked`);
77
    }
78
 
79
    /**
80
     * Adds the listener for the item select change event.
81
     *
82
     * @method registerItemSelectChangeEvent
83
     * @param {function} eventHandler The event handler function.
84
     * @returns {void}
85
     */
86
    registerItemSelectChangeEvent(eventHandler) {
87
        const itemSelectCheckboxes = document.querySelectorAll(Selectors.selectBulkItemCheckbox);
88
        itemSelectCheckboxes.forEach((checkbox) => {
89
            checkbox.addEventListener('change', eventHandler.bind(this));
90
        });
91
    }
92
}