luci-base: luci.js: add optional apply unchecked action
authorJo-Philipp Wich <jo@mein.io>
Sun, 10 Nov 2019 17:21:09 +0000 (18:21 +0100)
committerJo-Philipp Wich <jo@mein.io>
Sun, 10 Nov 2019 17:21:09 +0000 (18:21 +0100)
Turn the "Save & Apply" button into a combo button which allows to
toggle between apply with rollback and unchecked apply modes.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/luci.js

index 3f4707d4e576d4875540cc4a6492b525ea95854a..7c1831376f35d67fb0e3a617a0abe9044693312d 100644 (file)
                         * returned promise runs to completion before the button
                         * is reenabled.
                         */
-                       handleSaveApply: function(ev) {
+                       handleSaveApply: function(ev, mode) {
                                return this.handleSave(ev).then(function() {
-                                       L.ui.changes.apply(true);
+                                       L.ui.changes.apply(mode == '0');
                                });
                        },
 
                        addFooter: function() {
                                var footer = E([]);
 
+                               var saveApplyBtn = this.handleSaveApply ? new L.ui.ComboButton('0', {
+                                       0: [ _('Save & Apply') ],
+                                       1: [ _('Apply unchecked') ]
+                               }, {
+                                       classes: {
+                                               0: 'cbi-button cbi-button-apply important',
+                                               1: 'cbi-button cbi-button-negative important'
+                                       },
+                                       click: L.ui.createHandlerFn(this, 'handleSaveApply')
+                               }).render() : E([]);
+
                                if (this.handleSaveApply || this.handleSave || this.handleReset) {
                                        footer.appendChild(E('div', { 'class': 'cbi-page-actions' }, [
-                                               this.handleSaveApply ? E('button', {
-                                                       'class': 'cbi-button cbi-button-apply',
-                                                       'click': L.ui.createHandlerFn(this, 'handleSaveApply')
-                                               }, [ _('Save & Apply') ]) : '', ' ',
+                                               saveApplyBtn, ' ',
                                                this.handleSave ? E('button', {
                                                        'class': 'cbi-button cbi-button-save',
                                                        'click': L.ui.createHandlerFn(this, 'handleSave')