luci-base: form.js: fix handling of array sections in JSONMap forms
authorJo-Philipp Wich <jo@mein.io>
Sun, 14 Jun 2020 14:41:02 +0000 (16:41 +0200)
committerJo-Philipp Wich <jo@mein.io>
Sun, 14 Jun 2020 14:41:49 +0000 (16:41 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/form.js

index c86f75785ca3a2b670fa0bacfb8ee45f18ad3c31..a50d457e213f0a559d0d106ccbf9e4cf289299ff 100644 (file)
@@ -27,17 +27,7 @@ var CBIJSONConfig = baseclass.extend({
                        if (!data.hasOwnProperty(sectiontype))
                                continue;
 
-                       if (L.isObject(data[sectiontype])) {
-                               this.data[sectiontype] = Object.assign(data[sectiontype], {
-                                       '.anonymous': false,
-                                       '.name': sectiontype,
-                                       '.type': sectiontype
-                               });
-
-                               section_ids.push(sectiontype);
-                               num_sections++;
-                       }
-                       else if (Array.isArray(data[sectiontype])) {
+                       if (Array.isArray(data[sectiontype])) {
                                for (var i = 0, index = 0; i < data[sectiontype].length; i++) {
                                        var item = data[sectiontype][i],
                                            anonymous, name;
@@ -65,6 +55,16 @@ var CBIJSONConfig = baseclass.extend({
                                        });
                                }
                        }
+                       else if (L.isObject(data[sectiontype])) {
+                               this.data[sectiontype] = Object.assign(data[sectiontype], {
+                                       '.anonymous': false,
+                                       '.name': sectiontype,
+                                       '.type': sectiontype
+                               });
+
+                               section_ids.push(sectiontype);
+                               num_sections++;
+                       }
                }
 
                section_ids.sort(L.bind(function(a, b) {