Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 23... Línea 23...
23
 * @copyright  2021 Ferran Recio <ferran@moodle.com>
23
 * @copyright  2021 Ferran Recio <ferran@moodle.com>
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
25
 */
Línea 26... Línea 26...
26
 
26
 
-
 
27
import DndSectionItem from 'core_courseformat/local/courseeditor/dndsectionitem';
Línea 27... Línea 28...
27
import DndSectionItem from 'core_courseformat/local/courseeditor/dndsectionitem';
28
import log from "core/log";
Línea 28... Línea 29...
28
 
29
 
29
export default class Component extends DndSectionItem {
30
export default class Component extends DndSectionItem {
Línea 40... Línea 41...
40
        this.id = descriptor.id;
41
        this.id = descriptor.id;
41
        this.section = descriptor.section;
42
        this.section = descriptor.section;
42
        this.course = descriptor.course;
43
        this.course = descriptor.course;
43
        this.fullregion = descriptor.fullregion;
44
        this.fullregion = descriptor.fullregion;
Línea 44... Línea 45...
44
 
45
 
45
        // Prevent topic zero from being draggable.
46
        // Prevent topic zero and delegated sections from being draggable.
46
        if (this.section.number > 0) {
47
        if (this.section.number > 0 && this.section.component === null) {
47
            this.getDraggableData = this._getDraggableData;
48
            this.getDraggableData = this._getDraggableData;
48
        }
49
        }
Línea 49... Línea 50...
49
    }
50
    }
Línea 54... Línea 55...
54
     * @param {element|string} target the DOM main element or its ID
55
     * @param {element|string} target the DOM main element or its ID
55
     * @param {object} selectors optional css selector overrides
56
     * @param {object} selectors optional css selector overrides
56
     * @return {Component}
57
     * @return {Component}
57
     */
58
     */
58
    static init(target, selectors) {
59
    static init(target, selectors) {
-
 
60
        let element = document.querySelector(target);
-
 
61
        // TODO Remove this if condition as part of MDL-83851.
-
 
62
        if (!element) {
-
 
63
            log.debug('Init component with id is deprecated, use a query selector instead.');
-
 
64
            element = document.getElementById(target);
-
 
65
        }
59
        return new this({
66
        return new this({
60
            element: document.getElementById(target),
67
            element,
61
            selectors,
68
            selectors,
62
        });
69
        });
63
    }
70
    }
Línea 64... Línea 71...
64
 
71
 
65
    /**
72
    /**
66
     * Initial state ready method.
73
     * Initial state ready method.
67
     *
74
     *
68
     * @param {Object} state the initial state
75
     * @param {Object} state the initial state
69
     */
76
     */
70
    stateReady(state) {
77
    stateReady(state) {
71
        this.configDragDrop(this.id, state, this.fullregion);
78
        this.configDragDrop(this.id, state, this.fullregion, !!document.querySelector(`[data-courseindexdndallowed="true"]`));
72
    }
79
    }