luci-base: form.js: reset parent maps on returning from nested section modal
authorJo-Philipp Wich <jo@mein.io>
Mon, 16 May 2022 09:49:28 +0000 (11:49 +0200)
committerJo-Philipp Wich <jo@mein.io>
Mon, 16 May 2022 11:39:36 +0000 (13:39 +0200)
The nested section modal might have changed values also covered/displayed by
the parent map, so ensure to reload all parent maps in the current modal
view stack to ensure that no stale values are shown on return.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/form.js

index eb7a2572d48216482a5bfc845144b4c63b944dc1..6786d3d2345e87fb73c41e689f4123ed0f0ba66f 100644 (file)
@@ -2994,10 +2994,20 @@ var CBITableSection = CBITypedSection.extend(/** @lends LuCI.form.TableSection.p
 
        /** @private */
        handleModalCancel: function(modalMap, ev) {
-               var prevNode = this.getPreviousModalMap();
+               var prevNode = this.getPreviousModalMap(),
+                   resetTasks = Promise.resolve();
 
                if (prevNode) {
-                       var heading = prevNode.parentNode.querySelector('h4');
+                       var heading = prevNode.parentNode.querySelector('h4'),
+                           prevMap = dom.findClassInstance(prevNode);
+
+                       while (prevMap) {
+                               resetTasks = resetTasks
+                                       .then(L.bind(prevMap.load, prevMap))
+                                       .then(L.bind(prevMap.reset, prevMap));
+
+                               prevMap = prevMap.parent;
+                       }
 
                        prevNode.classList.add('flash');
                        prevNode.classList.remove('hidden');
@@ -3014,7 +3024,7 @@ var CBITableSection = CBITypedSection.extend(/** @lends LuCI.form.TableSection.p
                        ui.hideModal();
                }
 
-               return Promise.resolve();
+               return resetTasks;
        },
 
        /** @private */