Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WEBUI JS: Add delete/abort confirm dialogs, improve idnode_form_grid
  • Loading branch information
perexg committed Sep 8, 2014
1 parent 4a60cb8 commit ac09d42
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/webui/static/app/dvr.js
Expand Up @@ -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?'
});
}
}
Expand Down
42 changes: 30 additions & 12 deletions src/webui/static/app/idnode.js
Expand Up @@ -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)
Expand Down Expand Up @@ -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({
Expand All @@ -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 */
Expand Down Expand Up @@ -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();
}
});
}
Expand Down Expand Up @@ -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();
}
});
}
Expand Down Expand Up @@ -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: {
Expand All @@ -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,
Expand Down Expand Up @@ -1547,7 +1565,7 @@ tvheadend.idnode_form_grid = function(panel, conf)
render : {
fn : function() {
if (!current)
grid.getSelectionModel().selectFirstRow();
select.selectFirstRow();
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/webui/static/app/tvheadend.js
Expand Up @@ -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');
Expand Down

0 comments on commit ac09d42

Please sign in to comment.