changeset 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 fb424948de02
files app/controller/Filter.js app/controller/grid/Status.js app/view/grid/Status.js resources/img/edit-redo.png
diffstat 4 files changed, 64 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/Filter.js	Thu Jan 07 10:59:46 2016 +0100
+++ b/app/controller/Filter.js	Thu Jan 07 16:19:41 2016 +0100
@@ -33,15 +33,15 @@
         this.control({
             // CSS like selector to select element in the viewport. See
             // ComponentQuery documentation for more details.
-            'combobox[name=filter]': {
+            'filterpanel combobox[name=filter]': {
                 // Map Select event
                 select: this.selectSql
             },
-            'button[action=search]': {
+            'filterpanel button[action=search]': {
                 // Map click event on Button.
                 click: this.search
             },
-            'button[action=reset]': {
+            'filterpanel button[action=reset]': {
                 // Map click event on Button.
                 click: this.reset
             },
--- 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'));
+                }
+            }
+        });
+
+     }
 });
--- a/app/view/grid/Status.js	Thu Jan 07 10:59:46 2016 +0100
+++ b/app/view/grid/Status.js	Thu Jan 07 16:19:41 2016 +0100
@@ -60,6 +60,12 @@
             xtype: 'toolbar',
             dock: 'bottom',
             items: ['->', {
+                text: 'Zurücksetzen',
+                icon: 'resources/img/edit-redo.png',
+                action: 'reset',
+                probeId: this.probeId,
+                parentId: this.parentId
+            }, {
                 text: 'Hinzufügen',
                 icon: 'resources/img/list-add.png',
                 action: 'add',
@@ -179,9 +185,11 @@
         if (b == true){
             //Readonly
             this.down('button[action=add]').disable();
+            this.down('button[action=reset]').disable();
         }else{
             //Writable
             this.down('button[action=add]').enable();
+            this.down('button[action=reset]').enable();
         }
     }
 });
Binary file resources/img/edit-redo.png has changed

http://lada.wald.intevation.org