luci-base: form.js: reuse JSONMap data provider in GridSection modals
authorJo-Philipp Wich <jo@mein.io>
Sat, 4 Feb 2023 21:15:42 +0000 (22:15 +0100)
committerJo-Philipp Wich <jo@mein.io>
Sat, 4 Feb 2023 21:22:53 +0000 (22:22 +0100)
Reuse the same data provider as the parent JSONMap instance in order
to avoid inadvertently mangling the form data when saving the modal
edit dialog.

Fixes: bb9ede238a ("luci-base: form.js: reuse JSONMap data provider in GridSection modals")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/form.js

index 4edfc7e1352a1aed3ae70ba4779b5a3a3f26de28..317b49fdfeebde5f322184fe2bdd8e825fdb9bec 100644 (file)
@@ -3213,10 +3213,13 @@ var CBITableSection = CBITypedSection.extend(/** @lends LuCI.form.TableSection.p
 
                        var m;
 
-                       if (parent instanceof CBIJSONMap)
-                               m = new CBIJSONMap(parent.data.data, null, null);
-                       else
+                       if (parent instanceof CBIJSONMap) {
+                               m = new CBIJSONMap(null, null, null);
+                               m.data = parent.data;
+                       }
+                       else {
                                m = new CBIMap(parent.config, null, null);
+                       }
 
                        var s = m.section(CBINamedSection, section_id, this.sectiontype);