[Lada-commits] [PATCH] Open status edit window and send status objects

Wald Commits scm-commit at wald.intevation.org
Wed Apr 13 19:04:19 CEST 2016


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1460567055 -7200
# Node ID dbd435256f77bf583106d1b686f6ae09dcc12d47
# Parent  5e9a674d7bb465b034cd61dc266d1264b67049a9
Open status edit window and send status objects.

diff -r 5e9a674d7bb4 -r dbd435256f77 app/controller/grid/MessungList.js
--- a/app/controller/grid/MessungList.js	Wed Apr 13 18:41:47 2016 +0200
+++ b/app/controller/grid/MessungList.js	Wed Apr 13 19:04:15 2016 +0200
@@ -24,12 +24,37 @@
                 itemdblclick: this.editItem,
                 select: this.activateButtons,
                 deselect: this.deactivateButtons
+            },
+            'messunglistgrid toolbar button[action=setstatus]': {
+                click: this.setStatus
             }
         });
         this.callParent(arguments);
     },
 
     /**
+     * Sets the Status on Bulk
+     **/
+    setStatus: function(button) {
+        //disable Button and setLoading...
+
+        var grid = button.up('grid');
+        var selection = grid.getView().getSelectionModel().getSelection();
+        var i18n = Lada.getApplication().bundle;
+
+        var win = Ext.create('Lada.view.window.SetStatus', {
+            title: i18n.getMsg('statusSetzen.win.title'),
+            grid: grid,
+            modal: true,
+            selection: selection
+        });
+
+        win.show();
+
+    },
+
+
+    /**
      * This function is called after a Row in the
      * {@link Lada.view.grid.ProbeList}
      * was double-clicked.
@@ -257,13 +282,13 @@
     buttonToggle: function(enabled, grid) {
         if (!enabled) {
             grid.down('button[action=print]').disable();
-            grid.down('button[action=setStatus]').disable();
+            grid.down('button[action=setstatus]').disable();
         }
         else {
             grid.down('button[action=print]').enable();
             // TODO: enable button only on messungen with owner == true and
             // readonly == false
-            grid.down('button[action=setStatus]').enable();
+            grid.down('button[action=setstatus]').enable();
         }
     },
 
diff -r 5e9a674d7bb4 -r dbd435256f77 app/controller/grid/ProbeList.js
--- a/app/controller/grid/ProbeList.js	Wed Apr 13 18:41:47 2016 +0200
+++ b/app/controller/grid/ProbeList.js	Wed Apr 13 19:04:15 2016 +0200
@@ -167,7 +167,7 @@
         try {
             for (key in selection[0].data) {
                 // Do not write owner or readonly or id
-                if (["owner", "readonly", "id"].indexOf(key) == -1){
+                if (["owner", "readonly", "id", "probeId"].indexOf(key) == -1){
                     columns.push(key);
                 }
             }
diff -r 5e9a674d7bb4 -r dbd435256f77 app/view/grid/MessungList.js
--- a/app/view/grid/MessungList.js	Wed Apr 13 18:41:47 2016 +0200
+++ b/app/view/grid/MessungList.js	Wed Apr 13 19:04:15 2016 +0200
@@ -36,7 +36,7 @@
             }, {
                 text: i18n.getMsg('statusSetzen'),
                 icon: 'resources/img/emblem-important.png',
-                action: 'setStatus',
+                action: 'setstatus',
                 disabled: true //disabled on start, enabled by the controller
             }]
         }];
diff -r 5e9a674d7bb4 -r dbd435256f77 app/view/widget/DynamicGrid.js
--- a/app/view/widget/DynamicGrid.js	Wed Apr 13 18:41:47 2016 +0200
+++ b/app/view/widget/DynamicGrid.js	Wed Apr 13 19:04:15 2016 +0200
@@ -80,6 +80,9 @@
         fields.push(new Ext.data.Field({
             name: 'readonly'
         }));
+        fields.push(new Ext.data.Field({
+            name: 'statusEdit'
+        }));
 
         resultColumns.push({
             xtype: 'actioncolumn',
@@ -89,12 +92,22 @@
             tooltip: 'Probe öffnen',
             width: 30,
             getClass: function (val, meta, rec) {
-                if ( rec.get('readonly') === false && rec.get('owner') === true) {
+                if (rec.get('readonly') === false &&
+                    rec.get('owner') === true &&
+                    !rec.get('statusEdit')) {
+                    console.log('edit' + rec.get('statusEdit'));
                         return 'edit';
                 }
-                else {
-                        return 'noedit';
+                else if (rec.get('readonly') === false &&
+                    rec.get('owner') === true &&
+                    rec.get('statusEdit')) {
+                        return 'editstatus';
                 }
+                else if (rec.get('readonly') === true &&
+                    rec.get('statusEdit')) {
+                        return 'noeditstatus';
+                }
+                return 'noedit';
             },
             handler: function(grid, rowIndex, colIndex) {
                 var rec = grid.getStore().getAt(rowIndex);
diff -r 5e9a674d7bb4 -r dbd435256f77 app/view/window/SetStatus.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/window/SetStatus.js	Wed Apr 13 19:04:15 2016 +0200
@@ -0,0 +1,172 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * This is a simple Window to set the Status for multiple Messungen on bulk.
+ */
+Ext.define('Lada.view.window.SetStatus', {
+    extend: 'Ext.window.Window',
+    alias: 'setstatuswindow',
+
+    requires: [
+        'Lada.view.widget.Status'
+    ],
+
+    grid: null,
+    selection: null,
+
+    modal: true,
+    closable: false,
+    resultMessage: '',
+
+    /**
+     * This function initialises the Window
+     */
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+        var me = this;
+        this.items = [{
+            xtype: 'panel',
+            name: 'valueselection',
+            border: 0,
+            items: [{
+                xtype: 'fieldset',
+                title: 'Status für ' + this.selection.length + ' Messung(en) setzen',
+                margin: '5, 5, 10, 5',
+                items: [{
+                    xtype: 'combobox',
+                    store: Ext.data.StoreManager.get('messstellenFiltered'),
+                    displayField: 'messStelle',
+                    valueField: 'id',
+                    allowBlank: false,
+                    queryMode: 'local',
+                    editable: false,
+                    width: 300,
+                    labelWidth: 100,
+                    emptyText: 'Wählen Sie einen Erzeuger aus.',
+                    fieldLabel: i18n.getMsg('statusgrid.header.erzeuger')
+                }, {
+                    xtype: 'statuswert',
+                    allowBlank: false,
+                    width: 300,
+                    labelWidth: 100,
+                    fieldLabel: i18n.getMsg('statusgrid.header.statusWert')
+                }, {
+                    xtype: 'textarea',
+                    width: 300,
+                    height: 100,
+                    labelWidth: 100,
+                    fieldLabel: i18n.getMsg('statusgrid.header.text'),
+                    emptyText: 'Geben Sie einen Kommentar ein.'
+                }]
+            }]
+        }, {
+            xtype: 'panel',
+            hidden: true,
+            margin: '5, 5, 5, 5',
+            overflow: 'auto',
+            name: 'result'
+        }, {
+            xtype: 'progressbar',
+            margin: '5, 5, 5, 5',
+            hidden: true,
+            text: 'Verarbeite Statusänderungen'
+        }];
+        this.buttons = [{
+            text: i18n.getMsg('statusSetzen'),
+            name: 'start',
+            icon: 'resources/img/emblem-important.png',
+            handler: this.setStatus
+        }, {
+            text: i18n.getMsg('cancel'),
+            name: 'abort',
+            handler: this.closeWindow
+        }, {
+            text: i18n.getMsg('close'),
+            name: 'close',
+            hidden: true,
+            handler: this.closeWindow
+        }];
+
+        this.callParent(arguments);
+    },
+
+    /**
+     * @private
+     * A handler for a Abort-Button
+     */
+    closeWindow: function(button) {
+        var win = button.up('window');
+        win.close();
+    },
+
+    /**
+     * @private
+     * A handler to setStatus on Bulk.
+     */
+    setStatus: function(button) {
+        var win = button.up('window');
+        win.down('panel').disable();
+        win.down('button[name=start]').disable();
+        win.down('button[name=abort]').disable();
+        var progress = win.down('progressbar');
+        progress.show();
+        win.send();
+    },
+
+    send: function() {
+        var i18n = Lada.getApplication().bundle;
+        var me = this;
+        var progress = me.down('progressbar');
+        var progressText = progress.getText();
+        var count = 0;
+        for (var i = 0; i < this.selection.length; i++) {
+            var data = Ext.create('Lada.model.Status', {
+                messungsId: this.selection[i].get('id'),
+                erzeuger: this.down('combobox').getValue(),
+                datum: new Date(),
+                statusWert: this.down('statuswert').getValue(),
+                text: this.down('textarea').getValue()
+            });
+            Ext.Ajax.request({
+                url: 'lada-server/rest/status',
+                method: 'POST',
+                jsonData: data.raw,
+                success: function(response) {
+                    var json = Ext.JSON.decode(response.responseText);
+                    me.resultMessage += '<strong>' + i18n.getMsg('messung') + ': ';
+                    var sel = me.selection[count];
+                    me.resultMessage += sel.get('hauptprobenNr') + ' - ' + sel.get('nebenprobenNr') + '</strong><br><dd>';
+                    me.resultMessage += i18n.getMsg(json.message) + '</dd><br>';
+                    count++;
+                    progress.updateProgress(count / me.selection.length, progressText + ' (' + count + ')');
+                    if (count === me.selection.length) {
+                        var result = me.down('panel[name=result]');
+                        var values = me.down('panel[name=valueselection]');
+                        me.down('button[name=start]').hide();
+                        me.down('button[name=abort]').hide();
+                        me.down('button[name=close]').show();
+                        result.setSize(values.getWidth(), values.getHeight());
+                        result.getEl().setHTML(me.resultMessage);
+                        result.show();
+                        values.hide();
+                    }
+                },
+                failure: function(response) {
+                    console.log(response);
+                    count++;
+                    progress.updateProgress(count / me.selection.length);
+                    if (count === me.selection.length) {
+                        me.close();
+                    }
+                }
+            });
+        }
+    }
+});
+


More information about the Lada-commits mailing list