Mercurial > lada > lada-client
comparison app/view/grid/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 | 07dfcdf5b41f |
children | c7bf0b459074 |
comparison
equal
deleted
inserted
replaced
944:1f1467713c3f | 945:023e622f9551 |
---|---|
81 }, { | 81 }, { |
82 header: 'Status', | 82 header: 'Status', |
83 flex: 1, | 83 flex: 1, |
84 dataIndex: 'id', | 84 dataIndex: 'id', |
85 renderer: function(value) { | 85 renderer: function(value) { |
86 var id = 'messung-status-item' + value; | 86 var statusId = this.store.getById(value).get('status'); |
87 this.updateStatus(value, id); | 87 var divId = 'messung-status-item' + value; |
88 return '<div id="' + id + '">Lade...</div>'; | 88 this.updateStatus(value, divId, statusId); |
89 return '<div id="' + divId + '">Lade...</div>'; | |
89 } | 90 } |
90 }, { | 91 }, { |
91 header: 'OK-Flag', | 92 header: 'OK-Flag', |
92 dataIndex: 'fertig', | 93 dataIndex: 'fertig', |
93 flex: 1, | 94 flex: 1, |
145 probeId: this.recordId | 146 probeId: this.recordId |
146 } | 147 } |
147 }); | 148 }); |
148 }, | 149 }, |
149 | 150 |
150 updateStatus: function(value, divId) { | 151 /** |
152 * Load the statusstore, | |
153 * afterwards: retrieve the statusid | |
154 */ | |
155 updateStatus: function(value, divId, statusId) { | |
151 var statusStore = Ext.create('Lada.store.Status'); | 156 var statusStore = Ext.create('Lada.store.Status'); |
152 statusStore.on('load', | 157 statusStore.on('load', |
153 this.updateStatusColumn, | 158 this.updateStatusColumn, |
154 this, | 159 this, |
155 {divId: divId}); | 160 {divId: divId, statusId: statusId}); |
156 statusStore.load({ | 161 statusStore.load({ |
157 params: { | 162 params: { |
158 messungsId: value | 163 messungsId: value |
159 } | 164 } |
160 }); | 165 }); |
195 value = store.getTotalCount(); | 200 value = store.getTotalCount(); |
196 } | 201 } |
197 Ext.fly(opts.divId).update(value); | 202 Ext.fly(opts.divId).update(value); |
198 }, | 203 }, |
199 | 204 |
205 /** | |
206 * Retrieve Statuswert and update the column | |
207 */ | |
200 updateStatusColumn: function(sstore, record, success, opts) { | 208 updateStatusColumn: function(sstore, record, success, opts) { |
201 var value; | 209 var value = 0; |
202 if (sstore.getTotalCount() === 0) { | 210 if (sstore.getTotalCount() === 0) { |
203 value = 0; | 211 value = 0; |
204 } | 212 } |
205 else { | 213 else { |
206 value = sstore.last().get('status'); | 214 value = sstore.getById(opts.statusId).get('statusWert'); |
207 } | 215 } |
208 if (Ext.fly(opts.divId)) { | 216 if (Ext.fly(opts.divId)) { |
209 var sta = Ext.create('Lada.store.StatusWerte'); | 217 var sta = Ext.StoreManager.lookup('StatusWerte'); |
210 var val = sta.getById(value).get('display'); | 218 if (!sta) { |
211 Ext.fly(opts.divId).update(val); | 219 var sta = Ext.create('Lada.store.StatusWerte'); |
220 } | |
221 var val = 'error'; | |
222 sta.load({ | |
223 scope: this, | |
224 callback: function(records, operation, success) { | |
225 if (success) { | |
226 try { | |
227 val = sta.getById(value).get('wert'); | |
228 } | |
229 catch (e) { | |
230 } | |
231 } | |
232 Ext.fly(opts.divId).update(val); | |
233 } | |
234 }); | |
212 } | 235 } |
213 }, | 236 }, |
214 | 237 |
215 setReadOnly: function(b) { | 238 setReadOnly: function(b) { |
216 if (b == true){ | 239 if (b == true){ |