mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-78370 block_myoverview: Ensure that the summary text will be loaded
* With the summary data being excluded in card/list display modes, it means that switching to the summary display mode will render the courses in summary view without the summary text. This patch will ensure that course summary text are included when switching to the summary view.
This commit is contained in:
parent
40c329064b
commit
3056f6cdbd
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
@ -63,6 +63,16 @@ let lastLimit = 0;
|
||||
|
||||
let namespace = null;
|
||||
|
||||
/**
|
||||
* Whether the summary display has been loaded.
|
||||
*
|
||||
* If true, this means that courses have been loaded with the summary text.
|
||||
* Otherwise, switching to the summary display mode will require course data to be fetched with the summary text.
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
let summaryDisplayLoaded = false;
|
||||
|
||||
/**
|
||||
* Get filter values from DOM.
|
||||
*
|
||||
@ -107,6 +117,7 @@ const getMyCourses = (filters, limit) => {
|
||||
};
|
||||
if (filters.display === 'summary') {
|
||||
params.requiredfields = Repository.SUMMARY_REQUIRED_FIELDS;
|
||||
summaryDisplayLoaded = true;
|
||||
} else {
|
||||
params.requiredfields = Repository.CARDLIST_REQUIRED_FIELDS;
|
||||
}
|
||||
@ -133,8 +144,10 @@ const getSearchMyCourses = (filters, limit, searchValue) => {
|
||||
};
|
||||
if (filters.display === 'summary') {
|
||||
params.requiredfields = Repository.SUMMARY_REQUIRED_FIELDS;
|
||||
summaryDisplayLoaded = true;
|
||||
} else {
|
||||
params.requiredfields = Repository.CARDLIST_REQUIRED_FIELDS;
|
||||
summaryDisplayLoaded = false;
|
||||
}
|
||||
return Repository.getEnrolledCoursesByTimeline(params);
|
||||
};
|
||||
@ -846,12 +859,25 @@ export const init = root => {
|
||||
*/
|
||||
export const reset = root => {
|
||||
if (loadedPages.length > 0) {
|
||||
loadedPages.forEach((courseList, index) => {
|
||||
let pagedContentPage = getPagedContentContainer(root, index);
|
||||
renderCourses(root, courseList).then((html, js) => {
|
||||
return Templates.replaceNodeContents(pagedContentPage, html, js);
|
||||
}).catch(Notification.exception);
|
||||
});
|
||||
const filters = getFilterValues(root);
|
||||
// If the display mode is changed to 'summary' but the summary display has not been loaded yet,
|
||||
// we need to re-fetch the courses to include the course summary text.
|
||||
if (filters.display === 'summary' && !summaryDisplayLoaded) {
|
||||
const page = document.querySelector(SELECTORS.region.selectBlock);
|
||||
const input = page.querySelector(SELECTORS.region.searchInput);
|
||||
if (input.value !== '') {
|
||||
initializePagedContent(root, searchFunctionalityCurry(), input.value.trim());
|
||||
} else {
|
||||
initializePagedContent(root, standardFunctionalityCurry());
|
||||
}
|
||||
} else {
|
||||
loadedPages.forEach((courseList, index) => {
|
||||
let pagedContentPage = getPagedContentContainer(root, index);
|
||||
renderCourses(root, courseList).then((html, js) => {
|
||||
return Templates.replaceNodeContents(pagedContentPage, html, js);
|
||||
}).catch(Notification.exception);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
init(root);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user