Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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
/**
17
 * Add category button for displaying the modal form.
18
 *
19
 * This just connects up the button to the showEditModal listener.
20
 *
21
 * @module     qbank_managecategories/addcategory
22
 * @class      qbank_managecategories/addcategory
23
 */
24
 
25
import {BaseComponent} from 'core/reactive';
26
import {categorymanager} from 'qbank_managecategories/categorymanager';
27
 
28
export default class extends BaseComponent {
29
 
30
    create(descriptor) {
31
        this.name = descriptor.element.id;
32
        this.selectors = {
33
            ADD_BUTTON: '[data-action="addeditcategory"]',
34
        };
35
    }
36
 
37
    stateReady() {
38
        this.addEventListener(this.getElement(this.selectors.ADD_BUTTON), 'click', categorymanager.showEditModal);
39
    }
40
 
41
    /**
42
     * Static method to create a component instance form the mustache template.
43
     *
44
     * @param {string} target the DOM main element or its ID
45
     * @param {object} selectors optional css selector overrides
46
     * @return {Component}
47
     */
48
    static init(target, selectors) {
49
        const targetElement = document.querySelector(target);
50
        return new this({
51
            element: targetElement,
52
            selectors,
53
            reactive: categorymanager,
54
        });
55
    }
56
}