# HG changeset patch # User Dustin Demuth # Date 1447326811 -3600 # Node ID 6a6f2c6fe8ee185da17f8d2bfe8443a1b2725464 # Parent 9b6800458a9ed359aca72007d67bf2679d3e503b More work done on StatusWerte and Statusstufe. A Messung will also open when the owner attribute is true. Stauswerte and StatusStufen are loaded at application startup. Statusgrid and Messunggrid now use these stores, which were registered at the store manager. diff -r 9b6800458a9e -r 6a6f2c6fe8ee app.js --- a/app.js Thu Nov 12 09:50:48 2015 +0100 +++ b/app.js Thu Nov 12 12:13:31 2015 +0100 @@ -42,7 +42,9 @@ 'Lada.store.Probenzusaetze', 'Lada.store.Staaten', 'Lada.store.Umwelt', - 'Lada.store.Verwaltungseinheiten' + 'Lada.store.Verwaltungseinheiten', + 'Lada.store.StatusWerte', + 'Lada.store.StatusStufe' ], bundle: { bundle: 'Lada', @@ -154,6 +156,12 @@ Ext.create('Lada.store.Verwaltungseinheiten', { storeId: 'verwaltungseinheiten' }); + Ext.create('Lada.store.StatusWerte', { + storeId: 'statuswerte' + }); + Ext.create('Lada.store.StatusStufe', { + storeId: 'statusstufe' + }); }, getServerVersion: function() { diff -r 9b6800458a9e -r 6a6f2c6fe8ee app/controller/grid/Messung.js --- a/app/controller/grid/Messung.js Thu Nov 12 09:50:48 2015 +0100 +++ b/app/controller/grid/Messung.js Thu Nov 12 12:13:31 2015 +0100 @@ -43,12 +43,17 @@ /* Only open a new Window when: statusEdit = True -or- - the value of status is not 0 - the statusWert attribute is not present in the original data. - it is appended, when the value and name of the status were - determined. + the value of status is not 0 + -or- + the owner = True + + the statusWert attribute is not present in the original data. + it is appended, when the value and name of the status were + determined. */ - if (record.get('statusEdit') || record.get('statusWert') > 0) { + if (record.get('statusEdit') + || record.get('statusWert') > 0 + || record.get('owner')) { var win = Ext.create('Lada.view.window.MessungEdit', { parentWindow: grid.up('window'), probe: probe, diff -r 9b6800458a9e -r 6a6f2c6fe8ee app/store/StatusStufe.js --- a/app/store/StatusStufe.js Thu Nov 12 09:50:48 2015 +0100 +++ b/app/store/StatusStufe.js Thu Nov 12 12:13:31 2015 +0100 @@ -13,6 +13,5 @@ extend: 'Ext.data.Store', model: 'Lada.model.StatusStufe', autoLoad: true, - storeId: 'StatusStufe' }); diff -r 9b6800458a9e -r 6a6f2c6fe8ee app/store/StatusWerte.js --- a/app/store/StatusWerte.js Thu Nov 12 09:50:48 2015 +0100 +++ b/app/store/StatusWerte.js Thu Nov 12 12:13:31 2015 +0100 @@ -13,5 +13,4 @@ extend: 'Ext.data.Store', model: 'Lada.model.StatusWerte', autoLoad: true, - storeId: 'StatusWerte' }); diff -r 9b6800458a9e -r 6a6f2c6fe8ee app/view/form/Messung.js --- a/app/view/form/Messung.js Thu Nov 12 09:50:48 2015 +0100 +++ b/app/view/form/Messung.js Thu Nov 12 12:13:31 2015 +0100 @@ -201,48 +201,78 @@ * Updates the Messungform and fills the Statuswert */ setStatusWert: function(value){ - var swStore = Ext.create('Lada.store.StatusWerte'); - swStore.load({ - scope: this, - callback: function(records, operation, success) { - var i18n = Lada.getApplication().bundle; - var msg = i18n.getMsg('load.statuswert.error'); - var textfield = this.down('[name=status]'); - if (success) { - var item = swStore.getById(value); - if (item) { - msg = item.get('wert'); + var swStore = Ext.data.StoreManager.get('statuswerte'); + var i18n = Lada.getApplication().bundle; + var msg = i18n.getMsg('load.statuswert.error'); + var textfield = this.down('[name=status]'); + + if (!swStore) { + //Set the textfield asynchronously + swStore = Ext.create('Lada.store.StatusWerte'); + swStore.load({ + scope: this, + callback: function(records, operation, success) { + if (success) { + var item = swStore.getById(value); + if (item) { + msg = item.get('wert'); + } } - } - if (textfield) { - textfield.setRawValue(msg); - } - }, - }); + if (textfield) { + textfield.setRawValue(msg); + } + }, + }); + } + else { + //Set the textfield + var item = swStore.getById(value); + if (item) { + msg = item.get('wert'); + } + if (textfield) { + textfield.setRawValue(msg); + } + } + }, /** * Updates the Messungform and fills the StatusStufe */ setStatusStufe: function(value){ - var ssStore = Ext.create('Lada.store.StatusStufe'); - ssStore.load({ - scope: this, - callback: function(records, operation, success) { - var i18n = Lada.getApplication().bundle; - var msg = i18n.getMsg('load.statusstufe.error'); - var textfield = this.down('[name=stufe]'); - if (success) { - var item = ssStore.getById(value); - if (item) { - msg = item.get('stufe'); + var ssStore = Ext.data.StoreManager.get('statusstufe') + var i18n = Lada.getApplication().bundle; + var msg = i18n.getMsg('load.statusstufe.error'); + var textfield = this.down('[name=stufe]'); + if (!ssStore) { + //set the value asynchronously + Ext.create('Lada.store.StatusStufe'); + ssStore.load({ + scope: this, + callback: function(records, operation, success) { + if (success) { + var item = ssStore.getById(value); + if (item) { + msg = item.get('stufe'); + } } - } - if (textfield) { - textfield.setRawValue(msg); - } - }, - }); + if (textfield) { + textfield.setRawValue(msg); + } + }, + }); + } + else { + //Set the value. + var item = ssStore.getById(value); + if (item) { + msg = item.get('stufe'); + } + if (textfield) { + textfield.setRawValue(msg); + } + } }, setMessages: function(errors, warnings) { diff -r 9b6800458a9e -r 6a6f2c6fe8ee app/view/grid/Messung.js --- a/app/view/grid/Messung.js Thu Nov 12 09:50:48 2015 +0100 +++ b/app/view/grid/Messung.js Thu Nov 12 12:13:31 2015 +0100 @@ -85,7 +85,10 @@ renderer: function(value) { var statusId = this.store.getById(value).get('status'); var divId = 'messung-status-item' + value; - this.updateStatus(value, divId, statusId); + //also fwd the record to the asynchronous loading of statuswerte + // in order to add the statuswert to the record, + // after the grid was rendered... + this.updateStatus(value, divId, statusId, this.store.getById(value)); return '
Lade...
'; } }, { @@ -140,11 +143,16 @@ }, initData: function() { + this.setLoading(true); this.store = Ext.create('Lada.store.Messungen'); this.store.load({ params: { probeId: this.recordId - } + }, + callback: function (records, operation, success) { + this.setLoading(false); + }, + scope: this }); }, @@ -152,12 +160,12 @@ * Load the statusstore, * afterwards: retrieve the statusid */ - updateStatus: function(value, divId, statusId) { + updateStatus: function(value, divId, statusId, record) { var statusStore = Ext.create('Lada.store.Status'); statusStore.on('load', this.updateStatusColumn, this, - {divId: divId, statusId: statusId}); + {divId: divId, statusId: statusId, record: record}); statusStore.load({ params: { messungsId: value @@ -211,23 +219,44 @@ value = 0; } else { - value = sstore.getById(opts.statusId).get('statusWert'); + var rec = sstore.getById(opts.statusId); + if (rec) { + value = rec.get('statusWert'); + //add the determined statuswert to the record. + // this is necessary to let the controller determine + // which actions are allowed. + opts.record.data.statusWert = value; + } } if (Ext.fly(opts.divId)) { - var sta = Ext.StoreManager.lookup('StatusWerte'); - if (!sta) { - var sta = Ext.create('Lada.store.StatusWerte'); - } + //Try to get the statuswerte store, + // If it does not exist, create a new one. + var sta = Ext.data.StoreManager.getByKey('statuswerte'); var val = 'error'; - sta.load({ - scope: this, - callback: function(records, operation, success) { - if (success) { - val = sta.getById(value).get('wert'); + if (!sta) { + // Set the Data asynchronously + sta = Ext.create('Lada.store.StatusWerte'); + sta.load({ + scope: this, + callback: function(records, operation, success) { + if (success) { + var item = sta.getById(value); + if (item) { + val = item.get('wert'); + } + } + Ext.fly(opts.divId).update(val); } - Ext.fly(opts.divId).update(val); + }); + } + else { + // set the data + var item = sta.getById(value); + if (item) { + val = item.get('wert'); } - }); + Ext.fly(opts.divId).update(val); + } } }, diff -r 9b6800458a9e -r 6a6f2c6fe8ee app/view/grid/Status.js --- a/app/view/grid/Status.js Thu Nov 12 09:50:48 2015 +0100 +++ b/app/view/grid/Status.js Thu Nov 12 12:13:31 2015 +0100 @@ -25,6 +25,15 @@ allowDeselect: true, initComponent: function() { + var statusWerteStore = Ext.create('Lada.store.StatusWerte'); + statusWerteStore.load({ + params: { + messungsId: this.recordId + } + }); + var statusStufeStore = Ext.create('Lada.store.StatusStufe'); + statusStufeStore.load(); + this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { clicksToMoveEditor: 1, autoCancel: false, @@ -46,18 +55,6 @@ }); this.plugins = [this.rowEditing]; - var statusWerteStore = Ext.create('Lada.store.StatusWerte'); - statusWerteStore.load({ - //params: { - // messungsId: this.recordId - //} - }); - var statusStufeStore = Ext.create('Lada.store.StatusStufe'); - statusStufeStore.load({ - //params: { - // messungsId: this.recordId - //} - }); this.dockedItems = [{ xtype: 'toolbar', dock: 'bottom', @@ -108,11 +105,12 @@ header: 'Stufe', dataIndex: 'statusStufe', renderer: function(value) { + var sta = Ext.data.StoreManager.get('statusstufe'); var r; if (value===null || value === '') { r = 'Error'; } - var item = statusStufeStore.getById(value); + var item = sta.getById(value); if (item) { r = item.get('stufe'); } @@ -123,11 +121,13 @@ header: 'Status', 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'; } - var item = statusWerteStore.getById(value); + var item = sta.getById(value); if (item) { r = item.get('wert'); }