MDL-69336 lib: Correctly return promises when table show/hide columns
authorMichael Hawkins <michaelh@moodle.com>
Thu, 23 Jul 2020 04:45:19 +0000 (12:45 +0800)
committerMichael Hawkins <michaelh@moodle.com>
Tue, 4 Aug 2020 07:20:29 +0000 (15:20 +0800)
Previously showColumn and HideColumn were returning nothing, so
attempts to catch exceptions were themselves throwing errors in the
browser console.

lib/table/amd/build/dynamic.min.js
lib/table/amd/build/dynamic.min.js.map
lib/table/amd/src/dynamic.js

index 11ddc73..457bab1 100644 (file)
Binary files a/lib/table/amd/build/dynamic.min.js and b/lib/table/amd/build/dynamic.min.js differ
index 089870b..e2275f1 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 899809b..a0246dd 100644 (file)
@@ -336,12 +336,13 @@ export const getLastInitial = tableRoot => getTableData(tableRoot).tableLastInit
  * @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);
 
-    updateTable(tableRoot, {hiddenColumns}, refreshContent);
+    return updateTable(tableRoot, {hiddenColumns}, refreshContent);
 };
 
 /**
@@ -350,12 +351,13 @@ export const hideColumn = (tableRoot, columnToHide, refreshContent = true) => {
  * @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);
 
-    updateTable(tableRoot, {hiddenColumns}, refreshContent);
+    return updateTable(tableRoot, {hiddenColumns}, refreshContent);
 };
 
 /**