]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
WEBUI: Add 'Apply' button to create/edit dialogs, fixes #3184
authorJaroslav Kysela <perex@perex.cz>
Tue, 24 Nov 2015 11:43:38 +0000 (12:43 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 24 Nov 2015 11:43:38 +0000 (12:43 +0100)
src/webui/static/app/idnode.js

index 4259121af80c41b8d3d7e9b21800e19ec1304e97..47396c765490ce97a9651a9438c31fe39bdb861f 100644 (file)
@@ -943,13 +943,31 @@ tvheadend.idnode_editor = function(item, conf)
                     },
                     success: function(d) {
                         if (conf.win)
-                            conf.win.hide();
+                            conf.win.close();
                     }
                 });
             }
         });
         buttons.push(saveBtn);
 
+        var applyBtn = new Ext.Button({
+            text: _('Apply'),
+            iconCls: 'apply',
+            handler: function() {
+                var node = panel.getForm().getFieldValues();
+                node.uuid = conf.uuids ? conf.uuids : item.uuid;
+                tvheadend.Ajax({
+                    url: 'api/idnode/save',
+                    params: {
+                        node: Ext.encode(node)
+                    },
+                    success: function(d) {
+                    }
+                });
+            }
+        });
+        buttons.push(applyBtn);
+
         if (conf.help) {
             var helpBtn = new Ext.Button({
                 text: _('Help'),
@@ -1018,6 +1036,26 @@ tvheadend.idnode_create = function(conf, onlyDefault)
             });
         }
     });
+    var applyBtn = new Ext.Button({
+        tooltip: _('Apply settings'),
+        text: _('Apply'),
+        iconCls: 'apply',
+        hidden: true,
+        handler: function() {
+            var params = conf.create.params || {};
+            if (puuid)
+                params['uuid'] = puuid;
+            if (pclass)
+                params['class'] = pclass;
+            params['conf'] = Ext.encode(panel.getForm().getFieldValues());
+            tvheadend.Ajax({
+                url: conf.create.url || conf.url + '/create',
+                params: params,
+                success: function(d) {
+                }
+            });
+        }
+    });
     var cancelBtn = new Ext.Button({
         tooltip: _('Cancel operation'),
         text: _('Cancel'),
@@ -1040,7 +1078,7 @@ tvheadend.idnode_create = function(conf, onlyDefault)
         defaultType: 'textfield',
         buttonAlign: 'left',
         items: [],
-        buttons: [cancelBtn, saveBtn]
+        buttons: [cancelBtn, saveBtn, applyBtn]
     });
 
     /* Create window */
@@ -1080,6 +1118,7 @@ tvheadend.idnode_create = function(conf, onlyDefault)
                         panel.remove(s);
                         tvheadend.idnode_editor_form(d, null, panel, { create: true, showpwd: true });
                         saveBtn.setVisible(true);
+                        applyBtn.setVisible(true);
                         win.setOriginSize(true);
                     }
                 }
@@ -1096,6 +1135,7 @@ tvheadend.idnode_create = function(conf, onlyDefault)
                         d = json_decode(d);
                         tvheadend.idnode_editor_form(d.props, d, panel, { create: true, showpwd: true });
                         saveBtn.setVisible(true);
+                        applyBtn.setVisible(true);
                         win.setOriginSize(true);
                     }
                 });
@@ -1127,12 +1167,14 @@ tvheadend.idnode_create = function(conf, onlyDefault)
             success: function(d) {
                 d = json_decode(d);
                 tvheadend.idnode_editor_form(d.props, d, panel, { create: true, showpwd: true });
-                saveBtn.setVisible(true);
                 if (onlyDefault) {
                     saveBtn.handler();
                     panel.destroy();
-                } else
+                } else {
+                    saveBtn.setVisible(true);
+                    applyBtn.setVisible(true);
                     win.show();
+                }
             }
         });
     }