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 |
import {setUserPreference} from 'core_user/repository';
|
|
|
17 |
|
|
|
18 |
/**
|
|
|
19 |
* Default mutation manager
|
|
|
20 |
*
|
|
|
21 |
* @module qbank_managecategories/mutations
|
|
|
22 |
*/
|
|
|
23 |
class Mutations {
|
|
|
24 |
/**
|
|
|
25 |
* Set the showdescriptions property to true or false in the page's state.
|
|
|
26 |
*
|
|
|
27 |
* @param {stateManager} stateManager
|
|
|
28 |
* @param {boolean} showDescriptions
|
|
|
29 |
* @return {Promise<void>}
|
|
|
30 |
*/
|
|
|
31 |
async toggleDescriptions(stateManager, showDescriptions) {
|
|
|
32 |
stateManager.setReadOnly(false);
|
|
|
33 |
await setUserPreference('qbank_managecategories_showdescriptions', showDescriptions);
|
|
|
34 |
stateManager.state.page.showdescriptions = showDescriptions;
|
|
|
35 |
stateManager.setReadOnly(true);
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
* Set the draghandle property to true in a given category's state.
|
|
|
40 |
*
|
|
|
41 |
* @param {stateManager} stateManager
|
|
|
42 |
* @param {Number} categoryId
|
|
|
43 |
* @return {Promise<void>}
|
|
|
44 |
*/
|
|
|
45 |
async showDragHandle(stateManager, categoryId) {
|
|
|
46 |
stateManager.setReadOnly(false);
|
|
|
47 |
stateManager.state.categories.get(categoryId).draghandle = true;
|
|
|
48 |
stateManager.setReadOnly(true);
|
|
|
49 |
}
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
export const mutations = new Mutations();
|