Mercurial > lada > lada-client
diff app/view/form/Messung.js @ 963:6a6f2c6fe8ee
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.
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Thu, 12 Nov 2015 12:13:31 +0100 |
parents | 6f1cc3316e2d |
children | a2c2039bb5d9 |
line wrap: on
line diff
--- 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) {