X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Pman.Delete.js;h=cdb4448cb1a20574d51f2ef643755c6a411433ec;hb=3c32040ca8b807469e6bd499ab5a85a2681f455c;hp=a5d2c1c7ba95bf73a227c1777040a7360e897ef7;hpb=b78ad6a6013734f8bd0b392e90b89fa89a5ee4ec;p=Pman.Core diff --git a/Pman.Delete.js b/Pman.Delete.js index a5d2c1c7..cdb4448c 100644 --- a/Pman.Delete.js +++ b/Pman.Delete.js @@ -41,39 +41,27 @@ Pman.Delete = { if (btn != 'yes') { return; } - Pman.Delete.simpleCall(r); + tab.grid.getView().mainWrap.mask("Deleting"); + Pman.Delete.simpleCall(tab, tbl, r, function(response) { + Pman.Delete.completed(tab); + }); } ); }, - simpleCall : function(r) + simpleCall : function(tab, tbl, r, resp) { // what about the toolbar?? - tab.grid.getView().mainWrap.mask("Deleting"); + new Pman.Request({ - url: baseURL + '/Roo/'+tbl+'.php', + url: baseURL + '/Roo/'+tbl, method: 'POST', params: { _delete : r.join(',') }, - success: function(response) { - tab.grid.getView().mainWrap.unmask(); - if ( tab.paging ) { - tab.paging.onClick('refresh'); - } else if (tab.grid.footer && tab.grid.footer.onClick) { - // new xtype built grids - tab.grid.footer.onClick('refresh'); - } else if (tab.refresh) { - tab.refresh(); // this might cause problems as panels have a refresh method? - } else { - tab.grid.getDataSource().load(); - } - - - - }, + success: resp, failure: function(act) { Roo.log(act); @@ -88,70 +76,61 @@ Pman.Delete = { } }); - } + }, progress : function(tab, tbl) { - var r = []; - - - var s = tab.grid.getSelectionModel().getSelections(); - if (!s.length) { - Roo.MessageBox.alert("Error", "Select at least one Row to delete" ); - return ''; - } - var reader = tab.grid.reader || tab.grid.ds.reader; - for(var i = 0; i < s.length; i++) { - r.push(reader.getId(s[i].json)); + var r = this.selections(tab); + if (!r.length) { + return; } - + + Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that?", function(btn) { if (btn != 'yes') { return; } - // what about the toolbar?? - tab.grid.getView().mainWrap.mask("Deleting"); - new Pman.Request({ - url: baseURL + '/Roo/'+tbl+'.php', - method: 'POST', - params: { - _delete : r.join(',') - }, - success: function(response) { - tab.grid.getView().mainWrap.unmask(); - if ( tab.paging ) { - tab.paging.onClick('refresh'); - } else if (tab.grid.footer && tab.grid.footer.onClick) { - // new xtype built grids - tab.grid.footer.onClick('refresh'); - } else if (tab.refresh) { - tab.refresh(); // this might cause problems as panels have a refresh method? - } else { - tab.grid.getDataSource().load(); - } - - - - }, - failure: function(act) { + Roo.MessageBox.progress("Delete Records", "Deleting 1/" + r.length ); + + + var p = 0; + + var delItem = function () + { + Roo.MessageBox.updateProgress( (p+1)/r.length, "Deleting " + (1+p) + "/" + r.length ); + Pman.Delete.simpleCall(tab, tbl, [ r[p] ], function(response) { - Roo.log(act); - var msg = ''; - try { - msg = act.errorMsg; - } catch(e) { - msg = "Error deleting"; + p++; + if (p == r.length) { + Roo.MessageBox.hide(); + Pman.Delete.completed(tab); + return; } - tab.grid.getView().mainWrap.unmask(); - Roo.MessageBox.alert("Error", msg); - } - - }); + + delItem(); + }); + } + delItem(); + + } ); - return ''; }, + completed : function() + { + tab.grid.getView().mainWrap.unmask(); + if ( tab.paging ) { + tab.paging.onClick('refresh'); + } else if (tab.grid.footer && tab.grid.footer.onClick) { + // new xtype built grids + tab.grid.footer.onClick('refresh'); + } else if (tab.refresh) { + tab.refresh(); // this might cause problems as panels have a refresh method? + } else { + tab.grid.getDataSource().load(); + } + } } \ No newline at end of file