Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 27... Línea 27...
27
import Notification from 'core/notification';
27
import Notification from 'core/notification';
Línea 28... Línea 28...
28
 
28
 
Línea 29... Línea 29...
29
export default class GroupSearch extends search_combobox {
29
export default class GroupSearch extends search_combobox {
-
 
30
 
30
 
31
    courseID;
Línea -... Línea 32...
-
 
32
    cmID;
-
 
33
    bannedFilterFields = ['id', 'link', 'groupimageurl'];
-
 
34
 
-
 
35
    /**
-
 
36
     * Construct the class.
31
    courseID;
37
     *
32
    bannedFilterFields = ['id', 'link', 'groupimageurl'];
38
     * @param {int|null} cmid ID of the course module initiating the group search (optional).
33
 
39
     */
34
    constructor() {
40
    constructor(cmid = null) {
35
        super();
41
        super();
36
        this.selectors = {...this.selectors,
42
        this.selectors = {...this.selectors,
37
            courseid: '[data-region="courseid"]',
43
            courseid: '[data-region="courseid"]',
38
            placeholder: '.groupsearchdropdown [data-region="searchplaceholder"]',
44
            placeholder: '.groupsearchdropdown [data-region="searchplaceholder"]',
39
        };
45
        };
40
        const component = document.querySelector(this.componentSelector());
46
        const component = document.querySelector(this.componentSelector());
-
 
47
        this.courseID = component.querySelector(this.selectors.courseid).dataset.courseid;
Línea 41... Línea 48...
41
        this.courseID = component.querySelector(this.selectors.courseid).dataset.courseid;
48
        // Override the instance since the body is built outside the constructor for the combobox.
42
        // Override the instance since the body is built outside the constructor for the combobox.
49
        this.instance = component.querySelector(this.selectors.instance).dataset.instance;
43
        this.instance = component.querySelector(this.selectors.instance).dataset.instance;
50
        this.cmID = cmid;
Línea 53... Línea 60...
53
            }
60
            }
Línea 54... Línea 61...
54
 
61
 
55
            searchValueElement.value = '';
62
            searchValueElement.value = '';
Línea 56... Línea 63...
56
        });
63
        });
57
 
64
 
Línea 58... Línea 65...
58
        this.$component.on('hide.bs.dropdown', () => {
65
        this.component.addEventListener('hide.bs.dropdown', () => {
59
            this.searchInput.removeAttribute('aria-activedescendant');
66
            this.searchInput.removeAttribute('aria-activedescendant');
60
 
67
 
Línea 74... Línea 81...
74
        });
81
        });
Línea 75... Línea 82...
75
 
82
 
76
        this.renderDefault().catch(Notification.exception);
83
        this.renderDefault().catch(Notification.exception);
Línea -... Línea 84...
-
 
84
    }
-
 
85
 
-
 
86
    /**
-
 
87
     * Initialise an instance of the class.
-
 
88
     *
77
    }
89
     * @param {int|null} cmid ID of the course module initiating the group search (optional).
78
 
90
     */
79
    static init() {
91
    static init(cmid = null) {
Línea 80... Línea 92...
80
        return new GroupSearch();
92
        return new GroupSearch(cmid);
81
    }
93
    }
82
 
94
 
Línea 129... Línea 141...
129
     * Get the data we will be searching against in this component.
141
     * Get the data we will be searching against in this component.
130
     *
142
     *
131
     * @returns {Promise<*>}
143
     * @returns {Promise<*>}
132
     */
144
     */
133
    async fetchDataset() {
145
    async fetchDataset() {
134
        return await groupFetch(this.courseID).then((r) => r.groups);
146
        return await groupFetch(this.courseID, this.cmID).then((r) => r.groups);
135
    }
147
    }
Línea 136... Línea 148...
136
 
148
 
137
    /**
149
    /**
138
     * Dictate to the search component how and what we want to match upon.
150
     * Dictate to the search component how and what we want to match upon.