[Lada-commits] [PATCH 1 of 4] Load messung grid columns as record fields to get rid of 'Ext.fly'
Wald Commits
scm-commit at wald.intevation.org
Thu Feb 18 11:22:14 CET 2016
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1455790615 -3600
# Node ID fa04558f35cda822394e4ca8719abafaa725c3eb
# Parent 488fed1d2b987f780c74877c9c2ab0e0d08b5fd4
Load messung grid columns as record fields to get rid of 'Ext.fly'
diff -r 488fed1d2b98 -r fa04558f35cd app/model/Messung.js
--- a/app/model/Messung.js Wed Feb 17 14:25:40 2016 +0100
+++ b/app/model/Messung.js Thu Feb 18 11:16:55 2016 +0100
@@ -76,6 +76,15 @@
}
return value;
}
+ }, {
+ name: 'statusWert',
+ persist: false
+ }, {
+ name: 'messwerteCount',
+ persist: false
+ }, {
+ name: 'kommentarCount',
+ persist: false
}],
idProperty: 'id',
diff -r 488fed1d2b98 -r fa04558f35cd app/view/grid/Messung.js
--- a/app/view/grid/Messung.js Wed Feb 17 14:25:40 2016 +0100
+++ b/app/view/grid/Messung.js Thu Feb 18 11:16:55 2016 +0100
@@ -81,15 +81,19 @@
}, {
header: 'Status',
flex: 1,
- dataIndex: 'id',
- renderer: function(value) {
- var statusId = this.store.getById(value).get('status');
- var divId = 'messung-status-item' + value;
+ dataIndex: 'statusWert',
+ renderer: function(value, meta, record, rNdx, cNdx) {
+ var statusId = record.get('status');
+ var mId = record.get('id');
//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 '<div id="' + divId + '">Lade...</div>';
+ if (value === '') {
+ this.updateStatus(mId, statusId, record);
+ return 'Lade...';
+ }
+ var sta = Ext.data.StoreManager.getByKey('statuswerte');
+ return sta.getById(value).get('wert');
}
}, {
header: 'OK-Flag',
@@ -110,21 +114,27 @@
// Gibt die Anzahl der Messwerte wieder,
// NICHT die Anzahl der verschiedenen Nukleide
// Eventuell ist die Bezeichnug daher irreführend
- dataIndex: 'id',
+ dataIndex: 'messwerteCount',
flex: 1,
- renderer: function(value) {
- var id = 'messung-nuklid-item' + value;
- this.updateNuklide(value, id);
- return '<div id="' + id + '">Lade...</div>';
+ renderer: function(value, meta, record) {
+ if (value === '') {
+ var mId = record.get('id');
+ this.updateNuklide(mId, record);
+ return 'Lade...';
+ }
+ return value;
}
}, {
header: 'Anzahl Kommentare',
flex: 1,
- dataIndex: 'id',
- renderer: function(value) {
- var id = 'messung-kommentar-item' + value;
- this.updateKommentare(value, id);
- return '<div id="' + id + '">Lade...</div>';
+ dataIndex: 'kommentarCount',
+ renderer: function(value, meta, record) {
+ if (value === '') {
+ var mId = record.get('id');
+ this.updateKommentare(mId, record);
+ return 'Lade...';
+ }
+ return value;
}
}];
this.listeners = {
@@ -160,12 +170,12 @@
* Load the statusstore,
* afterwards: retrieve the statusid
*/
- updateStatus: function(value, divId, statusId, record) {
+ updateStatus: function(value, statusId, record) {
var statusStore = Ext.create('Lada.store.Status');
statusStore.on('load',
this.updateStatusColumn,
this,
- {divId: divId, statusId: statusId, record: record});
+ {statusId: statusId, record: record});
statusStore.load({
params: {
messungsId: value
@@ -173,28 +183,28 @@
});
},
- updateNuklide: function(value, divId) {
+ updateNuklide: function(id, record) {
var messwerte = Ext.create('Lada.store.Messwerte');
messwerte.on('load',
this.updateColumn,
this,
- {divId: divId});
+ {record: record, type: 'messwerteCount'});
messwerte.load({
params: {
- messungsId: value
+ messungsId: id
}
});
},
- updateKommentare: function(value, divId) {
+ updateKommentare: function(id, record) {
var kommentare = Ext.create('Lada.store.MKommentare');
kommentare.on('load',
this.updateColumn,
this,
- {divId: divId});
+ {record: record, type: 'kommentarCount'});
kommentare.load({
params: {
- messungsId: value
+ messungsId: id
}
});
},
@@ -212,7 +222,9 @@
else {
value = 'k.A.';
}
- Ext.fly(opts.divId).update(value);
+ opts.record.beginEdit();
+ opts.record.set(opts.type, value);
+ opts.record.endEdit();
},
/**
@@ -230,37 +242,9 @@
//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)) {
- //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';
- 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);
- }
- });
- }
- else {
- // set the data
- var item = sta.getById(value);
- if (item) {
- val = item.get('wert');
- }
- Ext.fly(opts.divId).update(val);
+ opts.record.beginEdit();
+ opts.record.set('statusWert', value);
+ opts.record.endEdit();
}
}
},
More information about the Lada-commits
mailing list