Mercurial > lada > lada-client
diff app/view/form/Messung.js @ 945:023e622f9551
Added the ability to work with "StatusWerten" which are delivered by the lada-server.
To enable the uses of StatusWerte, the controller for the status grid, needed to be extended.
In addition, the form and grid views of Messung and Status were updated.
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Tue, 27 Oct 2015 16:46:58 +0100 |
parents | a1d72228af00 |
children | c7bf0b459074 |
line wrap: on
line diff
--- a/app/view/form/Messung.js Fri Oct 16 08:15:36 2015 +0200 +++ b/app/view/form/Messung.js Tue Oct 27 16:46:58 2015 +0100 @@ -113,6 +113,22 @@ fieldLabel: 'Geplant', width: 300, labelWidth: 100 + }, { + xtype: 'textfield', + name: 'status', + readOnly: true, + isFormField: false, + maxLength: 10, + margin: '0, 10, 5, 0', + fieldLabel: 'Status', + width: 300, + labelWidth: 100, + submitValue: false, + isFormField: false, + preventMark: true, //Do not display error msg. + validateValue: function() { + return true; //this field is always valid + }, }] }] }]; @@ -121,6 +137,57 @@ setRecord: function(record) { this.getForm().loadRecord(record); + this.retrieveStatus(record.id, record.get('status')); + }, + + retrieveStatus: function(messungsId, statusId) { + var i18n = Lada.getApplication().bundle; + var msg = i18n.getMsg('load.statuswert'); + var textfield = this.down('[name=status]'); + + textfield.setRawValue(msg); + + var sStore = Ext.StoreManager.lookup('Status'); + if (!sStore) { + sStore = Ext.create('Lada.store.Status'); + } + sStore.on('load', + function(records, operation, success) { + var ret; + var i18n = Lada.getApplication().bundle; + if (sStore.getTotalCount() === 0) { + ret = 0; + } + else { + ret = sStore.getById(statusId).get('statusWert'); + } + this.setStatusWert(ret); + }, + this); + sStore.load({ + params: { + messungsId: messungsId + } + }); + }, + + setStatusWert: function(value){ + var swStore = Ext.StoreManager.lookup('StatusWerte'); + if (!swStore) { + var swStore = Ext.create('Lada.store.StatusWerte'); + } + swStore.on('load', + function(records, operation, success) { + var i18n = Lada.getApplication().bundle; + var msg = i18n.getMsg('load.statuswert.error'); + var textfield = this.down('[name=status]'); + if (success) { + msg = swStore.getById(value).get('wert'); + } + textfield.setRawValue(msg); + }, + this); + swStore.load(); }, setMessages: function(errors, warnings) {