]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
WEBUI JS: Add delete/abort confirm dialogs, improve idnode_form_grid
authorJaroslav Kysela <perex@perex.cz>
Mon, 8 Sep 2014 14:30:44 +0000 (16:30 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 8 Sep 2014 14:49:00 +0000 (16:49 +0200)
src/webui/static/app/dvr.js
src/webui/static/app/idnode.js
src/webui/static/app/tvheadend.js

index 6071c7aa38c19e6f6dab5e472a37e1d68eeb3f80..a76b474563c3bbb5ef7be55e1f61c1d88af1bf35 100644 (file)
@@ -102,14 +102,15 @@ tvheadend.dvr_upcoming = function(panel, index) {
                 var uuids = [];
                 for (var i = 0; i < r.length; i++)
                     uuids.push(r[i].id);
-                tvheadend.Ajax({
+                tvheadend.AjaxConfirm({
                     url: 'api/dvr/entry/cancel',
                     params: {
                         uuid: Ext.encode(uuids)
                     },
                     success: function(d) {
                         store.reload();
-                    }
+                    },
+                    question: 'Do you really want to abort/unschedule the selection?'
                 });
             }
         }
index b636d919b2c354ac8272968d23441ef7e0473c0c..d41f43080a79a2a1211738dbe025675e2750b84a 100644 (file)
@@ -992,7 +992,7 @@ tvheadend.idnode_grid = function(panel, conf)
                         var uuids = [];
                         for (var i = 0; i < r.length; i++)
                             uuids.push(r[i].id);
-                        tvheadend.Ajax({
+                        tvheadend.AjaxConfirm({
                             url: 'api/idnode/delete',
                             params: {
                                 uuid: Ext.encode(uuids)
@@ -1342,6 +1342,7 @@ tvheadend.idnode_form_grid = function(panel, conf)
         var abuttons = {};
         var plugins = conf.plugins || [];
         var current = null;
+        var selectuuid = null;
 
         /* Store */
         store = new Ext.data.JsonStore({
@@ -1363,9 +1364,18 @@ tvheadend.idnode_form_grid = function(panel, conf)
             }
         });
 
-        store.on('load', function(st) {
-            if (!current)
-                grid.getSelectionModel().selectFirstRow();
+        store.on('load', function(records) {
+            var s = false;
+            if (selectuuid) {
+                records.each(function(r) {
+                    if (r.id === selectuuid) {
+                        select.selectRecords([r]);
+                        s = true;
+                    }
+                });
+                selectuuid = null;
+            } else if (!current && !select.getSelected())
+                select.selectFirstRow();
         });
 
         /* Model */
@@ -1407,7 +1417,9 @@ tvheadend.idnode_form_grid = function(panel, conf)
                         node: Ext.encode(node)
                     },
                     success: function() {
-                        store.reload()
+                        selectuuid = current.uuid;
+                        roweditor_destroy();
+                        store.reload();
                     }
                 });
             }
@@ -1445,15 +1457,14 @@ tvheadend.idnode_form_grid = function(panel, conf)
                 disabled: true,
                 handler: function() {
                     if (current) {
-                        tvheadend.Ajax({
+                        tvheadend.AjaxConfirm({
                             url: 'api/idnode/delete',
                             params: {
                                 uuid: current.uuid
                             },
-                            success: function(d)
-                            {
+                            success: function(d) {
+                                roweditor_destroy();
                                 store.reload();
-                                grid.getSelectionModel().selectFirstRow();
                             }
                         });
                     }
@@ -1493,9 +1504,17 @@ tvheadend.idnode_form_grid = function(panel, conf)
             });
         }
 
+        function roweditor_destroy() {
+            if (current)
+                mpanel.remove(current.editor);
+            current = null;
+        }
+
         function roweditor(r) {
             if (!r || !r.id)
                 return;
+            if (current && current.uuid == r.id)
+                return;
             tvheadend.Ajax({
                 url: 'api/idnode/load',
                 params: {
@@ -1504,8 +1523,7 @@ tvheadend.idnode_form_grid = function(panel, conf)
                 },
                 success: function(d) {
                     d = json_decode(d);
-                    if (current)
-                        mpanel.remove(current.editor);
+                    roweditor_destroy();
                     var editor = new tvheadend.idnode_editor(d[0], {
                                     title: 'Parameters',
                                     labelWidth: 300,
@@ -1547,7 +1565,7 @@ tvheadend.idnode_form_grid = function(panel, conf)
                 render : {
                     fn :  function() {
                         if (!current)
-                            grid.getSelectionModel().selectFirstRow();
+                            select.selectFirstRow();
                     }
                 }
             }
index 4a3c2ea8ac25575484a0dba5dc8628d1103012f9..87b2b6c0fe8c8fcccc222d06d08983b3c8df6f0b 100644 (file)
@@ -72,6 +72,17 @@ tvheadend.Ajax = function(conf) {
     Ext.Ajax.request(conf);
 };
 
+tvheadend.AjaxConfirm = function(conf) {
+    Ext.MessageBox.confirm(
+        conf.title || 'Message',
+        conf.question || 'Do you really want to delete the selection?',
+        function (btn) {
+            if (btn == 'yes')
+                tvheadend.Ajax(conf);
+        }
+    );
+};
+
 tvheadend.loading = function(on) {
     if (on)
       Ext.getBody().mask('Loading... Please, wait...', 'loading');