913 |
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 |
* Course index section title component.
|
|
|
18 |
*
|
|
|
19 |
* This component is used to control specific course section interactions like drag and drop.
|
|
|
20 |
*
|
|
|
21 |
* @module theme_universe/courseindex/sectiontitle
|
|
|
22 |
* @class theme_universe/courseindex/sectiontitle
|
|
|
23 |
* @copyright 2021 Ferran Recio <ferran@moodle.com>
|
|
|
24 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
25 |
*/
|
|
|
26 |
|
|
|
27 |
import DndSectionItem from 'theme_universe_child/courseeditor/dndsectionitem';
|
|
|
28 |
|
|
|
29 |
export default class Component extends DndSectionItem {
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* Constructor hook.
|
|
|
33 |
*
|
|
|
34 |
* @param {Object} descriptor
|
|
|
35 |
*/
|
|
|
36 |
create(descriptor) {
|
|
|
37 |
// Optional component name for debugging.
|
|
|
38 |
this.name = 'courseindex_sectiontitle';
|
|
|
39 |
|
|
|
40 |
this.id = descriptor.id;
|
|
|
41 |
this.section = descriptor.section;
|
|
|
42 |
this.course = descriptor.course;
|
|
|
43 |
this.fullregion = descriptor.fullregion;
|
|
|
44 |
|
|
|
45 |
// Prevent topic zero from being draggable.
|
|
|
46 |
if (this.section.number > 0) {
|
|
|
47 |
this.getDraggableData = this._getDraggableData;
|
|
|
48 |
}
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Static method to create a component instance form the mustahce template.
|
|
|
53 |
*
|
|
|
54 |
* @param {element|string} target the DOM main element or its ID
|
|
|
55 |
* @param {object} selectors optional css selector overrides
|
|
|
56 |
* @return {Component}
|
|
|
57 |
*/
|
|
|
58 |
static init(target, selectors) {
|
|
|
59 |
return new this({
|
|
|
60 |
element: document.getElementById(target),
|
|
|
61 |
selectors,
|
|
|
62 |
});
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
/**
|
|
|
66 |
* Initial state ready method.
|
|
|
67 |
*
|
|
|
68 |
* @param {Object} state the initial state
|
|
|
69 |
*/
|
|
|
70 |
stateReady(state) {
|
|
|
71 |
this.configDragDrop(this.id, state, this.fullregion);
|
|
|
72 |
}
|
|
|
73 |
}
|