MDL-68793 core_table: fix WS name to comply with guidelines
[moodle.git] / lib / table / amd / src / local / dynamic / repository.js
CommitLineData
1592c3c4
SL
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 * A javascript module to handle calendar ajax actions.
18 *
19 * @module core_calendar/repository
20 * @class repository
21 * @package core_calendar
22 * @copyright 2017 Simey Lameze <lameze@moodle.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25import {call as fetchMany} from 'core/ajax';
26
27/**
28 * Fetch table view.
29 *
30 * @method fetch
4cf97b7f 31 * @param {String} component The component
1592c3c4
SL
32 * @param {String} handler The name of the handler
33 * @param {String} uniqueid The unique id of the table
a31a2b6d
AN
34 * @param {Object} options The options to use when updating the table
35 * @param {Array} options.sortData The list of columns to sort by
36 * @param {Number} options.joinType The filterset join type
37 * @param {Object} options.filters The filters to apply when searching
38 * @param {String} options.firstinitial The first name initial to filter on
39 * @param {String} options.lastinitial The last name initial to filter on
40 * @param {String} options.pageNumber The page number
41 * @param {Number} options.pageSize The page size
42 * @param {Object} options.hiddenColumns The columns to hide
68c46a28 43 * @param {Bool} resetPreferences
1592c3c4
SL
44 * @return {Promise} Resolved with requested table view
45 */
4cf97b7f 46export const fetch = (component, handler, uniqueid, {
a31a2b6d 47 sortData = [],
1592c3c4 48 joinType = null,
c540a575
AN
49 filters = {},
50 firstinitial = null,
51 lastinitial = null,
f7b84afe
SL
52 pageNumber = null,
53 pageSize = null,
e2f12c22 54 hiddenColumns = {}
68c46a28 55 } = {}, resetPreferences = false) => {
1592c3c4 56 return fetchMany([{
1179f07d 57 methodname: `core_table_get_dynamic_table_content`,
1592c3c4 58 args: {
4cf97b7f 59 component,
1592c3c4
SL
60 handler,
61 uniqueid,
a31a2b6d 62 sortdata: sortData,
1592c3c4
SL
63 jointype: joinType,
64 filters,
c540a575
AN
65 firstinitial,
66 lastinitial,
f7b84afe
SL
67 pagenumber: pageNumber,
68 pagesize: pageSize,
e2f12c22 69 hiddencolumns: hiddenColumns,
68c46a28 70 resetpreferences: resetPreferences
1592c3c4
SL
71 },
72 }])[0];
73};