Mercurial > lada > lada-client
annotate app/controller/form/Ortszuordnung.js @ 1013:75ce503ab296 stammdatengrids
Added a Ortszuordnungwindow and Form
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Tue, 26 Jan 2016 12:29:59 +0100 |
parents | app/controller/form/Ort.js@24b5684d74d7 |
children | 1df6b6210b42 |
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 |
742
6e28ebbe1a73
added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents:
704
diff
changeset
|
9 /* |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
10 * This is a controller for an Ortszuordnung Form |
742
6e28ebbe1a73
added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents:
704
diff
changeset
|
11 */ |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
12 Ext.define('Lada.controller.form.Ortszuordnung', { |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 extend: 'Ext.app.Controller', |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 |
742
6e28ebbe1a73
added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents:
704
diff
changeset
|
15 /** |
6e28ebbe1a73
added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents:
704
diff
changeset
|
16 * Initialize the Controller with 4 listeners |
6e28ebbe1a73
added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents:
704
diff
changeset
|
17 */ |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 init: function() { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 this.control({ |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
20 'ortszuordnungform button[action=save]': { |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 click: this.save |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 }, |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
23 'ortszuordnungform button[action=discard]': { |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 click: this.discard |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 }, |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
26 'ortszuordnungform': { |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 dirtychange: this.dirtyForm |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 }, |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
29 'ortszuordnungform combobox[name=ort]': { |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 select: this.updateDetails |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 }); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 }, |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 |
742
6e28ebbe1a73
added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents:
704
diff
changeset
|
35 /** |
972
24b5684d74d7
Set letzteAenderung in a Bunch of controllers.
Dustin Demuth <dustin@intevation.de>
parents:
742
diff
changeset
|
36 * The save function saves the content of the Ort form. |
742
6e28ebbe1a73
added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents:
704
diff
changeset
|
37 * On success it will reload the Store, |
6e28ebbe1a73
added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents:
704
diff
changeset
|
38 * on failure, it will display an Errormessage |
6e28ebbe1a73
added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents:
704
diff
changeset
|
39 */ |
6e28ebbe1a73
added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents:
704
diff
changeset
|
40 save: function(button) { |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
41 var formPanel = button.up('ortszuordnungform'); |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 var data = formPanel.getForm().getFieldValues(true); |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
43 var i18n = Lada.getApplication().bundle; |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 for (var key in data) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 formPanel.getForm().getRecord().set(key, data[key]); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 } |
972
24b5684d74d7
Set letzteAenderung in a Bunch of controllers.
Dustin Demuth <dustin@intevation.de>
parents:
742
diff
changeset
|
47 if (!formPanel.getForm().getRecord().get('letzteAenderung')) { |
24b5684d74d7
Set letzteAenderung in a Bunch of controllers.
Dustin Demuth <dustin@intevation.de>
parents:
742
diff
changeset
|
48 formPanel.getForm().getRecord().data.letzteAenderung = new Date(); |
24b5684d74d7
Set letzteAenderung in a Bunch of controllers.
Dustin Demuth <dustin@intevation.de>
parents:
742
diff
changeset
|
49 } |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 formPanel.getForm().getRecord().save({ |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 success: function(record, response) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 var json = Ext.decode(response.response.responseText); |
641
5b5bba1d8e6a
Load and update the correct orte form.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
615
diff
changeset
|
53 if (json) { |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 button.setDisabled(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 button.up('toolbar').down('button[action=discard]') |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 .setDisabled(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 formPanel.clearMessages(); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 formPanel.setRecord(record); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 formPanel.setMessages(json.errors, json.warnings); |
644
71e8b84d7829
Reload grids on messung or ort changed/added.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
641
diff
changeset
|
60 formPanel.up('window').grid.store.reload(); |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
61 debugger; |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 }, |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 failure: function(record, response) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 button.setDisabled(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 button.up('toolbar').down('button[action=discard]') |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 .setDisabled(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 var json = response.request.scope.reader.jsonData; |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 if (json) { |
695
d6ef146e1a9f
Added simple handling for Failure-Messages
Dustin Demuth <dustin@intevation.de>
parents:
644
diff
changeset
|
71 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ |
d6ef146e1a9f
Added simple handling for Failure-Messages
Dustin Demuth <dustin@intevation.de>
parents:
644
diff
changeset
|
72 formPanel.setMessages(json.errors, json.warnings); |
d6ef146e1a9f
Added simple handling for Failure-Messages
Dustin Demuth <dustin@intevation.de>
parents:
644
diff
changeset
|
73 } |
d6ef146e1a9f
Added simple handling for Failure-Messages
Dustin Demuth <dustin@intevation.de>
parents:
644
diff
changeset
|
74 |
d6ef146e1a9f
Added simple handling for Failure-Messages
Dustin Demuth <dustin@intevation.de>
parents:
644
diff
changeset
|
75 if(json.message){ |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
76 Ext.Msg.alert(i18n.getMsg('err.msg.save.title') |
701
f0bc5387abcc
Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents:
695
diff
changeset
|
77 +' #'+json.message, |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
78 i18n.getMsg(json.message)); |
701
f0bc5387abcc
Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents:
695
diff
changeset
|
79 } else { |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
80 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'), |
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
81 i18n.getMsg('err.msg.generic.body')); |
695
d6ef146e1a9f
Added simple handling for Failure-Messages
Dustin Demuth <dustin@intevation.de>
parents:
644
diff
changeset
|
82 } |
701
f0bc5387abcc
Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents:
695
diff
changeset
|
83 } else { |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
84 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'), |
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
85 i18n.getMsg('err.msg.response.body')); |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 }); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 }, |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
91 /** |
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
92 * The discard function resets the Location form |
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
93 * to its original state. |
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
94 */ |
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
95 discard: function(button) { |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 var formPanel = button.up('form'); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 }, |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 |
1013
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
100 /** |
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
101 * The dirtyForm function enables or disables the save and discard |
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
102 * button which are present in the toolbar of the form. |
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
103 * The Buttons are only active if the content of the form was altered |
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
104 * (the form is dirty). |
75ce503ab296
Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents:
972
diff
changeset
|
105 */ |
603
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 dirtyForm: function(form, dirty) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 if (dirty) { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 form.owner.down('button[action=save]').setDisabled(false); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 form.owner.down('button[action=discard]').setDisabled(false); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 else { |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 form.owner.down('button[action=save]').setDisabled(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 form.owner.down('button[action=discard]').setDisabled(true); |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 } |
9d0113bc2f70
Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 }); |