[Lada-commits] [PATCH 1 of 2] draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'

Wald Commits scm-commit at wald.intevation.org
Thu Jan 7 16:20:57 CET 2016


# HG changeset patch
# User Dustin Demuth <dustin at intevation.de>
# Date 1452179981 -3600
# Node ID 092e245b13a487a7735ac6a12a878d903b1da7b2
# Parent  77ea9a5c5f1dafec53b7240a4a47842e03ae233a
draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'

diff -r 77ea9a5c5f1d -r 092e245b13a4 app/controller/Filter.js
--- 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
             },
diff -r 77ea9a5c5f1d -r 092e245b13a4 app/controller/grid/Status.js
--- 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'));
+                }
+            }
+        });
+
+     }
 });
diff -r 77ea9a5c5f1d -r 092e245b13a4 app/view/grid/Status.js
--- 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();
         }
     }
 });
diff -r 77ea9a5c5f1d -r 092e245b13a4 resources/img/edit-redo.png
Binary file resources/img/edit-redo.png has changed


More information about the Lada-commits mailing list