MDL-68951 user: Add appropriate exceptions for table/participants
authorAndrew Nicols <andrew@nicols.co.uk>
Mon, 8 Jun 2020 00:05:00 +0000 (08:05 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Mon, 8 Jun 2020 01:35:39 +0000 (09:35 +0800)
12 files changed:
enrol/manual/amd/build/quickenrolment.min.js
enrol/manual/amd/build/quickenrolment.min.js.map
enrol/manual/amd/src/quickenrolment.js
lib/table/amd/build/dynamic.min.js
lib/table/amd/build/dynamic.min.js.map
lib/table/amd/src/dynamic.js
user/amd/build/participantsfilter.min.js
user/amd/build/participantsfilter.min.js.map
user/amd/build/status_field.min.js
user/amd/build/status_field.min.js.map
user/amd/src/participantsfilter.js
user/amd/src/status_field.js

index ee9d82b..a451f2b 100644 (file)
Binary files a/enrol/manual/amd/build/quickenrolment.min.js and b/enrol/manual/amd/build/quickenrolment.min.js differ
index a413c22..7561852 100644 (file)
Binary files a/enrol/manual/amd/build/quickenrolment.min.js.map and b/enrol/manual/amd/build/quickenrolment.min.js.map differ
index 087e4c4..ee67d3c 100644 (file)
@@ -165,9 +165,15 @@ const submitFormAjax = (dynamicTable, modal) => {
             throw new Error(response.error);
         }
 
-        DynamicTable.refreshTableContent(dynamicTable);
-        return Str.get_string('totalenrolledusers', 'enrol', response.count);
+        return response.count;
     })
+    .then(count => {
+        return Promise.all([
+            Str.get_string('totalenrolledusers', 'enrol', count),
+            DynamicTable.refreshTableContent(dynamicTable),
+        ]);
+    })
+    .then(([notificationBody]) => notificationBody)
     .then(notificationBody => Toast.add(notificationBody))
     .catch(error => {
         Notification.addNotification({
index 3bf3339..29f5cbd 100644 (file)
Binary files a/lib/table/amd/build/dynamic.min.js and b/lib/table/amd/build/dynamic.min.js differ
index f1e7466..26c7b51 100644 (file)
Binary files a/lib/table/amd/build/dynamic.min.js.map and b/lib/table/amd/build/dynamic.min.js.map differ
index 1448991..59c4fb5 100644 (file)
@@ -26,6 +26,7 @@ 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;
 
@@ -353,49 +354,50 @@ export const init = () => {
         if (sortableLink) {
             e.preventDefault();
 
-            setSortOrder(tableRoot, sortableLink.dataset.sortby, sortableLink.dataset.sortorder);
+            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);
+            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);
+            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);
+            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);
+            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);
+            showColumn(tableRoot, show.dataset.column).catch(Notification.exception);
         }
 
         const resetTablePreferencesLink = e.target.closest('.resettable a');
         if (resetTablePreferencesLink) {
             e.preventDefault();
 
-            resetTablePreferences(tableRoot);
+            resetTablePreferences(tableRoot).catch(Notification.exception);
         }
     });
 };
index 1176f2b..60a726d 100644 (file)
Binary files a/user/amd/build/participantsfilter.min.js and b/user/amd/build/participantsfilter.min.js differ
index b4c9f89..7965370 100644 (file)
Binary files a/user/amd/build/participantsfilter.min.js.map and b/user/amd/build/participantsfilter.min.js.map differ
index 5c1b1bb..f0f6af8 100644 (file)
Binary files a/user/amd/build/status_field.min.js and b/user/amd/build/status_field.min.js differ
index 2c77fb2..52641a3 100644 (file)
Binary files a/user/amd/build/status_field.min.js.map and b/user/amd/build/status_field.min.js.map differ
index 718e5ab..4e31a15 100644 (file)
@@ -371,7 +371,8 @@ export const init = participantsRegionId => {
                 filters: Object.values(activeFilters).map(filter => filter.filterValue),
                 jointype: filterSet.querySelector(Selectors.filterset.fields.join).value,
             }
-        );
+        )
+        .catch(Notification.exception);
     };
 
     /**
index 1563120..e5637f6 100644 (file)
@@ -280,7 +280,8 @@ const submitEditFormAjax = (clickedLink, getBody, modal, userEnrolmentId, userDa
         return data;
     })
     .then(() => {
-        DynamicTable.refreshTableContent(getDynamicTableFromLink(clickedLink));
+        DynamicTable.refreshTableContent(getDynamicTableFromLink(clickedLink))
+        .catch(Notification.exception);
 
         return Str.get_string('enrolmentupdatedforuser', 'core_enrol', userData);
     })
@@ -321,7 +322,8 @@ const submitUnenrolFormAjax = (clickedLink, modal, args, userData) => {
         return data;
     })
     .then(() => {
-        DynamicTable.refreshTableContent(getDynamicTableFromLink(clickedLink));
+        DynamicTable.refreshTableContent(getDynamicTableFromLink(clickedLink))
+        .catch(Notification.exception);
 
         return Str.get_string('unenrolleduser', 'core_enrol', userData);
     })