Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * External function calls for qbank_columnsortorder
18
 *
19
 * @module     qbank_columnsortorder/repository
20
 * @copyright  2023 Catalyst IT Europe Ltd.
21
 * @author     Mark Johnson <mark.johnson@catalyst-eu.net>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
import {call as fetchMany} from 'core/ajax';
26
 
27
/**
28
 * Save the list of hidden columns
29
 *
30
 * @param {String[]} columns List of hidden column names
31
 * @param {Boolean} global Set global config setting, rather than user preference
32
 * @return {Promise}
33
 */
34
export const setHiddenColumns = (columns, global = false) => fetchMany([{
35
    methodname: 'qbank_columnsortorder_set_hidden_columns',
36
    args: {
37
        columns,
38
        global,
39
    },
40
}])[0];
41
 
42
/**
43
 * Save the order of columns
44
 *
45
 * @param {String[]} columns List of column names in the desired order
46
 * @param {Boolean} global Set global config setting, rather than user preference
47
 * @return {Promise}
48
 */
49
export const setColumnbankOrder = (columns, global = false) => fetchMany([{
50
    methodname: 'qbank_columnsortorder_set_columnbank_order',
51
    args: {
52
        columns,
53
        global,
54
    },
55
}])[0];
56
 
57
/**
58
 * Save the column widths
59
 *
60
 * @param {String} sizes JSON string encoding an array of objects with "column" and "width" properties.
61
 * @param {Boolean} global Set global config setting, rather than user preference
62
 * @return {Promise}
63
 */
64
export const setColumnSize = (sizes, global = false) => fetchMany([{
65
    methodname: 'qbank_columnsortorder_set_column_size',
66
    args: {
67
        sizes,
68
        global,
69
    },
70
}])[0];
71
 
72
/**
73
 * Reset all settings.
74
 *
75
 * @param {Boolean} global Reset global config settings, rather than user preference
76
 * @return {Promise}
77
 */
78
export const resetColumns = (global = false) => Promise.all(
79
    fetchMany([
80
        {
81
            methodname: 'qbank_columnsortorder_set_column_size',
82
            args: {
83
                global,
84
            },
85
        },
86
        {
87
            methodname: 'qbank_columnsortorder_set_columnbank_order',
88
            args: {
89
                global,
90
            },
91
        },
92
        {
93
            methodname: 'qbank_columnsortorder_set_hidden_columns',
94
            args: {
95
                global,
96
            },
97
        },
98
    ])
99
);