luci-base: luci.js: render view buttons depending on available functions
authorJo-Philipp Wich <jo@mein.io>
Tue, 17 Sep 2019 05:03:27 +0000 (07:03 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 17 Sep 2019 05:03:27 +0000 (07:03 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/luci.js

index bcc6870bd218e4cfa36c313df82690343cb454f4..0b7ec6ea86d71d59a6bc22d9ae6d1c62aa78f4c3 100644 (file)
                        },
 
                        addFooter: function() {
-                               var footer = E([]),
-                                   mc = document.getElementById('maincontent');
+                               var footer = E([]);
 
-                               if (mc.querySelector('.cbi-map')) {
+                               if (this.handleSaveApply || this.handleSave || this.handleReset) {
                                        footer.appendChild(E('div', { 'class': 'cbi-page-actions' }, [
-                                               E('button', {
+                                               this.handleSaveApply ? E('button', {
                                                        'class': 'cbi-button cbi-button-apply',
                                                        'click': L.ui.createHandlerFn(this, 'handleSaveApply')
-                                               }, _('Save & Apply')), ' ',
-                                               E('button', {
+                                               }, _('Save & Apply')) : '', ' ',
+                                               this.handleSave ? E('button', {
                                                        'class': 'cbi-button cbi-button-save',
                                                        'click': L.ui.createHandlerFn(this, 'handleSave')
-                                               }, _('Save')), ' ',
-                                               E('button', {
+                                               }, _('Save')) : '', ' ',
+                                               this.handleReset ? E('button', {
                                                        'class': 'cbi-button cbi-button-reset',
                                                        'click': L.ui.createHandlerFn(this, 'handleReset')
-                                               }, _('Reset'))
+                                               }, _('Reset')) : ''
                                        ]));
                                }