Mercurial > lada > lada-client
annotate app/controller/form/Ort.js @ 623:19d81c9aa97f
anchored all elements, to make them the same size, added a margin of 1px to the frame around the fieldset to prevent the cuttoff on the right side
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Mon, 16 Mar 2015 11:12:10 +0100 |
parents | 3d33c65319f3 |
children | 5b5bba1d8e6a |
rev | line source |
---|---|
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 * |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 */ |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 Ext.define('Lada.controller.form.Ort', { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 extend: 'Ext.app.Controller', |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 init: function() { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 this.control({ |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 'ortform button[action=save]': { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 click: this.save |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 }, |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 'ortform button[action=discard]': { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 click: this.discard |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 }, |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 'ortform': { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 dirtychange: this.dirtyForm |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 }, |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 'ortform combobox[name=ort]': { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 select: this.updateDetails |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 }); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 }, |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 save: function(button) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 var formPanel = button.up('form'); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 var data = formPanel.getForm().getFieldValues(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 for (var key in data) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 formPanel.getForm().getRecord().set(key, data[key]); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 formPanel.getForm().getRecord().save({ |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 success: function(record, response) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 var json = Ext.decode(response.response.responseText); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 if (response.action !== 'create' && |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 json && |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 json.success) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 button.setDisabled(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 button.up('toolbar').down('button[action=discard]') |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 .setDisabled(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 formPanel.clearMessages(); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 formPanel.setRecord(record); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 formPanel.setMessages(json.errors, json.warnings); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 }, |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 failure: function(record, response) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 button.setDisabled(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 button.up('toolbar').down('button[action=discard]') |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 .setDisabled(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 var json = response.request.scope.reader.jsonData; |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 if (json) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 formPanel.setMessages(json.errors, json.warnings); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 }); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 }, |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 discard: function(button) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 var formPanel = button.up('form'); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); |
615
3d33c65319f3
Update feature selection on 'ort' selection change.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
603
diff
changeset
|
65 var win = button.up('window'); |
3d33c65319f3
Update feature selection on 'ort' selection change.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
603
diff
changeset
|
66 var id = formPanel.getForm().getRecord().get('ort'); |
3d33c65319f3
Update feature selection on 'ort' selection change.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
603
diff
changeset
|
67 var toLoad = Ext.data.StoreManager.get('locations').getById(id); |
3d33c65319f3
Update feature selection on 'ort' selection change.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
603
diff
changeset
|
68 win.down('locationform').setRecord(toLoad); |
3d33c65319f3
Update feature selection on 'ort' selection change.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
603
diff
changeset
|
69 win.down('map').selectFeature(id); |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 }, |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 dirtyForm: function(form, dirty) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 if (dirty) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 form.owner.down('button[action=save]').setDisabled(false); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 form.owner.down('button[action=discard]').setDisabled(false); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 else { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 form.owner.down('button[action=save]').setDisabled(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 form.owner.down('button[action=discard]').setDisabled(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 }, |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 updateDetails: function(combobox, record) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 var win = combobox.up('window'); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 var details = win.down('locationform'); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 var id = record[0].get('id'); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 if (details) { |
615
3d33c65319f3
Update feature selection on 'ort' selection change.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
603
diff
changeset
|
88 var toLoad = Ext.data.StoreManager.get('locations').getById(id); |
3d33c65319f3
Update feature selection on 'ort' selection change.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
603
diff
changeset
|
89 win.down('locationform').setRecord(toLoad); |
3d33c65319f3
Update feature selection on 'ort' selection change.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
603
diff
changeset
|
90 win.down('map').selectFeature(id); |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 }); |