Mercurial > lada > lada-client
comparison app/view/grid/Messung.js @ 588:e24bc8cf8e1d
Renamed messungen grid and controller.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 11 Mar 2015 15:21:27 +0100 |
parents | |
children | 6742ae5f35dc |
comparison
equal
deleted
inserted
replaced
587:cf328526b5bb | 588:e24bc8cf8e1d |
---|---|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out | |
6 * the documentation coming with IMIS-Labordaten-Application for details. | |
7 */ | |
8 | |
9 /* | |
10 * Grid to list Messungen | |
11 */ | |
12 Ext.define('Lada.view.grid.Messung', { | |
13 extend: 'Ext.grid.Panel', | |
14 alias: 'widget.messunggrid', | |
15 | |
16 maxHeight: 350, | |
17 emptyText: 'Keine Messungen gefunden', | |
18 minHeight: 110, | |
19 viewConfig: { | |
20 deferEmptyText: false | |
21 }, | |
22 margin: '0, 5, 5, 5', | |
23 | |
24 recordId: null, | |
25 | |
26 warnings: null, | |
27 errors: null, | |
28 | |
29 initComponent: function() { | |
30 this.dockedItems = [{ | |
31 xtype: 'toolbar', | |
32 dock: 'bottom', | |
33 items: ['->', { | |
34 text: 'Hinzufügen', | |
35 icon: 'resources/img/list-add.png', | |
36 action: 'add', | |
37 probeId: this.probeId | |
38 }, { | |
39 text: 'Löschen', | |
40 icon: 'resources/img/list-remove.png', | |
41 action: 'delete' | |
42 }] | |
43 }]; | |
44 this.columns = [{ | |
45 header: 'Mess-ID', | |
46 dataIndex: 'id', | |
47 flex: 1, | |
48 editor: { | |
49 allowBlank: false | |
50 } | |
51 }, { | |
52 header: 'Nebenproben-Nr.', | |
53 dataIndex: 'nebenprobenNr', | |
54 flex: 1, | |
55 editor: { | |
56 allowBlank: false | |
57 } | |
58 }, { | |
59 header: 'MMT', | |
60 dataIndex: 'mmtId', | |
61 flex: 1, | |
62 editor: { | |
63 allowBlank: false | |
64 } | |
65 }, { | |
66 header: 'Messzeit', | |
67 dataIndex: 'messzeitpunkt', | |
68 flex: 2, | |
69 editor: { | |
70 xtype: 'datefield', | |
71 allowBlank: false, | |
72 format: 'd.m.Y', | |
73 // minValue: '01.01.2001', //todo: gibt es das? | |
74 // minText: 'Das Datum der Messung darf nicht vor dem 01.01.2001 liegen.', | |
75 maxValue: Ext.Date.format(new Date(), 'd.m.Y') | |
76 } | |
77 }, { | |
78 header: 'Status', | |
79 flex: 1, | |
80 dataIndex: 'id', | |
81 renderer: function(value) { | |
82 var id = 'messung-status-item' + value; | |
83 this.updateStatus(value, id); | |
84 return '<div id="' + id + '">Lade...</div>'; | |
85 } | |
86 }, { | |
87 header: 'OK-Flag', | |
88 dataIndex: 'fertig', | |
89 flex: 1, | |
90 renderer: function(value) { | |
91 if (value) { | |
92 return 'Ja'; | |
93 } | |
94 return 'Nein'; | |
95 }, | |
96 editor: { | |
97 xtype: 'checkboxfield', | |
98 allowBlank: false | |
99 } | |
100 }, { | |
101 header: 'Anzahl Nuklide', | |
102 // Gibt die Anzahl der Messwerte wieder, | |
103 // NICHT die Anzahl der verschiedenen Nukleide | |
104 // Eventuell ist die Bezeichnug daher irreführend | |
105 dataIndex: 'id', | |
106 flex: 1, | |
107 renderer: function(value) { | |
108 var id = 'messung-nuklid-item' + value; | |
109 this.updateNuklide(value, id); | |
110 return '<div id="' + id + '">Lade...</div>'; | |
111 } | |
112 }, { | |
113 header: 'Anzahl Kommentare', | |
114 flex: 1, | |
115 dataIndex: 'id', | |
116 renderer: function(value) { | |
117 var id = 'messung-kommentar-item' + value; | |
118 this.updateKommentare(value, id); | |
119 return '<div id="' + id + '">Lade...</div>'; | |
120 } | |
121 }]; | |
122 this.initData(); | |
123 this.callParent(arguments); | |
124 }, | |
125 | |
126 initData: function() { | |
127 this.store = Ext.create('Lada.store.Messungen'); | |
128 this.store.load({ | |
129 params: { | |
130 probeId: this.recordId | |
131 } | |
132 }); | |
133 }, | |
134 | |
135 updateStatus: function(value, divId) { | |
136 var statusStore = Ext.create('Lada.store.Status'); | |
137 statusStore.on('load', | |
138 this.updateStatusColumn, | |
139 this, | |
140 {divId: divId}); | |
141 statusStore.load({ | |
142 params: { | |
143 messungsId: value | |
144 } | |
145 }); | |
146 }, | |
147 | |
148 updateNuklide: function(value, divId) { | |
149 var messwerte = Ext.create('Lada.store.Messwerte'); | |
150 messwerte.on('load', | |
151 this.updateColumn, | |
152 this, | |
153 {divId: divId}); | |
154 messwerte.load({ | |
155 params: { | |
156 messungsId: value | |
157 } | |
158 }); | |
159 }, | |
160 | |
161 updateKommentare: function(value, divId) { | |
162 var kommentare = Ext.create('Lada.store.MKommentare'); | |
163 kommentare.on('load', | |
164 this.updateColumn, | |
165 this, | |
166 {divId: divId}); | |
167 kommentare.load({ | |
168 params: { | |
169 messungsId: value | |
170 } | |
171 }); | |
172 }, | |
173 | |
174 updateColumn: function(store, record, success, opts) { | |
175 var value; | |
176 if (store.getTotalCount() === 0) { | |
177 value = 'Keine'; | |
178 } | |
179 else { | |
180 value = store.getTotalCount(); | |
181 } | |
182 Ext.fly(opts.divId).update(value); | |
183 }, | |
184 | |
185 updateStatusColumn: function(sstore, record, success, opts) { | |
186 var value; | |
187 if (sstore.getTotalCount() === 0) { | |
188 value = 'unbekannt'; | |
189 } | |
190 else { | |
191 value = sstore.last().get('status'); | |
192 } | |
193 if (Ext.fly(opts.divId)) { | |
194 Ext.fly(opts.divId).update(value); | |
195 } | |
196 } | |
197 }); |