mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-78370 block_myoverview: Define required fields for views
* For list and card views, we only need the course fields ('id', 'fullname', 'shortname', 'showcoursecategory', 'showshortname', 'visible', and 'enddate'). * For summary view, in addition to the fields from list/card views, we only need the 'summary' and 'summaryformat'.
This commit is contained in:
parent
b70de7dbc3
commit
40c329064b
@ -5,6 +5,6 @@ define("block_myoverview/repository",["exports","core/ajax"],(function(_exports,
|
||||
* @module block_myoverview/repository
|
||||
* @copyright 2018 Bas Brands <base@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.setFavouriteCourses=_exports.getEnrolledCoursesByTimeline=void 0,_ajax=(obj=_ajax)&&obj.__esModule?obj:{default:obj};_exports.getEnrolledCoursesByTimeline=args=>{const request={methodname:"core_course_get_enrolled_courses_by_timeline_classification",args:args};return _ajax.default.call([request])[0]};_exports.setFavouriteCourses=args=>{const request={methodname:"core_course_set_favourite_courses",args:args};return _ajax.default.call([request])[0]}}));
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.setFavouriteCourses=_exports.getEnrolledCoursesByTimeline=_exports.SUMMARY_REQUIRED_FIELDS=_exports.CARDLIST_REQUIRED_FIELDS=void 0,_ajax=(obj=_ajax)&&obj.__esModule?obj:{default:obj};_exports.getEnrolledCoursesByTimeline=args=>{const request={methodname:"core_course_get_enrolled_courses_by_timeline_classification",args:args};return _ajax.default.call([request])[0]};_exports.setFavouriteCourses=args=>{const request={methodname:"core_course_set_favourite_courses",args:args};return _ajax.default.call([request])[0]};_exports.CARDLIST_REQUIRED_FIELDS=["id","fullname","shortname","showcoursecategory","showshortname","visible","enddate"];_exports.SUMMARY_REQUIRED_FIELDS=["id","fullname","shortname","showcoursecategory","showshortname","visible","enddate","summary","summaryformat"]}));
|
||||
|
||||
//# sourceMappingURL=repository.min.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"repository.min.js","sources":["../src/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 retrieve enrolled coruses from the server.\n *\n * @module block_myoverview/repository\n * @copyright 2018 Bas Brands <base@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\n\n/**\n * Retrieve a list of enrolled courses.\n *\n * Valid args are:\n * string classification future, inprogress, past\n * int limit number of records to retreive\n * int Offset offset for pagination\n * int sort sort by lastaccess or name\n *\n * @method getEnrolledCoursesByTimeline\n * @param {object} args The request arguments\n * @return {promise} Resolved with an array of courses\n */\nexport const getEnrolledCoursesByTimeline = args => {\n const request = {\n methodname: 'core_course_get_enrolled_courses_by_timeline_classification',\n args: args\n };\n\n return Ajax.call([request])[0];\n};\n\n/**\n * Set the favourite state on a list of courses.\n *\n * Valid args are:\n * Array courses list of course id numbers.\n *\n * @param {Object} args Arguments send to the webservice.\n * @return {Promise} Resolve with warnings.\n */\nexport const setFavouriteCourses = args => {\n const request = {\n methodname: 'core_course_set_favourite_courses',\n args: args\n };\n\n return Ajax.call([request])[0];\n};\n"],"names":["args","request","methodname","Ajax","call"],"mappings":";;;;;;;iOAsC4CA,aAClCC,QAAU,CACZC,WAAY,8DACZF,KAAMA,aAGHG,cAAKC,KAAK,CAACH,UAAU,iCAYGD,aACzBC,QAAU,CACZC,WAAY,oCACZF,KAAMA,aAGHG,cAAKC,KAAK,CAACH,UAAU"}
|
||||
{"version":3,"file":"repository.min.js","sources":["../src/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 retrieve enrolled coruses from the server.\n *\n * @module block_myoverview/repository\n * @copyright 2018 Bas Brands <base@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\n\n/**\n * Retrieve a list of enrolled courses.\n *\n * Valid args are:\n * string classification future, inprogress, past\n * int limit number of records to retreive\n * int Offset offset for pagination\n * int sort sort by lastaccess or name\n *\n * @method getEnrolledCoursesByTimeline\n * @param {object} args The request arguments\n * @return {promise} Resolved with an array of courses\n */\nexport const getEnrolledCoursesByTimeline = args => {\n const request = {\n methodname: 'core_course_get_enrolled_courses_by_timeline_classification',\n args: args\n };\n\n return Ajax.call([request])[0];\n};\n\n/**\n * Set the favourite state on a list of courses.\n *\n * Valid args are:\n * Array courses list of course id numbers.\n *\n * @param {Object} args Arguments send to the webservice.\n * @return {Promise} Resolve with warnings.\n */\nexport const setFavouriteCourses = args => {\n const request = {\n methodname: 'core_course_set_favourite_courses',\n args: args\n };\n\n return Ajax.call([request])[0];\n};\n\n/**\n * These course fields are the only ones needed to be included in the results for the card and list views.\n *\n * @type {string[]}\n */\nexport const CARDLIST_REQUIRED_FIELDS = [\n 'id',\n 'fullname',\n 'shortname',\n 'showcoursecategory',\n 'showshortname',\n 'visible',\n 'enddate',\n];\n\n/**\n * These course fields are the only ones needed to be included in the results for the card and list views.\n *\n * @type {string[]}\n */\nexport const SUMMARY_REQUIRED_FIELDS = [\n 'id',\n 'fullname',\n 'shortname',\n 'showcoursecategory',\n 'showshortname',\n 'visible',\n 'enddate',\n 'summary',\n 'summaryformat',\n];\n"],"names":["args","request","methodname","Ajax","call"],"mappings":";;;;;;;oSAsC4CA,aAClCC,QAAU,CACZC,WAAY,8DACZF,KAAMA,aAGHG,cAAKC,KAAK,CAACH,UAAU,iCAYGD,aACzBC,QAAU,CACZC,WAAY,oCACZF,KAAMA,aAGHG,cAAKC,KAAK,CAACH,UAAU,sCAQQ,CACpC,KACA,WACA,YACA,qBACA,gBACA,UACA,4CAQmC,CACnC,KACA,WACA,YACA,qBACA,gBACA,UACA,UACA,UACA"}
|
2
blocks/myoverview/amd/build/view.min.js
vendored
2
blocks/myoverview/amd/build/view.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -62,3 +62,35 @@ export const setFavouriteCourses = args => {
|
||||
|
||||
return Ajax.call([request])[0];
|
||||
};
|
||||
|
||||
/**
|
||||
* These course fields are the only ones needed to be included in the results for the card and list views.
|
||||
*
|
||||
* @type {string[]}
|
||||
*/
|
||||
export const CARDLIST_REQUIRED_FIELDS = [
|
||||
'id',
|
||||
'fullname',
|
||||
'shortname',
|
||||
'showcoursecategory',
|
||||
'showshortname',
|
||||
'visible',
|
||||
'enddate',
|
||||
];
|
||||
|
||||
/**
|
||||
* These course fields are the only ones needed to be included in the results for the card and list views.
|
||||
*
|
||||
* @type {string[]}
|
||||
*/
|
||||
export const SUMMARY_REQUIRED_FIELDS = [
|
||||
'id',
|
||||
'fullname',
|
||||
'shortname',
|
||||
'showcoursecategory',
|
||||
'showshortname',
|
||||
'visible',
|
||||
'enddate',
|
||||
'summary',
|
||||
'summaryformat',
|
||||
];
|
||||
|
@ -97,14 +97,20 @@ const DEFAULT_PAGED_CONTENT_CONFIG = {
|
||||
* @return {promise} Resolved with an array of courses.
|
||||
*/
|
||||
const getMyCourses = (filters, limit) => {
|
||||
return Repository.getEnrolledCoursesByTimeline({
|
||||
const params = {
|
||||
offset: courseOffset,
|
||||
limit: limit,
|
||||
classification: filters.grouping,
|
||||
sort: filters.sort,
|
||||
customfieldname: filters.customfieldname,
|
||||
customfieldvalue: filters.customfieldvalue
|
||||
});
|
||||
customfieldvalue: filters.customfieldvalue,
|
||||
};
|
||||
if (filters.display === 'summary') {
|
||||
params.requiredfields = Repository.SUMMARY_REQUIRED_FIELDS;
|
||||
} else {
|
||||
params.requiredfields = Repository.CARDLIST_REQUIRED_FIELDS;
|
||||
}
|
||||
return Repository.getEnrolledCoursesByTimeline(params);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -116,15 +122,21 @@ const getMyCourses = (filters, limit) => {
|
||||
* @return {promise} Resolved with an array of courses.
|
||||
*/
|
||||
const getSearchMyCourses = (filters, limit, searchValue) => {
|
||||
return Repository.getEnrolledCoursesByTimeline({
|
||||
const params = {
|
||||
offset: courseOffset,
|
||||
limit: limit,
|
||||
classification: 'search',
|
||||
sort: filters.sort,
|
||||
customfieldname: filters.customfieldname,
|
||||
customfieldvalue: filters.customfieldvalue,
|
||||
searchvalue: searchValue
|
||||
});
|
||||
searchvalue: searchValue,
|
||||
};
|
||||
if (filters.display === 'summary') {
|
||||
params.requiredfields = Repository.SUMMARY_REQUIRED_FIELDS;
|
||||
} else {
|
||||
params.requiredfields = Repository.CARDLIST_REQUIRED_FIELDS;
|
||||
}
|
||||
return Repository.getEnrolledCoursesByTimeline(params);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user