annotate app/controller/Proben.js @ 381:9bc080ecdbc9

Added action in controller to download the file in a new window.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Tue, 27 Aug 2013 10:40:14 +0200
parents 0fa48c66cf7d
children 91193c49c2bb
rev   line source
293
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
1 /**
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
2 * Controller for Proben
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
3 */
379
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
4
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
5 function buildImportReport(filename, msg, errors, warnings) {
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
6 var out = Array();
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
7 if (msg != 200) {
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
8 out.push("Der Import der Datei " + filename + " war nicht erfolgreich.");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
9 out.push("Bei dem Import sind folgende Fehler und Warnungen aufgetreten");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
10 out.push("<br/>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
11 out.push("<strong>Fehler:</strong>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
12 out.push("<br/>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
13 if (errors) {
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
14 out.push("<ol>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
15 for (var key in errors) {
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
16 out.push("<li>"+key+"</li>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
17 }
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
18 out.push("</ol>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
19 } else {
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
20 out.push("Keine Fehler");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
21 out.push("<br/>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
22 }
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
23 out.push("<strong>Warnungen:</strong>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
24 out.push("<br/>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
25 if (warnings) {
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
26 out.push("<ol>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
27 for (var key in warnings) {
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
28 out.push("<li>"+key+"</li>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
29 }
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
30 out.push("</ol>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
31 } else {
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
32 out.push("Keine Warnungen");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
33 out.push("<br/>");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
34 }
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
35 } else {
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
36 out.push("Der Import der Datei " + filename + " war erfolgreich.");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
37 }
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
38 return out.join("");
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
39 }
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
40
1
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
41 Ext.define('Lada.controller.Proben', {
293
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
42 extend: 'Lada.controller.Base',
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
43 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
44 'proben.Edit',
357
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
45 'proben.Create',
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
46 'proben.Import'
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
47 ],
13
a8efc4b96888 Added model for Proben and a Store.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 5
diff changeset
48 stores: [
122
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 121
diff changeset
49 '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
50 'Zusatzwerte',
144
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
51 'Probenzusatzwerte',
149
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
52 'Kommentare',
157
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
53 'Orte',
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
54 'Messungen'
13
a8efc4b96888 Added model for Proben and a Store.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 5
diff changeset
55 ],
1
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
56 init: function() {
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
57 console.log('Initialising the Proben controller');
293
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
58 this.callParent();
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
59 },
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
60 addListeners: function() {
1
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
61 this.control({
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
62 'probenlist': {
293
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
63 itemdblclick: this.editItem
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
64 },
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
65 'probenlist toolbar button[action=add]': {
293
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
66 click: this.addItem
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
67 },
357
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
68 'probenlist toolbar button[action=import]': {
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
69 click: this.selectUploadFile
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
70 },
381
9bc080ecdbc9 Added action in controller to download the file in a new window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 379
diff changeset
71 'probenlist toolbar button[action=export]': {
9bc080ecdbc9 Added action in controller to download the file in a new window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 379
diff changeset
72 click: this.downloadFile
9bc080ecdbc9 Added action in controller to download the file in a new window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 379
diff changeset
73 },
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
74 'probencreate button[action=save]': {
293
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
75 click: this.saveItem
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
76 },
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
77 'probenedit button[action=save]': {
293
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
78 click: this.saveItem
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
79 },
357
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
80 'probenimport button[action=save]': {
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
81 click: this.uploadItem
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
82 },
70
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
83 'probencreate form': {
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
84 savesuccess: this.createSuccess,
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
85 savefailure: this.createFailure
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
86 },
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
87 'probenedit form': {
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
88 savesuccess: this.editSuccess,
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
89 savefailure: this.editFailure
1
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
90 }
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
91 });
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
92 },
293
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
93 addItem: 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
94 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
95 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
96 },
357
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
97 /**
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
98 * Opens a window with a file chooser to select the file to upload
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
99 * @private
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
100 */
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
101 selectUploadFile: function(button) {
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
102 console.log('Importing');
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
103 var view = Ext.widget('probenimport');
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
104 },
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
105 /** Uploads the selected file the the server
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
106 * @private
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
107 */
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
108 uploadItem: function(button) {
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
109 var win = button.up('window');
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
110 var form = win.down('form');
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
111 if(form.isValid()){
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
112 form.submit({
376
90cec3bb9c09 Updated URL for import service.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
113 url: 'server/rest/import/laf',
357
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
114 waitMsg: 'Importiere...',
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
115 // TODO: Handle the response correct. o must must contain the
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
116 // filename (None) <2013-08-13 16:17>
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
117 success: function(fp, resp) {
379
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
118 var filename = resp.result.data[2].filename;
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
119 Ext.Msg.alert('Erfolg! ', 'Die Datei "' + filename + '" wurde erfolgreich importiert.');
357
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
120 win.close();
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
121 },
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
122 failure: function(fp, resp) {
379
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
123 var errors = resp.result.data[0];
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
124 var warnings = resp.result.data[1];
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
125 var filename = resp.result.data[2].filename;
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
126 var message = resp.message;
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
127 var dialogbody = buildImportReport(filename, message, errors.parser, warnings)
0fa48c66cf7d Set first version of a report of the import.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 376
diff changeset
128 Ext.Msg.alert('Fehler', dialogbody);
357
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
129 win.close();
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
130 }
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
131 });
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
132 }
94884cd8f8c0 Added logic to upload a file to the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 293
diff changeset
133 },
381
9bc080ecdbc9 Added action in controller to download the file in a new window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 379
diff changeset
134 /**
9bc080ecdbc9 Added action in controller to download the file in a new window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 379
diff changeset
135 * Will download the selected Probe in LAF format in a new window (tab).
9bc080ecdbc9 Added action in controller to download the file in a new window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 379
diff changeset
136 */
9bc080ecdbc9 Added action in controller to download the file in a new window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 379
diff changeset
137 downloadFile: function(button) {
9bc080ecdbc9 Added action in controller to download the file in a new window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 379
diff changeset
138 var grid = button.up('grid');
9bc080ecdbc9 Added action in controller to download the file in a new window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 379
diff changeset
139 var selection = grid.getView().getSelectionModel().getSelection()[0];
9bc080ecdbc9 Added action in controller to download the file in a new window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 379
diff changeset
140 var url = "server/rest/export/laf/" + selection.get('probeId');
9bc080ecdbc9 Added action in controller to download the file in a new window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 379
diff changeset
141 window.open(url, "_blank");
9bc080ecdbc9 Added action in controller to download the file in a new window.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 379
diff changeset
142 },
293
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
143 editItem: 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
144 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
145 var id = record.get('probeId');
122
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 121
diff changeset
146 // 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
147 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
148 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
149 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
150 zstore.load({
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 121
diff changeset
151 params: {
139
df6e36dd57ee Changed params probe -> probeId, mst -> mstId, uwb -> umwId
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 135
diff changeset
152 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
153 }
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 121
diff changeset
154 });
149
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
155 // Load Kommentare
144
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
156 var kstore = this.getKommentareStore();
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
157 kstore.load({
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
158 params: {
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
159 probeId: id
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
160 }
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 141
diff changeset
161 });
149
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
162 // Load Orte
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
163 var ostore = this.getOrteStore();
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
164 ostore.load({
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
165 params: {
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
166 probeId: id
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
167 }
26ac4c99f8c4 Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 144
diff changeset
168 });
157
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
169 // Load Orte
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
170 var mstore = this.getMessungenStore();
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
171 mstore.load({
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
172 params: {
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
173 probeId: id
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
174 }
237a4efe715a Enabled loading Messungen.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 149
diff changeset
175 });
362
6a7a9267e00f Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 357
diff changeset
176 var view = Ext.widget('probenedit', {modelId: id});
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
177 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
178 },
255
82118c01bc52 #57: Open Edit-Dialog after creating a new Probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 157
diff changeset
179 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
180 // Close Createdialog
69
cb1138f5cea7 Removed old code
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 65
diff changeset
181 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
182 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
183 // 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
184 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
185 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
186 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
187 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
188 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
189 // 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
190 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
191 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
192 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
193 var probe = store.findRecord("probeId", probeId);
293
bd77b6055791 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
194 this.editItem(null, probe);
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
195 }
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
196 }
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
197 });
70
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
198 },
255
82118c01bc52 #57: Open Edit-Dialog after creating a new Probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 157
diff changeset
199 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
200 // Reload store
eb40b74f871a Reload the store after the probe was created or edited.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 76
diff changeset
201 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
202 store.reload();
70
1a943947a7d2 Added new listeners for events comming from the Probenforms.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 69
diff changeset
203 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
204 win.close();
1
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
205 }
af8d7217521d Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
206 });

http://lada.wald.intevation.org