Mercurial > lada > lada-client
comparison app/view/grid/Ortszuordnung.js @ 1004:9ac03f461ab4 stammdatengrids
Introduced Orte into Stammdatengrids, Added Ortszuordnung. THIS COMMIT IS WORK IN PROGRESS, Proben will NOT work after this commit. Orte can not be edited.
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Wed, 20 Jan 2016 12:32:42 +0100 |
parents | app/view/grid/Ort.js@07dfcdf5b41f |
children | 2adc329d90fe 4d4de99bbe53 |
comparison
equal
deleted
inserted
replaced
1003:15d8c64049d1 | 1004:9ac03f461ab4 |
---|---|
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 Ortszuordnungen | |
11 */ | |
12 Ext.define('Lada.view.grid.Ortszuordnung', { | |
13 extend: 'Ext.grid.Panel', | |
14 alias: 'widget.ortgrid', | |
15 | |
16 maxHeight: 350, | |
17 emptyText: 'Keine Orte gefunden.', | |
18 // minHeight and deferEmptyText are needed to be able to show the | |
19 // emptyText message. | |
20 minHeight: 110, | |
21 viewConfig: { | |
22 deferEmptyText: false | |
23 }, | |
24 margin: '0, 5, 5, 5', | |
25 | |
26 recordId: null, | |
27 | |
28 warnings: null, | |
29 errors: null, | |
30 readOnly: true, | |
31 allowDeselect: true, | |
32 | |
33 initComponent: function() { | |
34 this.dockedItems = [{ | |
35 xtype: 'toolbar', | |
36 dock: 'bottom', | |
37 items: ['->', { | |
38 text: 'Hinzufügen', | |
39 icon: 'resources/img/list-add.png', | |
40 action: 'add', | |
41 probeId: this.probeId | |
42 }, { | |
43 text: 'Löschen', | |
44 icon: 'resources/img/list-remove.png', | |
45 action: 'delete' | |
46 }] | |
47 }]; | |
48 this.columns = [{ | |
49 header: 'Typ', | |
50 dataIndex: 'ortsTyp', | |
51 width: 50, | |
52 editor: { | |
53 allowBlank: false | |
54 } | |
55 }, { | |
56 header: 'Staat', | |
57 dataIndex: 'ort', | |
58 width: 70, | |
59 renderer: function(value) { | |
60 var store = Ext.data.StoreManager.get('orte'); | |
61 var staaten = Ext.data.StoreManager.get('staaten'); | |
62 var record = | |
63 staaten.getById(store.getById(value).get('staatId')); | |
64 return record.get('staatIso'); | |
65 } | |
66 }, { | |
67 header: 'Gemeineschlüssel', | |
68 dataIndex: 'ort', | |
69 width: 120, | |
70 renderer: function(value) { | |
71 var store = Ext.data.StoreManager.get('orte'); | |
72 var record = store.getById(value); | |
73 return record.get('gemId'); | |
74 } | |
75 }, { | |
76 header: 'Gemeindename', | |
77 dataIndex: 'ort', | |
78 flex: 1, | |
79 renderer: function(value) { | |
80 var store = Ext.data.StoreManager.get('orte'); | |
81 var gemeinden = | |
82 Ext.data.StoreManager.get('verwaltungseinheiten'); | |
83 var record = store.getById(value); | |
84 var gemid = record.get('gemId'); | |
85 var record2 = gemeinden.getById(gemid); | |
86 return record2.get('bezeichnung'); | |
87 } | |
88 }, { | |
89 header: 'Messpunkt', | |
90 dataIndex: 'ort', | |
91 renderer: function(value) { | |
92 var store = Ext.getStore('orte'); | |
93 var record = store.getById(value); | |
94 return record.get('bezeichnung'); | |
95 } | |
96 }]; | |
97 this.listeners = { | |
98 select: { | |
99 fn: this.activateRemoveButton, | |
100 scope: this | |
101 }, | |
102 deselect: { | |
103 fn: this.deactivateRemoveButton, | |
104 scope: this | |
105 } | |
106 }; | |
107 this.initData(); | |
108 this.callParent(arguments); | |
109 this.setReadOnly(true); //Grid is always initialised as RO | |
110 }, | |
111 | |
112 initData: function() { | |
113 this.store = Ext.create('Lada.store.Ortszuordnung'); | |
114 this.store.load({ | |
115 params: { | |
116 probeId: this.recordId | |
117 } | |
118 }); | |
119 Ext.ClassManager.get('Lada.model.Probe').load(this.recordId, { | |
120 failure: function(record, action) { | |
121 // TODO | |
122 }, | |
123 success: function(record, response) { | |
124 var json = Ext.decode(response.response.responseText); | |
125 if (json) { | |
126 this.warnings = json.warnings; | |
127 this.errors = json.errors; | |
128 } | |
129 }, | |
130 scope: this | |
131 }); | |
132 }, | |
133 | |
134 setReadOnly: function(b) { | |
135 if (b == true){ | |
136 //Readonly | |
137 if (this.getPlugin('rowedit')){ | |
138 this.getPlugin('rowedit').disable(); | |
139 } | |
140 this.down('button[action=delete]').disable(); | |
141 this.down('button[action=add]').disable(); | |
142 }else{ | |
143 //Writable | |
144 if (this.getPlugin('rowedit')){ | |
145 this.getPlugin('rowedit').enable(); | |
146 } | |
147 //this.down('button[action=delete]').enable(); | |
148 this.down('button[action=add]').enable(); | |
149 } | |
150 }, | |
151 /** | |
152 * Activate the Remove Button | |
153 */ | |
154 activateRemoveButton: function(selection, record) { | |
155 var grid = this; | |
156 //only enable the remove buttone, when the grid is editable. | |
157 if (! grid.readOnly) { | |
158 grid.down('button[action=delete]').enable(); | |
159 } | |
160 }, | |
161 /** | |
162 * Activate the Remove Button | |
163 */ | |
164 deactivateRemoveButton: function(selection, record) { | |
165 var grid = this; | |
166 //only enable the remove buttone, when the grid is editable. | |
167 if (! grid.readOnly) { | |
168 grid.down('button[action=delete]').disable(); | |
169 } | |
170 } | |
171 }); |