luci-base: form.js: rendering fixes for grid sections
authorJo-Philipp Wich <jo@mein.io>
Wed, 12 Feb 2020 07:16:06 +0000 (08:16 +0100)
committerJo-Philipp Wich <jo@mein.io>
Thu, 7 May 2020 17:40:49 +0000 (19:40 +0200)
 - Ensure that last header cell is rendered for grid sections without
   sorting or addremove actions
 - Don't skip header cells for optional options

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 9bb78b5cd842f94cbcaf00cc5b19c1e3b9669d93)

modules/luci-base/htdocs/luci-static/resources/form.js

index e547260e4e89579f0f889f1e5d40a6e9a9d674ef..07142b564095d6c05f9074d21724525702c39eac 100644 (file)
@@ -1106,7 +1106,7 @@ var CBITableSection = CBITypedSection.extend({
                return sectionEl;
        },
 
-       renderHeaderRows: function(max_cols) {
+       renderHeaderRows: function(max_cols, has_action) {
                var has_titles = false,
                    has_descriptions = false,
                    max_cols = isNaN(this.max_cols) ? this.children.length : this.max_cols,
@@ -1115,7 +1115,7 @@ var CBITableSection = CBITypedSection.extend({
                    trEls = E([]);
 
                for (var i = 0, opt; i < max_cols && (opt = this.children[i]) != null; i++) {
-                       if (opt.optional || opt.modalonly)
+                       if (opt.modalonly)
                                continue;
 
                        has_titles = has_titles || !!opt.title;
@@ -1129,7 +1129,7 @@ var CBITableSection = CBITypedSection.extend({
                        });
 
                        for (var i = 0, opt; i < max_cols && (opt = this.children[i]) != null; i++) {
-                               if (opt.optional || opt.modalonly)
+                               if (opt.modalonly)
                                        continue;
 
                                trEl.appendChild(E('div', {
@@ -1151,7 +1151,7 @@ var CBITableSection = CBITypedSection.extend({
                                        dom.content(trEl.lastElementChild, opt.title);
                        }
 
-                       if (this.sortable || this.extedit || this.addremove || has_more)
+                       if (this.sortable || this.extedit || this.addremove || has_more || has_action)
                                trEl.appendChild(E('div', {
                                        'class': 'th cbi-section-table-cell cbi-section-actions'
                                }));
@@ -1165,7 +1165,7 @@ var CBITableSection = CBITypedSection.extend({
                        });
 
                        for (var i = 0, opt; i < max_cols && (opt = this.children[i]) != null; i++) {
-                               if (opt.optional || opt.modalonly)
+                               if (opt.modalonly)
                                        continue;
 
                                trEl.appendChild(E('div', {
@@ -1479,6 +1479,10 @@ var CBIGridSection = CBITableSection.extend({
                }, (value != null) ? value : E('em', _('none')));
        },
 
+       renderHeaderRows: function(section_id) {
+               return this.super('renderHeaderRows', [ NaN, true ]);
+       },
+
        renderRowActions: function(section_id) {
                return this.super('renderRowActions', [ section_id, _('Edit') ]);
        },