Mercurial > lada > lada-client
diff app/controller/grid/Status.js @ 994:092e245b13a4
draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Thu, 07 Jan 2016 16:19:41 +0100 |
parents | 77ea9a5c5f1d |
children | bf7bb9583a40 |
line wrap: on
line diff
--- a/app/controller/grid/Status.js Thu Jan 07 10:59:46 2016 +0100 +++ b/app/controller/grid/Status.js Thu Jan 07 16:19:41 2016 +0100 @@ -24,6 +24,9 @@ }, 'statusgrid button[action=add]': { click: this.add + }, + 'statusgrid button[action=reset]': { + click: this.reset } }); }, @@ -115,5 +118,54 @@ button.up('statusgrid').store.insert(lastrow, record); button.up('statusgrid').getPlugin('rowedit').startEdit(lastrow, 1); - } + }, + + /** + * Reset + * This Function instructs the server to reset the current status + * WIP / TODO + * + **/ + reset: function(button) { + var s = button.up('window').down('messungform').getRecord().get('status'); + var messId = button.up('window').down('messungform').getRecord().get('id'); + var recentStatus = button.up('statusgrid').store.getById(s); + + //Set Status to 'Resetted' (8) + var record = recentStatus.copy(); + record.set('datum', new Date()); + record.set('statusWert', 8); + record.set('id', null); + record.set('text', null); + + Ext.Ajax.request({ + url: 'lada-server/status', + jsonData: record.getData(), + method: 'POST', + success: function(response) { + button.up('window').initData(); + }, + failure: function(response) { + // TODO sophisticated error handling, with understandable Texts + var json = Ext.JSON.decode(response.responseText); + if (json) { + if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ + formPanel.setMessages(json.errors, json.warnings); + } + if(json.message){ + Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') + +' #'+json.message, + Lada.getApplication().bundle.getMsg(json.message)); + } else { + Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), + i18n.getMsg('err.msg.generic.body')); + } + } else { + Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), + i18n.getMsg('err.msg.generic.body')); + } + } + }); + + } });