comparison app/view/grid/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 b401846e7817
children 989736bf4ffb
comparison
equal deleted inserted replaced
962:9b6800458a9e 963:6a6f2c6fe8ee
83 flex: 1, 83 flex: 1,
84 dataIndex: 'id', 84 dataIndex: 'id',
85 renderer: function(value) { 85 renderer: function(value) {
86 var statusId = this.store.getById(value).get('status'); 86 var statusId = this.store.getById(value).get('status');
87 var divId = 'messung-status-item' + value; 87 var divId = 'messung-status-item' + value;
88 this.updateStatus(value, divId, statusId); 88 //also fwd the record to the asynchronous loading of statuswerte
89 // in order to add the statuswert to the record,
90 // after the grid was rendered...
91 this.updateStatus(value, divId, statusId, this.store.getById(value));
89 return '<div id="' + divId + '">Lade...</div>'; 92 return '<div id="' + divId + '">Lade...</div>';
90 } 93 }
91 }, { 94 }, {
92 header: 'OK-Flag', 95 header: 'OK-Flag',
93 dataIndex: 'fertig', 96 dataIndex: 'fertig',
138 this.callParent(arguments); 141 this.callParent(arguments);
139 this.setReadOnly(true); //Grid is always initialised as RO 142 this.setReadOnly(true); //Grid is always initialised as RO
140 }, 143 },
141 144
142 initData: function() { 145 initData: function() {
146 this.setLoading(true);
143 this.store = Ext.create('Lada.store.Messungen'); 147 this.store = Ext.create('Lada.store.Messungen');
144 this.store.load({ 148 this.store.load({
145 params: { 149 params: {
146 probeId: this.recordId 150 probeId: this.recordId
147 } 151 },
152 callback: function (records, operation, success) {
153 this.setLoading(false);
154 },
155 scope: this
148 }); 156 });
149 }, 157 },
150 158
151 /** 159 /**
152 * Load the statusstore, 160 * Load the statusstore,
153 * afterwards: retrieve the statusid 161 * afterwards: retrieve the statusid
154 */ 162 */
155 updateStatus: function(value, divId, statusId) { 163 updateStatus: function(value, divId, statusId, record) {
156 var statusStore = Ext.create('Lada.store.Status'); 164 var statusStore = Ext.create('Lada.store.Status');
157 statusStore.on('load', 165 statusStore.on('load',
158 this.updateStatusColumn, 166 this.updateStatusColumn,
159 this, 167 this,
160 {divId: divId, statusId: statusId}); 168 {divId: divId, statusId: statusId, record: record});
161 statusStore.load({ 169 statusStore.load({
162 params: { 170 params: {
163 messungsId: value 171 messungsId: value
164 } 172 }
165 }); 173 });
209 var value = 0; 217 var value = 0;
210 if (sstore.getTotalCount() === 0 || !opts.statusId) { 218 if (sstore.getTotalCount() === 0 || !opts.statusId) {
211 value = 0; 219 value = 0;
212 } 220 }
213 else { 221 else {
214 value = sstore.getById(opts.statusId).get('statusWert'); 222 var rec = sstore.getById(opts.statusId);
223 if (rec) {
224 value = rec.get('statusWert');
225 //add the determined statuswert to the record.
226 // this is necessary to let the controller determine
227 // which actions are allowed.
228 opts.record.data.statusWert = value;
229 }
215 } 230 }
216 if (Ext.fly(opts.divId)) { 231 if (Ext.fly(opts.divId)) {
217 var sta = Ext.StoreManager.lookup('StatusWerte'); 232 //Try to get the statuswerte store,
233 // If it does not exist, create a new one.
234 var sta = Ext.data.StoreManager.getByKey('statuswerte');
235 var val = 'error';
218 if (!sta) { 236 if (!sta) {
219 var sta = Ext.create('Lada.store.StatusWerte'); 237 // Set the Data asynchronously
220 } 238 sta = Ext.create('Lada.store.StatusWerte');
221 var val = 'error'; 239 sta.load({
222 sta.load({ 240 scope: this,
223 scope: this, 241 callback: function(records, operation, success) {
224 callback: function(records, operation, success) { 242 if (success) {
225 if (success) { 243 var item = sta.getById(value);
226 val = sta.getById(value).get('wert'); 244 if (item) {
245 val = item.get('wert');
246 }
247 }
248 Ext.fly(opts.divId).update(val);
227 } 249 }
228 Ext.fly(opts.divId).update(val); 250 });
251 }
252 else {
253 // set the data
254 var item = sta.getById(value);
255 if (item) {
256 val = item.get('wert');
229 } 257 }
230 }); 258 Ext.fly(opts.divId).update(val);
259 }
231 } 260 }
232 }, 261 },
233 262
234 setReadOnly: function(b) { 263 setReadOnly: function(b) {
235 if (b == true){ 264 if (b == true){

http://lada.wald.intevation.org