comparison app/view/grid/Probenehmer.js @ 975:fb99332bb48e stammdatengrids

Severe changes concerning the Resultgrids. - Intrduced "Stammdaten" which can be selected in the Mode Field on the left side, - Added Stores and Models for the Stammdaten - Removed the FilterResultgrid and replaced it with a model which uses inheritance. Dynamic Grid Columns can now be derived from app/view/widget/DynamicGrid.js For Proben and Messprogramme this is already done. - There might be some REGRESSION concerning the buttons in the ProbeList and MessprogrammeList grid, as those are not disabled properly. This needs to be fixed in future commits.
author Dustin Demuth <dustin@intevation.de>
date Wed, 02 Dec 2015 17:39:04 +0100
parents
children 2c394e72ba41
comparison
equal deleted inserted replaced
974:ea477f62a667 975:fb99332bb48e
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 Probenehmer Stammdaten
11 */
12 Ext.define('Lada.view.grid.Probenehmer', {
13 extend: 'Ext.grid.Panel',
14 alias: 'widget.probenehmergrid',
15
16 // minHeight and deferEmptyText are needed to be able to show the
17 // emptyText message.
18 minHeight: 110,
19 viewConfig: {
20 deferEmptyText: false
21 },
22
23 warnings: null,
24 errors: null,
25 readOnly: true,
26 allowDeselect: true,
27
28 initComponent: function() {
29 var i18n = Lada.getApplication().bundle;
30 this.emptyText = i18n.getMsg('pn.emptyGrid');
31
32 // TODO: Which docked Items are required?
33 this.dockedItems = [{
34 xtype: 'toolbar',
35 dock: 'top',
36 items: [{
37 xtype: 'tbtext',
38 id: 'tbtitle',
39 text: i18n.getMsg('pn.gridTitle')
40 }]
41 /*
42 //bottom toolbar?
43 }, {
44 xtype: 'toolbar',
45 dock: 'bottom',
46 items: ['->', {
47 text: 'Hinzufügen',
48 icon: 'resources/img/list-add.png',
49 action: 'add',
50 probeId: this.probeId
51 }, {
52 text: 'Löschen',
53 icon: 'resources/img/list-remove.png',
54 action: 'delete'
55 }]
56 */
57 }];
58 /*
59 // Do we have row-editing
60 this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
61 clicksToMoveEditor: 1,
62 autoCancel: false,
63 disabled: false,
64 pluginId: 'rowedit',
65 listeners:{
66 // Make row ineditable when readonly is set to true
67 // Normally this would belong into a controller an not the view.
68 // But the RowEditPlugin is not handled there.
69 beforeedit: function(e, o) {
70 var readonlywin = o.grid.up('window').record.get('readonly');
71 var readonlygrid = o.record.get('readonly');
72 if (readonlywin == true || readonlygrid == true || this.disabled) {
73 return false;
74 }
75 return true;
76 }
77 }
78 });
79 this.plugins = [this.rowEditing];
80 */
81 this.columns = [{
82 header: i18n.getMsg('netzbetreiberId'),
83 dataIndex: 'netzbetreiberId',
84 renderer: function(value) {
85 var r = '';
86 if (!value || value === '') {
87 r = 'Error';
88 }
89 var store = Ext.data.StoreManager.get('netzbetreiber');
90 var record = store.getById(value);
91 if (record) {
92 r = record.get('netzbetreiber');
93 }
94 return r;
95 },
96 editor: {
97 xtype: 'combobox',
98 store: Ext.data.StoreManager.get('netzbetreiber'),
99 displayField: 'netzbetreiber',
100 valueField: 'id',
101 allowBlank: false
102 }
103 }, {
104 header: i18n.getMsg('bearbeiter'),
105 dataIndex: 'bearbeiter',
106 editor: {
107 allowBlank: false
108 }
109 }, {
110 header: i18n.getMsg('prnId'),
111 dataIndex: 'prnId',
112 editor: {
113 allowBlank: false
114 }
115 }, {
116 header: i18n.getMsg('bemerkung'),
117 dataIndex: 'bemerkung',
118 editor: {
119 allowBlank: false
120 }
121 }, {
122 header: i18n.getMsg('kurzBezeichnung'),
123 dataIndex: 'kurzBezeichnung',
124 editor: {
125 allowBlank: false
126 }
127 }, {
128 header: i18n.getMsg('ort'),
129 dataIndex: 'ort',
130 editor: {
131 allowBlank: false
132 }
133 }, {
134 header: i18n.getMsg('plz'),
135 dataIndex: 'plz',
136 editor: {
137 allowBlank: false
138 }
139 }, {
140 header: i18n.getMsg('strasse'),
141 dataIndex: 'strasse',
142 editor: {
143 allowBlank: false
144 }
145 }, {
146 header: i18n.getMsg('telefon'),
147 dataIndex: 'telefon',
148 editor: {
149 allowBlank: false
150 }
151 }, {
152 header: i18n.getMsg('tp'),
153 dataIndex: 'tp',
154 editor: {
155 allowBlank: false
156 }
157 }, {
158 header: i18n.getMsg('typ'),
159 dataIndex: 'typ',
160 editor: {
161 allowBlank: false
162 }
163 }, {
164 header: i18n.getMsg('letzteAenderung'),
165 dataIndex: 'letzteAenderung'
166 }];
167 this.listeners = {
168 select: {
169 fn: this.activateRemoveButton,
170 scope: this
171 },
172 deselect: {
173 fn: this.deactivateRemoveButton,
174 scope: this
175 }
176 };
177 // this.initData(); //This will be called by the Query Component.
178 this.callParent(arguments);
179 //TODO this.setReadOnly(true); //Grid is always initialised as RO
180 },
181
182 initData: function() {
183 this.store = Ext.create('Lada.store.DatensatzErzeuger');
184 this.store.load(); //TODO: Params?
185 },
186
187 setReadOnly: function(b) {
188 if (b == true){
189 //Readonly
190 if (this.getPlugin('rowedit')){
191 this.getPlugin('rowedit').disable();
192 }
193 try {
194 this.down('button[action=delete]').disable();
195 this.down('button[action=add]').disable();
196 }
197 catch(e) {
198 //TODO: Do Nothing...
199 }
200 }else{
201 //Writable
202 if (this.getPlugin('rowedit')){
203 this.getPlugin('rowedit').enable();
204 }
205 try {
206 this.down('button[action=delete]').enable();
207 this.down('button[action=add]').enable();
208 }
209 catch(e) {
210 //TODO: Do Nothing...
211 }
212 }
213 },
214 /**
215 * Activate the Remove Button
216 */
217 activateRemoveButton: function(selection, record) {
218 var grid = this;
219 //only enable the remove buttone, when the grid is editable.
220 if (! grid.readOnly) {
221 try {
222 grid.down('button[action=delete]').enable();
223 }
224 catch(e) {
225 //TODO: Do Nothing
226 }
227 }
228 },
229 /**
230 * deactivate the Remove Button
231 */
232 deactivateRemoveButton: function(selection, record) {
233 var grid = this;
234 //only enable the remove buttone, when the grid is editable.
235 if (! grid.readOnly) {
236 try {
237 grid.down('button[action=delete]').disable();
238 }
239 catch(e) {
240 //TODO: Do Nothing
241 }
242 }
243 }
244 });
245

http://lada.wald.intevation.org