luci-base: form.js: fix GridSection modals in JSONMap instances
authorJo-Philipp Wich <jo@mein.io>
Sat, 4 Feb 2023 20:03:51 +0000 (21:03 +0100)
committerJo-Philipp Wich <jo@mein.io>
Sat, 4 Feb 2023 20:03:51 +0000 (21:03 +0100)
Since grid section edit modals construct a new Map instance internally,
we must take care of using the correct map constructor type for the
internal copy in order to end up with the correct data provider.

Ensure that the extended option modal of GridSection instances uses a
JSONMap when the grid section's owner map is a JSONMap to avoid stray
uci related errors.

Ref: https://forum.openwrt.org/t/luci-save-apply/149658/5
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/form.js

index df0a63a4a1643ac039a4dd87cc835e089eb3ffb0..4edfc7e1352a1aed3ae70ba4779b5a3a3f26de28 100644 (file)
@@ -3211,8 +3211,14 @@ var CBITableSection = CBITypedSection.extend(/** @lends LuCI.form.TableSection.p
                return (stackedMap ? activeMap.save(null, true) : Promise.resolve()).then(L.bind(function() {
                        section_id = sref['.name'];
 
-                       var m = new CBIMap(parent.config, null, null),
-                           s = m.section(CBINamedSection, section_id, this.sectiontype);
+                       var m;
+
+                       if (parent instanceof CBIJSONMap)
+                               m = new CBIJSONMap(parent.data.data, null, null);
+                       else
+                               m = new CBIMap(parent.config, null, null);
+
+                       var s = m.section(CBINamedSection, section_id, this.sectiontype);
 
                        m.parent = parent;
                        m.section = section_id;