Mercurial > lada > lada-client
comparison app/view/grid/Ort.js @ 548:d47ee7439f44
Added new js files.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 06 Mar 2015 12:43:52 +0100 |
parents | |
children | 339741bc6ebf |
comparison
equal
deleted
inserted
replaced
547:f172b35a3b92 | 548:d47ee7439f44 |
---|---|
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 Orte | |
11 */ | |
12 Ext.define('Lada.view.grid.Ort', { | |
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 | |
31 initComponent: function() { | |
32 var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { | |
33 clicksToMoveEditor: 1, | |
34 autoCancel: false, | |
35 itemId: 'rowedit' | |
36 }); | |
37 this.plugins = [rowEditing]; | |
38 | |
39 this.dockedItems = [{ | |
40 xtype: 'toolbar', | |
41 dock: 'bottom', | |
42 items: ['->', { | |
43 text: 'Details', | |
44 icon: 'resources/img/document-open.png', | |
45 action: 'open', | |
46 disabled: true | |
47 }, { | |
48 text: 'Hinzufügen', | |
49 icon: 'resources/img/list-add.png', | |
50 action: 'add', | |
51 probeId: this.probeId | |
52 }, { | |
53 text: 'Löschen', | |
54 icon: 'resources/img/list-remove.png', | |
55 action: 'delete' | |
56 }] | |
57 }]; | |
58 this.columns = [{ | |
59 header: 'Typ', | |
60 dataIndex: 'ortsTyp', | |
61 width: 50, | |
62 editor: { | |
63 allowBlank: false | |
64 } | |
65 }, { | |
66 header: 'Staat', | |
67 dataIndex: 'ort', | |
68 width: 70, | |
69 renderer: function(value) { | |
70 var store = Ext.data.StoreManager.get('locations'); | |
71 var staaten = Ext.data.StoreManager.get('staaten'); | |
72 var record = | |
73 staaten.getById(store.getById(value).get('staatId')); | |
74 return record.get('staatIso'); | |
75 } | |
76 }, { | |
77 header: 'Gemeineschlüssel', | |
78 dataIndex: 'ort', | |
79 width: 120, | |
80 renderer: function(value) { | |
81 var store = Ext.data.StoreManager.get('locations'); | |
82 var record = store.getById(value); | |
83 return record.get('verwaltungseinheitId'); | |
84 } | |
85 }, { | |
86 header: 'Gemeindename', | |
87 dataIndex: 'ort', | |
88 flex: 1, | |
89 renderer: function(value) { | |
90 var store = Ext.data.StoreManager.get('locations'); | |
91 var gemeinden = | |
92 Ext.data.StoreManager.get('verwaltungseinheiten'); | |
93 var record = store.getById(value); | |
94 var gemid = record.get('verwaltungseinheitId'); | |
95 var record2 = gemeinden.getById(gemid); | |
96 return record2.get('bezeichnung'); | |
97 } | |
98 }, { | |
99 header: 'Messpunkt', | |
100 dataIndex: 'ort', | |
101 renderer: function(value) { | |
102 var store = Ext.getStore('locations'); | |
103 var record = store.getById(value); | |
104 return record.get('bezeichnung'); | |
105 } | |
106 }]; | |
107 this.initData(); | |
108 this.callParent(arguments); | |
109 }, | |
110 | |
111 initData: function() { | |
112 this.store = Ext.create('Lada.store.Orte'); | |
113 this.store.load({ | |
114 params: { | |
115 probeId: this.recordId | |
116 } | |
117 }); | |
118 Ext.ClassManager.get('Lada.model.Probe').load(this.recordId, { | |
119 failure: function(record, action) { | |
120 // TODO | |
121 }, | |
122 success: function(record, response) { | |
123 var json = Ext.decode(response.response.responseText); | |
124 if (json) { | |
125 this.warnings = json.warnings; | |
126 this.errors = json.errors; | |
127 } | |
128 }, | |
129 scope: this | |
130 }); | |
131 }, | |
132 | |
133 | |
134 setReadOnly: function() { | |
135 this.getPlugin('rowedit').disable(); | |
136 this.down('button[action=add]').disable(); | |
137 this.down('button[action=delete]').disable(); | |
138 } | |
139 }); |