changeset 995:fb424948de02

Merged heads
author Dustin Demuth <dustin@intevation.de>
date Thu, 07 Jan 2016 16:20:48 +0100
parents 092e245b13a4 (diff) f9449df5f9fb (current diff)
children bf7bb9583a40
files
diffstat 4 files changed, 64 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/Filter.js	Thu Jan 07 13:58:35 2016 +0100
+++ b/app/controller/Filter.js	Thu Jan 07 16:20:48 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 13:58:35 2016 +0100
+++ b/app/controller/grid/Status.js	Thu Jan 07 16:20:48 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 13:58:35 2016 +0100
+++ b/app/view/grid/Status.js	Thu Jan 07 16:20:48 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