annotate app/controller/Proben.js @ 290:fe51239321d9

Inherit from Base controller
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 09 Aug 2013 15:00:06 +0200
parents 0d6552bb28ea
children bd77b6055791
rev   line source
1
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
1 Ext.define('Lada.controller.Proben', {
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
2 extend: 'Ext.app.Controller',
4
b8e56e880f02 Added a first example view (userlisting) from the EXJS Tutorial. Need to be
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 1
diff changeset
3 views: [
65
9e2e09e819fd Added a new Dialog to create proben without any kommentare or other additional
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 64
diff changeset
4 'proben.Edit',
9e2e09e819fd Added a new Dialog to create proben without any kommentare or other additional
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 64
diff changeset
5 'proben.Create'
4
b8e56e880f02 Added a first example view (userlisting) from the EXJS Tutorial. Need to be
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 1
diff changeset
6 ],
13
a8efc4b96888 Added model for Proben and a Store.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 5
diff changeset
7 stores: [
122
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 121
diff changeset
8 'Proben',
135
e80a9114524c Load Probenzusatzwerte on editing a Probe. Values are needed in the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 122
diff changeset
9 'Zusatzwerte',
144
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
10 'Probenzusatzwerte',
149
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
11 'Kommentare',
157
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
12 'Orte',
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
13 'Messungen'
13
a8efc4b96888 Added model for Proben and a Store.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 5
diff changeset
14 ],
1
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
15 init: function() {
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
16 console.log('Initialising the Proben controller');
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
17 this.control({
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
18 // CSS like selector to select element in the viewport. See
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
19 // ComponentQuery documentation for more details.
18
9e1a40312bbe Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 13
diff changeset
20 'probenlist': {
5
039584709fa7 Map double click event on rows of the userlist to the editProben function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 4
diff changeset
21 itemdblclick: this.editProbe
18
9e1a40312bbe Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 13
diff changeset
22 },
64
a4a24e737deb Added listener to open a new window to enter data fpr the new probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 54
diff changeset
23 'probenlist toolbar button[action=add]': {
a4a24e737deb Added listener to open a new window to enter data fpr the new probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 54
diff changeset
24 click: this.addProbe
a4a24e737deb Added listener to open a new window to enter data fpr the new probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 54
diff changeset
25 },
270
0d6552bb28ea Add cancel Button to the editproben window and only show save button if the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 256
diff changeset
26 'probencreate button[action=save]': {
0d6552bb28ea Add cancel Button to the editproben window and only show save button if the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 256
diff changeset
27 click: this.saveProbe
0d6552bb28ea Add cancel Button to the editproben window and only show save button if the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 256
diff changeset
28 },
0d6552bb28ea Add cancel Button to the editproben window and only show save button if the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 256
diff changeset
29 'probenedit button[action=save]': {
0d6552bb28ea Add cancel Button to the editproben window and only show save button if the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 256
diff changeset
30 click: this.saveProbe
0d6552bb28ea Add cancel Button to the editproben window and only show save button if the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 256
diff changeset
31 },
70
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
32 'probencreate form': {
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
33 savesuccess: this.createSuccess,
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
34 savefailure: this.createFailure
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
35 },
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
36 'probenedit form': {
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
37 savesuccess: this.editSuccess,
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
38 savefailure: this.editFailure
1
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
39 }
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
40 });
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
41 },
270
0d6552bb28ea Add cancel Button to the editproben window and only show save button if the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 256
diff changeset
42 saveProbe: function(button) {
0d6552bb28ea Add cancel Button to the editproben window and only show save button if the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 256
diff changeset
43 console.log('Saving Probe');
0d6552bb28ea Add cancel Button to the editproben window and only show save button if the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 256
diff changeset
44 var form = button.up('window').down('form');
0d6552bb28ea Add cancel Button to the editproben window and only show save button if the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 256
diff changeset
45 form.commit();
0d6552bb28ea Add cancel Button to the editproben window and only show save button if the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 256
diff changeset
46 },
64
a4a24e737deb Added listener to open a new window to enter data fpr the new probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 54
diff changeset
47 addProbe: function(button) {
71
db26aeebe521 Added new Form for editing proben. Use this form in the edit window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 70
diff changeset
48 console.log('Adding new Probe');
65
9e2e09e819fd Added a new Dialog to create proben without any kommentare or other additional
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 64
diff changeset
49 var view = Ext.widget('probencreate');
64
a4a24e737deb Added listener to open a new window to enter data fpr the new probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 54
diff changeset
50 },
5
039584709fa7 Map double click event on rows of the userlist to the editProben function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 4
diff changeset
51 editProbe: function(grid, record) {
71
db26aeebe521 Added new Form for editing proben. Use this form in the edit window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 70
diff changeset
52 console.log('Editing Probe');
db26aeebe521 Added new Form for editing proben. Use this form in the edit window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 70
diff changeset
53 var id = record.get('probeId');
db26aeebe521 Added new Form for editing proben. Use this form in the edit window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 70
diff changeset
54 var view = Ext.widget('probenedit', {modelId: id});
122
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 121
diff changeset
55
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 121
diff changeset
56 // Load Zusatzwerte
135
e80a9114524c Load Probenzusatzwerte on editing a Probe. Values are needed in the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 122
diff changeset
57 var pstore = this.getProbenzusatzwerteStore();
e80a9114524c Load Probenzusatzwerte on editing a Probe. Values are needed in the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 122
diff changeset
58 pstore.load();
122
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 121
diff changeset
59 var zstore = this.getZusatzwerteStore();
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 121
diff changeset
60 zstore.load({
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 121
diff changeset
61 params: {
139
df6e36dd57ee Changed params probe -> probeId, mst -> mstId, uwb -> umwId
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 135
diff changeset
62 probeId: id
122
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 121
diff changeset
63 }
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 121
diff changeset
64 });
149
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
65 // Load Kommentare
144
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
66 var kstore = this.getKommentareStore();
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
67 kstore.load({
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
68 params: {
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
69 probeId: id
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
70 }
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
71 });
149
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
72 // Load Orte
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
73 var ostore = this.getOrteStore();
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
74 ostore.load({
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
75 params: {
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
76 probeId: id
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
77 }
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
78 });
157
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
79 // Load Orte
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
80 var mstore = this.getMessungenStore();
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
81 mstore.load({
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
82 params: {
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
83 probeId: id
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
84 }
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
85 });
71
db26aeebe521 Added new Form for editing proben. Use this form in the edit window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 70
diff changeset
86 console.log("Loaded Probe with ID " + record.getId()); //outputs ID
18
9e1a40312bbe Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 13
diff changeset
87 },
255
82118c01bc52 #57: Open Edit-Dialog after creating a new Probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 157
diff changeset
88 createSuccess: function(form, record, response) {
256
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
89 // Close Createdialog
69
cb1138f5cea7 Removed old code
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 65
diff changeset
90 var win = form.up('window');
18
9e1a40312bbe Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 13
diff changeset
91 win.close();
256
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
92 // Reload store
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
93 var store = this.getProbenStore();
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
94 store.reload({
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
95 scope: this,
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
96 callback: function(records, operation, success) {
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
97 console.log('Reloaded store');
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
98 // Open Editdialog
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
99 var json = Ext.decode(response.responseText);
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
100 if (json) {
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
101 var probeId = json.data.probeId;
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
102 var probe = store.findRecord("probeId", probeId);
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
103 this.editProbe(null, probe);
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
104 }
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
105 }
d8993f5b96e8 Added a possible fix for issue57. After the create dialog is closed the edit
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
106 });
70
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
107 },
255
82118c01bc52 #57: Open Edit-Dialog after creating a new Probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 157
diff changeset
108 createFailure: function(form, record, response) {
70
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
109 Ext.MessageBox.show({
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
110 title: 'Fehler beim Speichern',
76
eb8a7d3cca89 Use translated message from server in error dialog
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 71
diff changeset
111 msg: form.message,
70
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
112 icon: Ext.MessageBox.ERROR,
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
113 buttons: Ext.Msg.OK
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
114 });
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
115 },
255
82118c01bc52 #57: Open Edit-Dialog after creating a new Probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 157
diff changeset
116 editSuccess: function(form, record, response) {
86
eb40b74f871a Reload the store after the probe was created or edited.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 76
diff changeset
117 // Reload store
eb40b74f871a Reload the store after the probe was created or edited.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 76
diff changeset
118 var store = this.getProbenStore();
eb40b74f871a Reload the store after the probe was created or edited.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 76
diff changeset
119 store.reload();
70
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
120 var win = form.up('window');
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
121 win.close();
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
122 },
255
82118c01bc52 #57: Open Edit-Dialog after creating a new Probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 157
diff changeset
123 editFailure: function(form, record, response) {
70
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
124 Ext.MessageBox.show({
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
125 title: 'Fehler beim Speichern',
76
eb8a7d3cca89 Use translated message from server in error dialog
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 71
diff changeset
126 msg: form.message,
70
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
127 icon: Ext.MessageBox.ERROR,
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
128 buttons: Ext.Msg.OK
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
129 });
1
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
130 }
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
131 });

http://lada.wald.intevation.org