first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
define("core_table/local/dynamic/events",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;var eventName,_default={tableContentRefreshed:(eventName="tableContentRefreshed","core_table/dynamic:".concat(eventName))};return _exports.default=_default,_exports.default}));
//# sourceMappingURL=events.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"events.min.js","sources":["../../../src/local/dynamic/events.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Dynamic table selectors.\n *\n * @module core_table/local/dynamic/events\n * @copyright 2020 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nconst prefixEventName = eventName => `core_table/dynamic:${eventName}`;\n\nexport default {\n tableContentRefreshed: prefixEventName('tableContentRefreshed'),\n};\n"],"names":["eventName","tableContentRefreshed"],"mappings":"6JAuBwBA,mBAET,CACXC,uBAHoBD,UAGmB,qDAHgBA"}
+3
View File
@@ -0,0 +1,3 @@
define("core_table/local/dynamic/repository",["exports","core/ajax"],(function(_exports,_ajax){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.fetch=void 0;_exports.fetch=function(component,handler,uniqueid){let{sortData:sortData=[],joinType:joinType=null,filters:filters={},firstinitial:firstinitial=null,lastinitial:lastinitial=null,pageNumber:pageNumber=null,pageSize:pageSize=null,hiddenColumns:hiddenColumns={}}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},resetPreferences=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return(0,_ajax.call)([{methodname:"core_table_get_dynamic_table_content",args:{component:component,handler:handler,uniqueid:uniqueid,sortdata:sortData,jointype:joinType,filters:filters,firstinitial:firstinitial,lastinitial:lastinitial,pagenumber:pageNumber,pagesize:pageSize,hiddencolumns:hiddenColumns,resetpreferences:resetPreferences}}])[0]}}));
//# sourceMappingURL=repository.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"repository.min.js","sources":["../../../src/local/dynamic/repository.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * A javascript module to handle calendar ajax actions.\n *\n * @module core_table/local/dynamic/repository\n * @copyright 2017 Simey Lameze <lameze@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport {call as fetchMany} from 'core/ajax';\n\n/**\n * Fetch table view.\n *\n * @method fetch\n * @param {String} component The component\n * @param {String} handler The name of the handler\n * @param {String} uniqueid The unique id of the table\n * @param {Object} options The options to use when updating the table\n * @param {Array} options.sortData The list of columns to sort by\n * @param {Number} options.joinType The filterset join type\n * @param {Object} options.filters The filters to apply when searching\n * @param {String} options.firstinitial The first name initial to filter on\n * @param {String} options.lastinitial The last name initial to filter on\n * @param {String} options.pageNumber The page number\n * @param {Number} options.pageSize The page size\n * @param {Object} options.hiddenColumns The columns to hide\n * @param {Bool} resetPreferences\n * @return {Promise} Resolved with requested table view\n */\nexport const fetch = (component, handler, uniqueid, {\n sortData = [],\n joinType = null,\n filters = {},\n firstinitial = null,\n lastinitial = null,\n pageNumber = null,\n pageSize = null,\n hiddenColumns = {}\n} = {}, resetPreferences = false) => fetchMany([{\n methodname: `core_table_get_dynamic_table_content`,\n args: {\n component,\n handler,\n uniqueid,\n sortdata: sortData,\n jointype: joinType,\n filters,\n firstinitial,\n lastinitial,\n pagenumber: pageNumber,\n pagesize: pageSize,\n hiddencolumns: hiddenColumns,\n resetpreferences: resetPreferences\n },\n}])[0];\n"],"names":["component","handler","uniqueid","sortData","joinType","filters","firstinitial","lastinitial","pageNumber","pageSize","hiddenColumns","resetPreferences","methodname","args","sortdata","jointype","pagenumber","pagesize","hiddencolumns","resetpreferences"],"mappings":"4LA2CqB,SAACA,UAAWC,QAASC,cAAUC,SAChDA,SAAW,GADqCC,SAEhDA,SAAW,KAFqCC,QAGhDA,QAAU,GAHsCC,aAIhDA,aAAe,KAJiCC,YAKhDA,YAAc,KALkCC,WAMhDA,WAAa,KANmCC,SAOhDA,SAAW,KAPqCC,cAQhDA,cAAgB,2DAChB,GAAIC,gFAA6B,cAAU,CAAC,CAC5CC,kDACAC,KAAM,CACFb,UAAAA,UACAC,QAAAA,QACAC,SAAAA,SACAY,SAAUX,SACVY,SAAUX,SACVC,QAAAA,QACAC,aAAAA,aACAC,YAAAA,YACAS,WAAYR,WACZS,SAAUR,SACVS,cAAeR,cACfS,iBAAkBR,qBAEtB"}
+3
View File
@@ -0,0 +1,3 @@
define("core_table/local/dynamic/selectors",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={main:{region:'[data-region="core_table/dynamic"]',fromRegionId:regionId=>'[data-region="core_table/dynamic"][data-table-uniqueid="'.concat(regionId,'"]')},table:{links:{sortableColumn:'a[data-sortable="1"]',hide:'a[data-action="hide"]',show:'a[data-action="show"]'}},initialsBar:{links:{firstInitial:".firstinitial [data-initial]",lastInitial:".lastinitial [data-initial]"}},paginationBar:{links:{pageItem:".pagination [data-page-number]"}},showCount:{links:{toggle:'[data-action="showcount"]'}}},_exports.default}));
//# sourceMappingURL=selectors.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"selectors.min.js","sources":["../../../src/local/dynamic/selectors.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Dynamic table selectors.\n *\n * @module core_table/local/dynamic/selectors\n * @copyright 2020 Simey Lameze <simey@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n main: {\n region: '[data-region=\"core_table/dynamic\"]',\n fromRegionId: regionId => `[data-region=\"core_table/dynamic\"][data-table-uniqueid=\"${regionId}\"]`,\n },\n table: {\n links: {\n sortableColumn: 'a[data-sortable=\"1\"]',\n hide: 'a[data-action=\"hide\"]',\n show: 'a[data-action=\"show\"]',\n },\n },\n initialsBar: {\n links: {\n firstInitial: '.firstinitial [data-initial]',\n lastInitial: '.lastinitial [data-initial]',\n },\n },\n paginationBar: {\n links: {\n pageItem: '.pagination [data-page-number]'\n }\n },\n showCount: {\n links: {\n toggle: '[data-action=\"showcount\"]',\n },\n },\n};\n"],"names":["main","region","fromRegionId","regionId","table","links","sortableColumn","hide","show","initialsBar","firstInitial","lastInitial","paginationBar","pageItem","showCount","toggle"],"mappings":"oLAsBe,CACXA,KAAM,CACFC,OAAQ,qCACRC,aAAcC,4EAAuEA,gBAEzFC,MAAO,CACHC,MAAO,CACHC,eAAgB,uBAChBC,KAAM,wBACNC,KAAM,0BAGdC,YAAa,CACTJ,MAAO,CACHK,aAAc,+BACdC,YAAa,gCAGrBC,cAAe,CACXP,MAAO,CACHQ,SAAU,mCAGlBC,UAAW,CACPT,MAAO,CACHU,OAAQ"}
+472
View File
@@ -0,0 +1,472 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Module to handle dynamic table features.
*
* @module core_table/dynamic
* @copyright 2020 Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import * as Selectors from 'core_table/local/dynamic/selectors';
import Events from './local/dynamic/events';
import Pending from 'core/pending';
import {addIconToContainer} from 'core/loadingicon';
import {fetch as fetchTableData} from 'core_table/local/dynamic/repository';
import Notification from 'core/notification';
let watching = false;
/**
* Ensure that a table is a dynamic table.
*
* @param {HTMLElement} tableRoot
* @returns {Bool}
*/
const checkTableIsDynamic = tableRoot => {
if (!tableRoot) {
// The table is not a dynamic table.
throw new Error("The table specified is not a dynamic table and cannot be updated");
}
if (!tableRoot.matches(Selectors.main.region)) {
// The table is not a dynamic table.
throw new Error("The table specified is not a dynamic table and cannot be updated");
}
return true;
};
/**
* Get the filterset data from a known dynamic table.
*
* @param {HTMLElement} tableRoot
* @returns {Object}
*/
const getFiltersetFromTable = tableRoot => {
return JSON.parse(tableRoot.dataset.tableFilters);
};
/**
* Update the specified table based on its current values.
*
* @param {HTMLElement} tableRoot
* @param {Bool} resetContent
* @returns {Promise}
*/
export const refreshTableContent = (tableRoot, resetContent = false) => {
const filterset = getFiltersetFromTable(tableRoot);
addIconToContainer(tableRoot);
const pendingPromise = new Pending('core_table/dynamic:refreshTableContent');
return fetchTableData(
tableRoot.dataset.tableComponent,
tableRoot.dataset.tableHandler,
tableRoot.dataset.tableUniqueid,
{
sortData: JSON.parse(tableRoot.dataset.tableSortData),
joinType: filterset.jointype,
filters: filterset.filters,
firstinitial: tableRoot.dataset.tableFirstInitial,
lastinitial: tableRoot.dataset.tableLastInitial,
pageNumber: tableRoot.dataset.tablePageNumber,
pageSize: tableRoot.dataset.tablePageSize,
hiddenColumns: JSON.parse(tableRoot.dataset.tableHiddenColumns),
},
resetContent,
)
.then(data => {
const placeholder = document.createElement('div');
placeholder.innerHTML = data.html;
tableRoot.replaceWith(...placeholder.childNodes);
// Update the tableRoot.
return getTableFromId(tableRoot.dataset.tableUniqueid);
}).then(tableRoot => {
tableRoot.dispatchEvent(new CustomEvent(Events.tableContentRefreshed, {
bubbles: true,
}));
return tableRoot;
})
.then(tableRoot => {
pendingPromise.resolve();
return tableRoot;
});
};
export const updateTable = (tableRoot, {
sortBy = null,
sortOrder = null,
filters = null,
firstInitial = null,
lastInitial = null,
pageNumber = null,
pageSize = null,
hiddenColumns = null,
} = {}, refreshContent = true) => {
checkTableIsDynamic(tableRoot);
const pendingPromise = new Pending('core_table/dynamic:updateTable');
let tableConfigChanged = false;
// Update sort fields.
if (sortBy && sortOrder) {
// Always update the table if requested and there were sort fields.
// These fields are only ever normalised in the backend.
tableConfigChanged = true;
const sortData = JSON.parse(tableRoot.dataset.tableSortData);
sortData.unshift({
sortby: sortBy,
sortorder: parseInt(sortOrder, 10),
});
tableRoot.dataset.tableSortData = JSON.stringify(sortData);
}
// Update initials.
if (firstInitial !== null) {
if (tableRoot.dataset.tableFirstInitial !== firstInitial) {
tableConfigChanged = true;
}
tableRoot.dataset.tableFirstInitial = firstInitial;
}
if (lastInitial !== null) {
if (tableRoot.dataset.tableLastInitial !== lastInitial) {
tableConfigChanged = true;
}
tableRoot.dataset.tableLastInitial = lastInitial;
}
if (pageSize !== null) {
if (tableRoot.dataset.tablePageSize != pageSize) {
tableConfigChanged = true;
}
tableRoot.dataset.tablePageSize = pageSize;
}
// Update filters.
if (filters) {
const filterJson = JSON.stringify(filters);
if (tableRoot.dataset.tableFilters !== filterJson) {
tableConfigChanged = true;
}
tableRoot.dataset.tableFilters = filterJson;
}
// Reset to page 1 when table content is being altered by filtering or sorting.
// This ensures the table page being loaded always exists, and gives a consistent experience.
if (tableConfigChanged) {
pageNumber = 1;
}
// Update hidden columns.
if (hiddenColumns) {
const columnJson = JSON.stringify(hiddenColumns);
if (tableRoot.dataset.tableHiddenColumns !== columnJson) {
tableConfigChanged = true;
}
tableRoot.dataset.tableHiddenColumns = columnJson;
}
if (pageNumber !== null) {
if (tableRoot.dataset.tablePageNumber != pageNumber) {
tableConfigChanged = true;
}
tableRoot.dataset.tablePageNumber = pageNumber;
}
// Refresh.
if (refreshContent && tableConfigChanged) {
return refreshTableContent(tableRoot)
.then(tableRoot => {
pendingPromise.resolve();
return tableRoot;
});
} else {
pendingPromise.resolve();
return Promise.resolve(tableRoot);
}
};
/**
* Get the table dataset for the specified tableRoot, ensuring that the provided table is a dynamic table.
*
* @param {HTMLElement} tableRoot
* @returns {DOMStringMap}
*/
const getTableData = tableRoot => {
checkTableIsDynamic(tableRoot);
return tableRoot.dataset;
};
/**
* Update the specified table using the new filters.
*
* @param {HTMLElement} tableRoot
* @param {Object} filters
* @param {Bool} refreshContent
* @returns {Promise}
*/
export const setFilters = (tableRoot, filters, refreshContent = true) =>
updateTable(tableRoot, {filters}, refreshContent);
/**
* Get the filter data for the specified table.
*
* @param {HTMLElement} tableRoot
* @returns {Object}
*/
export const getFilters = tableRoot => {
checkTableIsDynamic(tableRoot);
return getFiltersetFromTable(tableRoot);
};
/**
* Update the sort order.
*
* @param {HTMLElement} tableRoot
* @param {String} sortBy
* @param {Number} sortOrder
* @param {Bool} refreshContent
* @returns {Promise}
*/
export const setSortOrder = (tableRoot, sortBy, sortOrder, refreshContent = true) =>
updateTable(tableRoot, {sortBy, sortOrder}, refreshContent);
/**
* Set the page number.
*
* @param {HTMLElement} tableRoot
* @param {String} pageNumber
* @param {Bool} refreshContent
* @returns {Promise}
*/
export const setPageNumber = (tableRoot, pageNumber, refreshContent = true) =>
updateTable(tableRoot, {pageNumber}, refreshContent);
/**
* Get the current page number.
*
* @param {HTMLElement} tableRoot
* @returns {Number}
*/
export const getPageNumber = tableRoot => getTableData(tableRoot).tablePageNumber;
/**
* Set the page size.
*
* @param {HTMLElement} tableRoot
* @param {Number} pageSize
* @param {Bool} refreshContent
* @returns {Promise}
*/
export const setPageSize = (tableRoot, pageSize, refreshContent = true) =>
updateTable(tableRoot, {pageSize, pageNumber: 1}, refreshContent);
/**
* Get the current page size.
*
* @param {HTMLElement} tableRoot
* @returns {Number}
*/
export const getPageSize = tableRoot => getTableData(tableRoot).tablePageSize;
/**
* Update the first initial to show.
*
* @param {HTMLElement} tableRoot
* @param {String} firstInitial
* @param {Bool} refreshContent
* @returns {Promise}
*/
export const setFirstInitial = (tableRoot, firstInitial, refreshContent = true) =>
updateTable(tableRoot, {firstInitial}, refreshContent);
/**
* Get the current first initial filter.
*
* @param {HTMLElement} tableRoot
* @returns {String}
*/
export const getFirstInitial = tableRoot => getTableData(tableRoot).tableFirstInitial;
/**
* Update the last initial to show.
*
* @param {HTMLElement} tableRoot
* @param {String} lastInitial
* @param {Bool} refreshContent
* @returns {Promise}
*/
export const setLastInitial = (tableRoot, lastInitial, refreshContent = true) =>
updateTable(tableRoot, {lastInitial}, refreshContent);
/**
* Get the current last initial filter.
*
* @param {HTMLElement} tableRoot
* @returns {String}
*/
export const getLastInitial = tableRoot => getTableData(tableRoot).tableLastInitial;
/**
* Hide a column in the participants table.
*
* @param {HTMLElement} tableRoot
* @param {String} columnToHide
* @param {Bool} refreshContent
* @returns {Promise}
*/
export const hideColumn = (tableRoot, columnToHide, refreshContent = true) => {
const hiddenColumns = JSON.parse(tableRoot.dataset.tableHiddenColumns);
hiddenColumns.push(columnToHide);
return updateTable(tableRoot, {hiddenColumns}, refreshContent);
};
/**
* Make a hidden column visible in the participants table.
*
* @param {HTMLElement} tableRoot
* @param {String} columnToShow
* @param {Bool} refreshContent
* @returns {Promise}
*/
export const showColumn = (tableRoot, columnToShow, refreshContent = true) => {
let hiddenColumns = JSON.parse(tableRoot.dataset.tableHiddenColumns);
hiddenColumns = hiddenColumns.filter(columnName => columnName !== columnToShow);
return updateTable(tableRoot, {hiddenColumns}, refreshContent);
};
/**
* Reset table preferences.
*
* @param {HTMLElement} tableRoot
* @returns {Promise}
*/
const resetTablePreferences = tableRoot => refreshTableContent(tableRoot, true);
/**
* Set up listeners to handle table updates.
*/
export const init = () => {
if (watching) {
// Already watching.
return;
}
watching = true;
document.addEventListener('click', e => {
const tableRoot = e.target.closest(Selectors.main.region);
if (!tableRoot) {
return;
}
const sortableLink = e.target.closest(Selectors.table.links.sortableColumn);
if (sortableLink) {
e.preventDefault();
setSortOrder(tableRoot, sortableLink.dataset.sortby, sortableLink.dataset.sortorder)
.catch(Notification.exception);
}
const firstInitialLink = e.target.closest(Selectors.initialsBar.links.firstInitial);
if (firstInitialLink !== null) {
e.preventDefault();
setFirstInitial(tableRoot, firstInitialLink.dataset.initial).catch(Notification.exception);
}
const lastInitialLink = e.target.closest(Selectors.initialsBar.links.lastInitial);
if (lastInitialLink !== null) {
e.preventDefault();
setLastInitial(tableRoot, lastInitialLink.dataset.initial).catch(Notification.exception);
}
const pageItem = e.target.closest(Selectors.paginationBar.links.pageItem);
if (pageItem) {
e.preventDefault();
setPageNumber(tableRoot, pageItem.dataset.pageNumber).catch(Notification.exception);
}
const hide = e.target.closest(Selectors.table.links.hide);
if (hide) {
e.preventDefault();
hideColumn(tableRoot, hide.dataset.column).catch(Notification.exception);
}
const show = e.target.closest(Selectors.table.links.show);
if (show) {
e.preventDefault();
showColumn(tableRoot, show.dataset.column).catch(Notification.exception);
}
const resetTablePreferencesLink = e.target.closest('.resettable a');
if (resetTablePreferencesLink) {
e.preventDefault();
resetTablePreferences(tableRoot).catch(Notification.exception);
}
const showCountLink = e.target.closest(Selectors.showCount.links.toggle);
if (showCountLink) {
e.preventDefault();
setPageSize(tableRoot, showCountLink.dataset.targetPageSize).catch(Notification.exception);
}
});
};
/**
* Fetch the table via its table region id.
*
* @param {String} tableRegionId
* @returns {HTMLElement}
*/
export const getTableFromId = tableRegionId => {
const tableRoot = document.querySelector(Selectors.main.fromRegionId(tableRegionId));
if (!tableRoot) {
// The table is not a dynamic table.
throw new Error("The table specified is not a dynamic table and cannot be updated");
}
return tableRoot;
};
export {
Events
};
+28
View File
@@ -0,0 +1,28 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Dynamic table selectors.
*
* @module core_table/local/dynamic/events
* @copyright 2020 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
const prefixEventName = eventName => `core_table/dynamic:${eventName}`;
export default {
tableContentRefreshed: prefixEventName('tableContentRefreshed'),
};
@@ -0,0 +1,69 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A javascript module to handle calendar ajax actions.
*
* @module core_table/local/dynamic/repository
* @copyright 2017 Simey Lameze <lameze@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import {call as fetchMany} from 'core/ajax';
/**
* Fetch table view.
*
* @method fetch
* @param {String} component The component
* @param {String} handler The name of the handler
* @param {String} uniqueid The unique id of the table
* @param {Object} options The options to use when updating the table
* @param {Array} options.sortData The list of columns to sort by
* @param {Number} options.joinType The filterset join type
* @param {Object} options.filters The filters to apply when searching
* @param {String} options.firstinitial The first name initial to filter on
* @param {String} options.lastinitial The last name initial to filter on
* @param {String} options.pageNumber The page number
* @param {Number} options.pageSize The page size
* @param {Object} options.hiddenColumns The columns to hide
* @param {Bool} resetPreferences
* @return {Promise} Resolved with requested table view
*/
export const fetch = (component, handler, uniqueid, {
sortData = [],
joinType = null,
filters = {},
firstinitial = null,
lastinitial = null,
pageNumber = null,
pageSize = null,
hiddenColumns = {}
} = {}, resetPreferences = false) => fetchMany([{
methodname: `core_table_get_dynamic_table_content`,
args: {
component,
handler,
uniqueid,
sortdata: sortData,
jointype: joinType,
filters,
firstinitial,
lastinitial,
pagenumber: pageNumber,
pagesize: pageSize,
hiddencolumns: hiddenColumns,
resetpreferences: resetPreferences
},
}])[0];
@@ -0,0 +1,51 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Dynamic table selectors.
*
* @module core_table/local/dynamic/selectors
* @copyright 2020 Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
export default {
main: {
region: '[data-region="core_table/dynamic"]',
fromRegionId: regionId => `[data-region="core_table/dynamic"][data-table-uniqueid="${regionId}"]`,
},
table: {
links: {
sortableColumn: 'a[data-sortable="1"]',
hide: 'a[data-action="hide"]',
show: 'a[data-action="show"]',
},
},
initialsBar: {
links: {
firstInitial: '.firstinitial [data-initial]',
lastInitial: '.lastinitial [data-initial]',
},
},
paginationBar: {
links: {
pageItem: '.pagination [data-page-number]'
}
},
showCount: {
links: {
toggle: '[data-action="showcount"]',
},
},
};