Mercurial > lada > lada-client
changeset 1009:afb355cc7fb3
Merged with stammdatengrids branch.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 21 Jan 2016 08:58:35 +0100 |
parents | 9651def05ae6 (diff) 04ac7bb4494f (current diff) |
children | 94a6b5415d73 |
files | |
diffstat | 12 files changed, 260 insertions(+), 74 deletions(-) [+] |
line wrap: on
line diff
--- a/Dockerfile Wed Jan 20 17:38:10 2016 +0100 +++ b/Dockerfile Thu Jan 21 08:58:35 2016 +0100 @@ -3,7 +3,7 @@ # # Build with e.g. `docker build --force-rm=true -t koala/lada_client .' # Run from the repository root-dir with e.g. -# `docker run --name lada_client -v $PWD:/usr/local/apache2/htdocs/ +# `docker run --name lada_client # --link lada_wildfly:lada-server -p 8182:80 -d koala/lada_client' # # The linked container may be created from the Dockerfile in the lada-server @@ -11,6 +11,9 @@ # # The LADA-application will be available under http://yourdockerhost:8182 # +# Add `-v $PWD:/usr/local/apache2/htdocs/' to the run-command if you want to +# test your local changes (you'll have to run ./install-dependencies.sh again). +# FROM httpd:2.4 MAINTAINER tom.gottfried@intevation.de
--- a/app/controller/Filter.js Wed Jan 20 17:38:10 2016 +0100 +++ b/app/controller/Filter.js Thu Jan 21 08:58:35 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 Wed Jan 20 17:38:10 2016 +0100 +++ b/app/controller/grid/Status.js Thu Jan 21 08:58:35 2016 +0100 @@ -21,10 +21,12 @@ 'statusgrid': { edit: this.gridSave, canceledit: this.cancelEdit, - select: this.toggleAllowedPermissions }, 'statusgrid button[action=add]': { click: this.add + }, + 'statusgrid button[action=reset]': { + click: this.reset } }); }, @@ -51,19 +53,20 @@ } }, failure: function(request, response) { + var i18n = Lada.getApplication().bundle; var json = response.request.scope.reader.jsonData; if (json) { if (json.message){ - Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title') + Ext.Msg.alert(i18n.getMsg('err.msg.save.title') +' #'+json.message, - Lada.getApplication().bundle.getMsg(json.message)); + i18n.getMsg(json.message)); } else { - Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), - Lada.getApplication().bundle.getMsg('err.msg.generic.body')); + Ext.Msg.alert(i18n.getMsg('err.msg.save.title'), + i18n.getMsg('err.msg.generic.body')); } } else { - Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), - Lada.getApplication().bundle.getMsg('err.msg.response.body')); + Ext.Msg.alert(i18n.getMsg('err.msg.save.title'), + i18n.getMsg('err.msg.response.body')); } } }); @@ -82,39 +85,112 @@ /** * This function adds a new row to add a Status + * and copies the data of the previous status into the new one + * if possible. */ add: function(button) { - var record = Ext.create('Lada.model.Status', { - messungsId: button.up('statusgrid').recordId - }); + var lastrow = button.up('statusgrid').store.count() + + // retrive current status from the messung. + var s = button.up('window').down('messungform').getRecord().get('status'); + var recentStatus = button.up('statusgrid').store.getById(s); + + button.up('statusgrid').statusWerteStore.reload(); + + //If possible copy the previous record into the new one. + //this assumes the store is ordered correctly, most recent status last. + // Do not copy, if current userid differs from the id of the current status + if (lastrow > 0 && + Ext.Array.contains(Lada.mst, recentStatus.get('erzeuger'))) { + + if (recentStatus) { + // clone the status + var record = recentStatus.copy() + } + + record.set('id', null); + } else { + //create a new one + var record = Ext.create('Lada.model.Status', { + messungsId: button.up('statusgrid').recordId + }); + } + //Set the Date - record.data.datum = new Date(); - var lastrow = button.up('statusgrid').store.count() + record.set('datum', new Date()); + button.up('statusgrid').store.insert(lastrow, record); - button.up('statusgrid').rowEditing.startEdit(lastrow, 1); + button.up('statusgrid').getPlugin('rowedit').startEdit(lastrow, 1); }, - /** - * When a row in a grid is selected, - * this function checks if the row may be edited, - * or if the row can be removed - */ - toggleAllowedPermissions: function(context, record, index){ - - //retrieve the readOnly parameters - var statusEdit = context.view.up('window').record.get('statusEdit'); + * Reset + * This Function instructs the server to reset the current status + * WIP / TODO + * + **/ + reset: function(button) { + var me = this; + var rstbutton = button; + var i18n = Lada.getApplication().bundle; + Ext.MessageBox.confirm( + i18n.getMsg('statusgrid.reset.mbox.title'), + i18n.getMsg('statusgrid.reset.mbox.text'), + function(btn) { + if (btn === 'yes') { + me.doReset(rstbutton); + } + }); + }, - var grid = context.view.up('grid'); - - //retrieve the last record of the store - var lastRecord = context.getStore().last(); + doReset: function(button) { + var i18n = Lada.getApplication().bundle; - //Check if edit is allowed - if (lastRecord != record || - statusEdit === false) { - grid.getPlugin('rowedit').cancelEdit(); + var resetStatusValue = 8; + + 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) + if (recentStatus) { + var record = recentStatus.copy(); + record.set('datum', new Date()); + record.set('statusWert', resetStatusValue); + record.set('id', null); + record.set('text', i18n.getMsg('statusgrid.resetText')); } - } + + Ext.Ajax.request({ + url: 'lada-server/rest/status', + jsonData: record.getData(), + method: 'POST', + success: function(response) { + button.up('window').initData(); + button.up('grid').initData(); + }, + failure: function(response) { + // TODO sophisticated error handling, with understandable Texts + var i18n = Lada.getApplication().bundle; + 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(i18n.getMsg('err.msg.generic.title') + +' #'+json.message, + i18n.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/model/Messung.js Wed Jan 20 17:38:10 2016 +0100 +++ b/app/model/Messung.js Thu Jan 21 08:58:35 2016 +0100 @@ -1,4 +1,4 @@ -* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz +/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz * Software engineering by Intevation GmbH * * This file is Free Software under the GNU GPL (v>=3)
--- a/app/model/Messwert.js Wed Jan 20 17:38:10 2016 +0100 +++ b/app/model/Messwert.js Thu Jan 21 08:58:35 2016 +0100 @@ -29,7 +29,14 @@ name: 'messwert', type: 'float' }, { - name: 'messwertNwg' + name: 'messwertNwg', + convert: function(v) { + if (!v) { + return null; + } + return "<"; + }, +// defaultValue: null }, { name: 'messfehler', type: 'float'
--- a/app/model/Status.js Wed Jan 20 17:38:10 2016 +0100 +++ b/app/model/Status.js Thu Jan 21 08:58:35 2016 +0100 @@ -27,8 +27,7 @@ name: 'erzeuger' }, { name: 'statusStufe', - type: 'int', - defaultValue: 1 + type: 'int' }, { name: 'statusWert', type: 'int',
--- a/app/view/form/Messung.js Wed Jan 20 17:38:10 2016 +0100 +++ b/app/view/form/Messung.js Thu Jan 21 08:58:35 2016 +0100 @@ -170,6 +170,7 @@ var i18n = Lada.getApplication().bundle; var msg = i18n.getMsg('load.statuswert'); var textfield = this.down('[name=status]'); + var messwin = this.up('window'); if(textfield) { textfield.setRawValue(msg); @@ -192,6 +193,17 @@ } this.setStatusWert(sw); this.setStatusStufe(ss); + + // Enable / Disable the statusreset button of the statusgrid of the messungform + if (messwin.record.get('statusEdit') === true && + sw != 0 && + sw != 4) { + messwin.enableStatusReset(); + } + else { + messwin.disableStatusReset(); + } + }, scope: this }); @@ -325,9 +337,6 @@ this.down('messmethode[name=mmtId]').setReadOnly(value); this.down('datetime[name=messzeitpunkt]').setReadOnly(value); this.down('numberfield[name=messdauer]').setReadOnly(value); - if (!this.getForm().getRecord().get('owner')) { - //Only set this Field to Readonly when the User is NOT the Owner of the Record. - this.down('chkbox[name=fertig]').setReadOnly(value); - } + this.down('chkbox[name=fertig]').setReadOnly(value); } });
--- a/app/view/grid/Messwert.js Wed Jan 20 17:38:10 2016 +0100 +++ b/app/view/grid/Messwert.js Thu Jan 21 08:58:35 2016 +0100 @@ -95,16 +95,30 @@ triggerAction: 'all' } }, { + header: '<NWG', + width: 60, + dataIndex: 'messwertNwg', + editor: { + xtype: 'checkbox', + inputValue: '<' + } + }, { header: 'Messwert', dataIndex: 'messwert', xtype: 'numbercolumn', width: 80, + renderer: function(value) { + return value.toExponential(2); + }, editor: { xtype: 'numberfield', allowBlank: false, maxLength: 10, - allowExponential: false, - enforceMaxLength: true + allowExponential: true, + enforceMaxLength: true, + hideTrigger: true, + keyNavEnabled: false, + mouseWheelEnabled: false } }, { header: 'Messeinheit', @@ -132,16 +146,6 @@ triggerAction: 'all' } }, { - header: '<NWG', - xtype: 'numbercolumn', - width: 60, - dataIndex: 'messwertNwg' - }, { - header: 'Nachweisgrenze', - xtype: 'numbercolumn', - width: 110, - dataIndex: 'nwgZuMesswert' - }, { header: 'Messfehler', dataIndex: 'messfehler', xtype: 'numbercolumn', @@ -154,6 +158,28 @@ enforceMaxLength: true } }, { + header: 'Nachweisgrenze', + xtype: 'numbercolumn', + dataIndex: 'nwgZuMesswert', + width: 80, + renderer: function(value) { + if (!value) { + return null; + } else { + return value.toExponential(2); + } + }, + editor: { + xtype: 'numberfield', + allowBlank: true, + maxLength: 10, + allowExponential: true, + enforceMaxLength: true, + hideTrigger: true, + keyNavEnabled: false, + mouseWheelEnabled: false + } + }, { header: 'Grenzwertüberschreitung', dataIndex: 'grenzwertueberschreitung', flex: 1,
--- a/app/view/grid/Status.js Wed Jan 20 17:38:10 2016 +0100 +++ b/app/view/grid/Status.js Thu Jan 21 08:58:35 2016 +0100 @@ -14,7 +14,6 @@ alias: 'widget.statusgrid', maxHeight: 350, - emptyText: 'Keine Statusangaben gefunden.', minHeight: 110, viewConfig: { deferEmptyText: false @@ -23,10 +22,14 @@ recordId: null, readOnly: true, allowDeselect: true, + statusWerteStore: null, initComponent: function() { - var statusWerteStore = Ext.create('Lada.store.StatusWerte'); - statusWerteStore.load({ + var i18n = Lada.getApplication().bundle; + this.emptyText = i18n.getMsg('statusgrid.emptyText'); + + this.statusWerteStore = Ext.create('Lada.store.StatusWerte'); + this.statusWerteStore.load({ params: { messungsId: this.recordId } @@ -37,8 +40,22 @@ this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { clicksToMoveEditor: 1, autoCancel: false, - disabled: true, - pluginId: 'rowedit' + disabled: true, //has no effect... but why? + pluginId: 'rowedit', + listeners: { + beforeedit: function(editor, context, eOpts) { + if (context.record.get('id') || + ! context.grid.up('window').record.get('statusEdit')) { + //Check if edit is allowed, this is true, when the selected + // Record has an id (=is not new) + // or is not allowed to add records. + + return false; + } + + + } + } }); this.plugins = [this.rowEditing]; @@ -46,7 +63,13 @@ xtype: 'toolbar', dock: 'bottom', items: ['->', { - text: 'Hinzufügen', + text: i18n.getMsg('reset'), + icon: 'resources/img/edit-redo.png', + action: 'reset', + probeId: this.probeId, + parentId: this.parentId + }, { + text: i18n.getMsg('add'), icon: 'resources/img/list-add.png', action: 'add', probeId: this.probeId, @@ -54,19 +77,19 @@ }] }]; this.columns = [{ - header: 'erstellt', + header: i18n.getMsg('statusgrid.header.datum'), dataIndex: 'datum', xtype: 'datecolumn', format: 'd.m.Y H:i', width: 110, sortable: false }, { - header: 'Erzeuger', + header: i18n.getMsg('statusgrid.header.erzeuger'), dataIndex: 'erzeuger', renderer: function(value) { var r = ''; if (!value || value === '') { - r = 'Error'; + r = i18n.getMsg('error'); } var mstore = Ext.data.StoreManager.get('messstellen'); var item = mstore.getById(value); @@ -85,13 +108,13 @@ }, sortable: false }, { - header: 'Stufe', + header: i18n.getMsg('statusgrid.header.statusStufe'), dataIndex: 'statusStufe', renderer: function(value) { var sta = Ext.data.StoreManager.get('statusstufe'); var r; if (value===null || value === '') { - r = 'Error'; + r = i18n.getMsg('error'); } var item = sta.getById(value); if (item) { @@ -101,14 +124,14 @@ }, sortable: false }, { - header: 'Status', + header: i18n.getMsg('statusgrid.header.statusWert'), dataIndex: 'statusWert', renderer: function(value) { var sta = Ext.data.StoreManager.get('statuswerte'); //This store is NOT used in the editor... var r; if (value===null || value === '') { - r = 'Error'; + r = i18n.getMsg('error'); } var item = sta.getById(value); if (item) { @@ -118,7 +141,7 @@ }, editor: { xtype: 'combobox', - store: statusWerteStore, + store: this.statusWerteStore, queryMode: 'local', displayField: 'wert', valueField: 'id', @@ -127,7 +150,7 @@ }, sortable: false }, { - header: 'Text', + header: i18n.getMsg('statusgrid.header.text'), dataIndex: 'text', flex: 1, editor: { @@ -147,11 +170,16 @@ this.store.removeAll(); } else { - this.store = Ext.create('Lada.store.Status'); + this.store = Ext.create('Lada.store.Status',{ + sorters: [{ + property: 'datum', + direction: 'ASC' + }] + }); } this.store.load({ params: { - messungsId: this.recordId + messungsId: this.recordId, } }); }, @@ -164,5 +192,13 @@ //Writable this.down('button[action=add]').enable(); } + }, + + setResetable: function(b) { + if (b == true){ + this.down('button[action=reset]').enable(); + }else{ + this.down('button[action=reset]').disable(); + } } });
--- a/app/view/window/MessungEdit.js Wed Jan 20 17:38:10 2016 +0100 +++ b/app/view/window/MessungEdit.js Thu Jan 21 08:58:35 2016 +0100 @@ -178,6 +178,7 @@ else { this.disableStatusEdit(); } + //Check if it is allowed to reset Status: done in Messungform }, scope: this }); @@ -210,6 +211,7 @@ this.down('fset[name=messungskommentare]').down('mkommentargrid').setReadOnly(true); this.down('fset[name=messungskommentare]').down('mkommentargrid').readOnly = true; this.disableStatusEdit(); + this.disableStatusReset(); }, /** @@ -221,12 +223,26 @@ this.down('fset[name=messungskommentare]').down('mkommentargrid').setReadOnly(false); this.down('fset[name=messungskommentare]').down('mkommentargrid').readOnly = false; this.enableStatusEdit(); + this.enableStatusReset(); }, /** + * Enable to reset the statusgrid + */ + enableStatusReset: function() { + this.down('fset[name=messungstatus]').down('statusgrid').setResetable(true); + }, + + /** + * Disable to reset the statusgrid + */ + disableStatusReset: function() { + this.down('fset[name=messungstatus]').down('statusgrid').setResetable(false); + }, + /** * Enable to edit the statusgrid */ - enableStatusEdit: function () { + enableStatusEdit: function() { this.down('fset[name=messungstatus]').down('statusgrid').setReadOnly(false); this.down('fset[name=messungstatus]').down('statusgrid').readOnly = false; }, @@ -234,7 +250,7 @@ /** * Disable to edit the statusgrid */ - disableStatusEdit: function () { + disableStatusEdit: function() { this.down('fset[name=messungstatus]').down('statusgrid').setReadOnly(true); this.down('fset[name=messungstatus]').down('statusgrid').readOnly = true; },
--- a/resources/i18n/Lada_de-DE.properties Wed Jan 20 17:38:10 2016 +0100 +++ b/resources/i18n/Lada_de-DE.properties Thu Jan 21 08:58:35 2016 +0100 @@ -143,6 +143,9 @@ action:Aktion remove:Entfernen +reset:Zurücksetzen +error: Fehler + delete.probe.window.title:Probe und ihre Messungen Löschen? delete.probe:Wollen Sie die Probe und alle damit verbundenen Messungen wirklich LÖSCHEN? delete.probe.warning:ACHTUNG: Diese Aktion kann nicht rückgängig gemacht werden. @@ -151,6 +154,17 @@ confirmation.question: Sind Sie sich sicher? +## Statusgrid +statusgrid.emptyText: Keine Statusangaben gefunden. +statusgrid.header.datum: Erstellt +statusgrid.header.erzeuger: Erzeuger +statusgrid.header.statusStufe: Stufe +statusgrid.header.statusWert: Status +statusgrid.header.text: Text +statusgrid.resetText: Der Status wurde zurückgesetzt +statusgrid.reset.mbox.title: Status der Messung zurücksetzen. +statusgrid.reset.mbox.text: Sind Sie sich sicher, dass Sie den Status zurücksetzen wollen? + ## # Msg: ##