annotate app/controller/form/Ortszuordnung.js @ 1338:d2f06ce4d43a

Use service and widget instead of local store for OrtszuordnungTyp.
author Tom Gottfried <tom@intevation.de>
date Fri, 03 Feb 2017 18:01:25 +0100
parents f879c806f880
children 1a2cd9bef6d7
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({
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
20 'ortszuordnungform button[action=setOrt]': {
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
21 toggle: this.chooseLocation
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
22 },
1013
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 972
diff changeset
23 'ortszuordnungform button[action=save]': {
603
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 click: this.save
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 },
1328
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
26 'ortszuordnungform button[action=revert]': {
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
27 click: this.revert
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
28 },
1013
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 972
diff changeset
29 'ortszuordnungform': {
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
30 validitychange: this.validityChange,
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
31 dirtychange: this.validityChange
603
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 },
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 704
diff changeset
36 /**
972
24b5684d74d7 Set letzteAenderung in a Bunch of controllers.
Dustin Demuth <dustin@intevation.de>
parents: 742
diff changeset
37 * 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
38 * On success it will reload the Store,
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 704
diff changeset
39 * on failure, it will display an Errormessage
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 704
diff changeset
40 */
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 704
diff changeset
41 save: function(button) {
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
42
1022
6d33a84979e4 More work on the Ortszuordnung grid. Saving does not work yet
Dustin Demuth <dustin@intevation.de>
parents: 1021
diff changeset
43 var formPanel = button.up('ortszuordnungform');
6d33a84979e4 More work on the Ortszuordnung grid. Saving does not work yet
Dustin Demuth <dustin@intevation.de>
parents: 1021
diff changeset
44
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
45 //try to disable ortPickerButton:
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
46 try {
1022
6d33a84979e4 More work on the Ortszuordnung grid. Saving does not work yet
Dustin Demuth <dustin@intevation.de>
parents: 1021
diff changeset
47 formPanel.down('button[action=setOrt]').toggle(false);
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
48 }
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
49 catch (e) {
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
50 }
1289
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
51 var data = formPanel.getForm().getFieldValues(false);
1013
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 972
diff changeset
52 var i18n = Lada.getApplication().bundle;
1289
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
53 var recordData = formPanel.getForm().getRecord().data;
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
54 if (recordData['probeId'] !== undefined) {
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
55 // TODO: as model.ort.ortId and model.ortszuordnung.ortId coexist,
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
56 // but mean different things, data.ortId is an array here, of
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
57 // which we need the first entry
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
58 recordData.ortId = data.ortId[0];
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
59 recordData.ortszuordnungTyp = data.ortszuordnungTyp;
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
60 } else { //messprogramm
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
61 recordData.ortsTyp = data.ortsTyp;
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
62 recordData.ort = data.ort;
603
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 }
1289
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
64 recordData.ortszusatztext = data.ortszusatztext;
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
65 if (!data.letzteAenderung) {
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
66 recordData.letzteAenderung = new Date();
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
67 } else {
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
68 recordData.letzteAenderung = data.letzteAenderung;
972
24b5684d74d7 Set letzteAenderung in a Bunch of controllers.
Dustin Demuth <dustin@intevation.de>
parents: 742
diff changeset
69 }
603
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 formPanel.getForm().getRecord().save({
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 success: function(record, response) {
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 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
73 if (json) {
603
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 button.setDisabled(true);
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 formPanel.clearMessages();
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 formPanel.setRecord(record);
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 formPanel.setMessages(json.errors, json.warnings);
1134
f1d21e6a7449 Fixed adding new ortszuortnung for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1028
diff changeset
78 formPanel.up('window').parentWindow.initData();
603
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 }
1022
6d33a84979e4 More work on the Ortszuordnung grid. Saving does not work yet
Dustin Demuth <dustin@intevation.de>
parents: 1021
diff changeset
80 //try to refresh the Grid of the Probe
6d33a84979e4 More work on the Ortszuordnung grid. Saving does not work yet
Dustin Demuth <dustin@intevation.de>
parents: 1021
diff changeset
81 try {
6d33a84979e4 More work on the Ortszuordnung grid. Saving does not work yet
Dustin Demuth <dustin@intevation.de>
parents: 1021
diff changeset
82 formPanel.up('window').parentWindow
6d33a84979e4 More work on the Ortszuordnung grid. Saving does not work yet
Dustin Demuth <dustin@intevation.de>
parents: 1021
diff changeset
83 .down('ortszuordnunggrid').store.reload();
6d33a84979e4 More work on the Ortszuordnung grid. Saving does not work yet
Dustin Demuth <dustin@intevation.de>
parents: 1021
diff changeset
84 }
6d33a84979e4 More work on the Ortszuordnung grid. Saving does not work yet
Dustin Demuth <dustin@intevation.de>
parents: 1021
diff changeset
85 catch (e) {
6d33a84979e4 More work on the Ortszuordnung grid. Saving does not work yet
Dustin Demuth <dustin@intevation.de>
parents: 1021
diff changeset
86
6d33a84979e4 More work on the Ortszuordnung grid. Saving does not work yet
Dustin Demuth <dustin@intevation.de>
parents: 1021
diff changeset
87 }
603
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 failure: function(record, response) {
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 button.setDisabled(true);
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 var json = response.request.scope.reader.jsonData;
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 if (json) {
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
94 if(Object.keys(json.errors).length > 0 ||
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
95 Object.keys(json.warnings).length > 0) {
695
d6ef146e1a9f Added simple handling for Failure-Messages
Dustin Demuth <dustin@intevation.de>
parents: 644
diff changeset
96 formPanel.setMessages(json.errors, json.warnings);
d6ef146e1a9f Added simple handling for Failure-Messages
Dustin Demuth <dustin@intevation.de>
parents: 644
diff changeset
97 }
d6ef146e1a9f Added simple handling for Failure-Messages
Dustin Demuth <dustin@intevation.de>
parents: 644
diff changeset
98 if(json.message){
1013
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 972
diff changeset
99 Ext.Msg.alert(i18n.getMsg('err.msg.save.title')
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 695
diff changeset
100 +' #'+json.message,
1013
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 972
diff changeset
101 i18n.getMsg(json.message));
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 695
diff changeset
102 } else {
1013
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 972
diff changeset
103 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'),
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 972
diff changeset
104 i18n.getMsg('err.msg.generic.body'));
695
d6ef146e1a9f Added simple handling for Failure-Messages
Dustin Demuth <dustin@intevation.de>
parents: 644
diff changeset
105 }
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 695
diff changeset
106 } else {
1013
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 972
diff changeset
107 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'),
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 972
diff changeset
108 i18n.getMsg('err.msg.response.body'));
603
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109 }
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 });
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 },
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113
1013
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 972
diff changeset
114 /**
1328
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
115 * reverts the form to the currently saved state
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
116 */
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
117 revert: function(button) {
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
118 var form = button.up('form');
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
119 var osg = button.up('window').down('ortstammdatengrid');
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
120 var recordData = form.getForm().getRecord().data;
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
121 var currentOrt = null;
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
122 if (recordData.ortId !== undefined) {
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
123 currentOrt = recordData.ortId;
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
124 } else {
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
125 currentOrt = recordData.ort;
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
126 }
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
127 var record = osg.store.getById(currentOrt);
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
128 var selmod = osg.getView().getSelectionModel();
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
129 form.getForm().reset();
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
130 var selmod = osg.getView().getSelectionModel();
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
131 selmod.select(record);
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
132 },
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
133
cf73b7d7cf99 reinserted discard button and functionality
Maximilian Krambach <mkrambach@intevation.de>
parents: 1327
diff changeset
134 /**
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
135 * When the button is Active, a Record can be selected.
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
136 * If the Record was selected from a grid this function
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
137 * sets the ortzuordnung.
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
138 */
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
139 chooseLocation: function(button, pressed, opts) {
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
140 var i18n = Lada.getApplication().bundle;
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
141 var win = button.up('window');
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
142 var gridPanel = win.down('panel[name=ortgrid]');
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
143 var osg = win.down('ortstammdatengrid');
1335
cba4e0b0e336 Fixed ort grid selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1328
diff changeset
144 var oForm = button.up('window').down('ortszuordnungform');
1289
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
145 osg.addListener('select',oForm.setOrt, oForm);
1293
16a80ca16732 map feature visibility, selection and grid layout
Maximilian Krambach <mkrambach@intevation.de>
parents: 1291
diff changeset
146 var map = win.down('map');
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
147 if (pressed) {
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
148 win.setHeight(Ext.getBody().getViewSize().height - 50);
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
149 button.setText(i18n.getMsg('ortszuordnung.form.setOrt.pressed'));
1293
16a80ca16732 map feature visibility, selection and grid layout
Maximilian Krambach <mkrambach@intevation.de>
parents: 1291
diff changeset
150 map.featureLayer.setVisibility(true);
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
151 win.setY(25);
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
152 gridPanel.show();
1336
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
153 var mstId = oForm.up('window').probe ? oForm.up('window').probe.get('mstId') :
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
154 oForm.up('window').messprogramm.get('mstId');
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
155 var mst = Ext.data.StoreManager.get('messstellen');
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
156 var ndx = mst.findExact('id', mstId);
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
157 var nId = mst.getAt(ndx).get('netzbetreiberId');
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
158 var store = Ext.create('Lada.store.Orte', {
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
159 defaultPageSize: 0,
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
160 listeners: {
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
161 beforeload: {
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
162 fn: function() {
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
163 osg.setLoading(true);
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
164 }
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
165 },
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
166 load: {
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
167 fn: function() {
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
168 osg.setLoading(false);
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
169 osg.setStore(store);
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
170 osg.store.filterBy(function(record) {
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
171 if (record.get('netzbetreiberId') ===
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
172 nId) {
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
173 return true;
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
174 }
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
175 });
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
176 }
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
177 }
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
178 }
f879c806f880 Create orte store for grid to have only orte with the correct netzbetreiberId
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1335
diff changeset
179 });
1293
16a80ca16732 map feature visibility, selection and grid layout
Maximilian Krambach <mkrambach@intevation.de>
parents: 1291
diff changeset
180 win.doLayout();
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
181 osg.addListener('select',oForm.setOrt, oForm);
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
182
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
183 }
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
184 else {
1293
16a80ca16732 map feature visibility, selection and grid layout
Maximilian Krambach <mkrambach@intevation.de>
parents: 1291
diff changeset
185 map.featureLayer.setVisibility(false);
16a80ca16732 map feature visibility, selection and grid layout
Maximilian Krambach <mkrambach@intevation.de>
parents: 1291
diff changeset
186 var y = (Ext.getBody().getViewSize().height - 465) / 2;
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
187 win.setHeight(465);
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
188 win.setY(y);
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
189 button.setText(i18n.getMsg('ortszuordnung.form.setOrt'));
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
190 gridPanel.hide();
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
191 osg.removeListener('select',oForm.setOrt, oForm);
1293
16a80ca16732 map feature visibility, selection and grid layout
Maximilian Krambach <mkrambach@intevation.de>
parents: 1291
diff changeset
192 oForm.doLayout();
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
193 }
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
194 },
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1147
diff changeset
195
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1013
diff changeset
196 /**
1291
e9f812528324 ortszuordnung form changes
Maximilian Krambach <mkrambach@intevation.de>
parents: 1289
diff changeset
197 * The validitychange function enables or disables the save button which
e9f812528324 ortszuordnung form changes
Maximilian Krambach <mkrambach@intevation.de>
parents: 1289
diff changeset
198 * is present in the toolbar of the form.
1013
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 972
diff changeset
199 */
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
200 validityChange: function(form, valid) {
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
201 if (form.isDirty()) {
1289
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
202 if (valid) {
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
203 if (form.getValues().ortId !== ''
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
204 && /[UEZA]/.test(form.getValues().ortszuordnungTyp)) {
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
205 // valid ortzuordnung(Probe)
1291
e9f812528324 ortszuordnung form changes
Maximilian Krambach <mkrambach@intevation.de>
parents: 1289
diff changeset
206 form.owner.down('button[action=save]').setDisabled(false);
1289
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
207 } else if (form.getValues().ort !== ''
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
208 && /[UEZA]/.test(form.getValues().ortsTyp)) {
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
209 // valid ortzuordnung(messprogramm)
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
210 form.owner.down('button[action=save]').setDisabled(false);
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
211 } else {
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
212 form.owner.down('button[action=save]').setDisabled(true);
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
213 }
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
214 } else {
1289
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
215 //invalid
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
216 form.owner.down('button[action=save]').setDisabled(true);
1144
5ceb0381ae73 Set a regex and required for ortszuordnungstyp field.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1134
diff changeset
217 }
1288
08085b7d1d0b Ortszuordnung: Search, new orte, display and validity check
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
218 } else {
1289
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
219 //not dirty
bfdc00c24baf Ortszuordnung for messprogramm and probe using same form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1288
diff changeset
220 form.owner.down('button[action=save]').setDisabled(true);
603
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
221 }
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
222 }
9d0113bc2f70 Added ort form and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
223 });

http://lada.wald.intevation.org