Mercurial > lada > lada-client
annotate app/controller/grid/ProbeList.js @ 1257:9a428be3907b
add action button in Messung grid and Ortszuordnung grid
author | Michael Stanko <mstanko@bfs.de> |
---|---|
date | Mon, 21 Nov 2016 08:07:54 +0100 |
parents | f961f94495c8 |
children | d19170280a23 |
rev | line source |
---|---|
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
3 * |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
7 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
8 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
9 /** |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
10 * Controller for the ProbeList result grid. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
11 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
12 Ext.define('Lada.controller.grid.ProbeList', { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
13 extend: 'Ext.app.Controller', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
14 requires: [ |
1227
848b50a4a4eb
Add missing requirements.
Tom Gottfried <tom@intevation.de>
parents:
1164
diff
changeset
|
15 'Lada.view.window.FileUpload', |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
16 'Lada.view.window.ProbeEdit', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
17 'Lada.view.window.GenProbenFromMessprogramm' |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
18 ], |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
19 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
20 /** |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
21 * Initialize the Controller with listeners |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
22 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
23 init: function() { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
24 this.control({ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
25 'probelistgrid': { |
977
56470a075e6e
Added methods to the controllers to disable/enable buttons in the toolbar when rows are (de)selected
Dustin Demuth <dustin@intevation.de>
parents:
975
diff
changeset
|
26 itemdblclick: this.editItem, |
56470a075e6e
Added methods to the controllers to disable/enable buttons in the toolbar when rows are (de)selected
Dustin Demuth <dustin@intevation.de>
parents:
975
diff
changeset
|
27 select: this.activateButtons, |
56470a075e6e
Added methods to the controllers to disable/enable buttons in the toolbar when rows are (de)selected
Dustin Demuth <dustin@intevation.de>
parents:
975
diff
changeset
|
28 deselect: this.deactivateButtons |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
29 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
30 'probelistgrid toolbar button[action=addProbe]': { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
31 click: this.addProbeItem |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
32 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
33 'probelistgrid toolbar button[action=import]': { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
34 click: this.uploadFile |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
35 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
36 'probelistgrid toolbar button[action=export]': { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
37 click: this.downloadFile |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
38 }, |
1244
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
39 'probelistgrid toolbar button[action=printSheet]': { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
40 click: { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
41 fn: this.printSelection, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
42 mode: 'printsheet' |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
43 } |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
44 }, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
45 'probelistgrid toolbar button[action=printExtract]': { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
46 click: { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
47 fn: this.printSelection, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
48 mode: 'printextract' |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
49 } |
1111
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
50 }, |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
51 'probelistgrid gridview': { |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
52 expandbody: this.expandBody, |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
53 collapsebody: this.collapseBody |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
54 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
55 }); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
56 this.callParent(arguments); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
57 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
58 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
59 /** |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
60 * This function is called after a Row in the |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
61 * {@link Lada.view.grid.ProbeList} |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
62 * was double-clicked. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
63 * The function opens a {@link Lada.view.window.ProbeEdit} |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
64 * or a {@link Lada.view.window.Messprogramm}. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
65 * To determine which window has to be opened, the function |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
66 * analyse the records modelname. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
67 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
68 editItem: function(grid, record) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
69 var winname = 'Lada.view.window.ProbeEdit'; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
70 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
71 var win = Ext.create(winname, { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
72 record: record, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
73 style: 'z-index: -1;' //Fixes an Issue where windows could not be created in IE8 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
74 }); |
1164
f43635937581
Open Probe always on the left side of the window and Messung on the right side
Evi Huber <ehuber@bfs.de>
parents:
1111
diff
changeset
|
75 win.setPosition(30); |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
76 win.show(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
77 win.initData(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
78 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
79 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
80 /** |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
81 * This function opens a new window to create a Probe |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
82 * {@link Lada.view.window.ProbeCreate} |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
83 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
84 addProbeItem: function() { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
85 var win = Ext.create('Lada.view.window.ProbeCreate'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
86 win.show(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
87 win.initData(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
88 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
89 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
90 /** |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
91 * This function opens a {@link Lada.view.window.FileUpload} |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
92 * window to upload a LAF-File |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
93 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
94 uploadFile: function() { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
95 var win = Ext.create('Lada.view.window.FileUpload', { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
96 title: 'Datenimport', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
97 modal: true |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
98 }); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
99 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
100 win.show(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
101 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
102 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
103 /** |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
104 * This function can be used to Download the items which |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
105 * were selected in the {@link Lada.view.grid.ProbeList} |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
106 * The Download does not work with Internet Explorers older than v.10 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
107 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
108 downloadFile: function(button) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
109 var grid = button.up('grid'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
110 var selection = grid.getView().getSelectionModel().getSelection(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
111 var i18n = Lada.getApplication().bundle; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
112 var proben = []; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
113 for (var i = 0; i < selection.length; i++) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
114 proben.push(selection[i].get('id')); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
115 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
116 var me = this; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
117 Ext.Ajax.request({ |
999 | 118 url: 'lada-server/data/export/laf', |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
119 jsonData: {'proben': proben}, |
1246
a7dc14e3b976
Increased timeout for probe export request.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1244
diff
changeset
|
120 timeout: 2 * 60 * 1000, |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
121 success: function(response) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
122 var content = response.responseText; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
123 var blob = new Blob([content],{type: 'text/plain'}); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
124 saveAs(blob, 'export.laf'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
125 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
126 failure: function(response) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
127 /* |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
128 SSO will send a 302 if the Client is not authenticated |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
129 unfortunately this seems to be filtered by the browser. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
130 We assume that a 302 was send when the follwing statement |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
131 is true. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
132 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
133 if (response.status == 0 && response.responseText === "") { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
134 Ext.MessageBox.confirm('Erneutes Login erforderlich', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
135 'Ihre Session ist abgelaufen.<br/>'+ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
136 'Für ein erneutes Login muss die Anwendung neu geladen werden.<br/>' + |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
137 'Alle ungesicherten Daten gehen dabei verloren.<br/>' + |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
138 'Soll die Anwendung jetzt neu geladen werden?', this.reload); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
139 } else { |
1256
f961f94495c8
Remove erroneous error handling.
Tom Gottfried <tom@intevation.de>
parents:
1246
diff
changeset
|
140 // further error handling |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
141 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
142 i18n.getMsg('err.msg.laf.filecreatefailed')); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
143 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
144 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
145 }); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
146 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
147 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
148 /** |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
149 * Send the selection to a Printservice |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
150 */ |
1244
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
151 printSelection: function(button, e, eOpts) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
152 switch (eOpts.mode) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
153 case "printextract" : |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
154 var printData = this.createExtractData(button); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
155 this.printpdf(printData, 'lada_print', 'lada-print.pdf', button); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
156 break; |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
157 case "printsheet" : |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
158 // The Data is loaded from the server again, so we need |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
159 // to be a little bit asynchronous here... |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
160 callback = function(response) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
161 var data = response.responseText; |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
162 var printData = '{"layout": "A4 portrait", "outputFormat": "pdf",' |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
163 + '"attributes": { "proben": ' + data |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
164 + '}}'; |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
165 this.printpdf(printData, 'lada_erfassungsbogen', |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
166 'lada-erfassungsbogen.pdf', button); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
167 } |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
168 |
1244
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
169 this.createSheetData(button, callback, this); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
170 break; |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
171 } |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
172 }, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
173 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
174 /** |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
175 * Toggles the buttons in the toolbar |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
176 **/ |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
177 activateButtons: function(rowModel, record) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
178 var grid = rowModel.view.up('grid'); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
179 this.buttonToggle(true, grid); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
180 }, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
181 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
182 /** |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
183 * Toggles the buttons in the toolbar |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
184 **/ |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
185 deactivateButtons: function(rowModel, record) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
186 var grid = rowModel.view.up('grid'); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
187 // Only disable buttons when nothing is selected |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
188 if (rowModel.selected.items == 0) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
189 this.buttonToggle(false, grid); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
190 } |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
191 }, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
192 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
193 /** |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
194 * Enables/Disables a set of buttons |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
195 **/ |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
196 buttonToggle: function(enabled, grid) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
197 if (!enabled) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
198 grid.down('button[action=export]').disable(); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
199 grid.down('button[action=printExtract]').disable(); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
200 grid.down('button[action=printSheet]').disable(); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
201 } |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
202 else { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
203 grid.down('button[action=export]').enable(); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
204 grid.down('button[action=printExtract]').enable(); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
205 grid.down('button[action=printSheet]').enable(); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
206 } |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
207 }, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
208 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
209 reload: function(btn) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
210 if (btn === 'yes') { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
211 location.reload(); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
212 } |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
213 }, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
214 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
215 expandBody: function(rowNode, record, expandRow) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
216 // var row = Ext.get('probe-row-' + record.get('id')); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
217 // var messungGrid = Ext.create('Lada.view.grid.Messung', { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
218 // recordId: record.get('id'), |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
219 // bottomBar: false, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
220 // rowLines: true |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
221 // }); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
222 // row.swallowEvent(['click', 'mousedown', 'mouseup', 'dblclick'], true); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
223 // messungGrid.render(row); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
224 }, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
225 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
226 collapseBody: function(rowNode, record, expandRow) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
227 // var element = Ext.get('probe-row-' + record.get('id')).down('div'); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
228 // element.destroy(); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
229 }, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
230 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
231 /** |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
232 * Returns a Json-Object whcih contains the data which has |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
233 * to be printed. |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
234 * The parameter printFunctionCallback will be called once the ajax-request |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
235 * starting the json-export was evaluated |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
236 **/ |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
237 createSheetData: function(button, printFunctionCallback, cbscope){ |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
238 //disable Button and setLoading... |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
239 // TODO ACTIVATE! |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
240 //button.disable(); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
241 //button.setLoading(true); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
242 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
243 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
244 // get Selected Items. |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
245 var grid = button.up('grid'); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
246 var selection = grid.getView().getSelectionModel().getSelection(); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
247 var i18n = Lada.getApplication().bundle; |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
248 var me = this; |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
249 var ids = []; |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
250 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
251 for (item in selection) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
252 ids.push(selection[item].data['id']); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
253 } |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
254 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
255 //basically, thats the same as the downloadFile |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
256 // code does. |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
257 var data = '{ "proben": ['+ids.toString()+'] }'; |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
258 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
259 Ext.Ajax.request({ |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
260 url: 'lada-server/data/export/json', |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
261 jsonData: data, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
262 binary: false, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
263 scope: cbscope, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
264 success: printFunctionCallback, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
265 failure: function(response) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
266 console.log('failure'); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
267 // Error handling |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
268 // TODO |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
269 console.log(response.responseText) |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
270 button.enable(); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
271 button.setLoading(false); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
272 // This is "copy & waste-code" from downloadFile |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
273 // FIXME |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
274 /* |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
275 SSO will send a 302 if the Client is not authenticated |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
276 unfortunately this seems to be filtered by the browser. |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
277 We assume that a 302 was send when the follwing statement |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
278 is true. |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
279 */ |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
280 if (response.status == 0 && response.responseText === "") { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
281 Ext.MessageBox.confirm(Lada.getApplication().bundle.getMsg('err.msg.sso.expired.title'), |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
282 Lada.getApplication().bundle.getMsg('err.msg.sso.expired.body'), |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
283 this.reload); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
284 } |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
285 // further error handling |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
286 var json = Ext.JSON.decode(response.responseText); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
287 if (json) { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
288 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
289 formPanel.setMessages(json.errors, json.warnings); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
290 } |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
291 if(json.message){ |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
292 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
293 +' #'+json.message, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
294 Lada.getApplication().bundle.getMsg(json.message)); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
295 } else { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
296 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
297 i18n.getMsg('err.msg.print.failed')); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
298 } |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
299 } else { |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
300 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
301 i18n.getMsg('err.msg.print.failed')); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
302 } |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
303 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
304 return null; |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
305 } |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
306 }); |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
307 }, |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
308 |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
309 /** |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
310 * Returns a Json-Object whcih contains the data which has |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
311 * to be printed. |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
312 **/ |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
313 createExtractData: function(button){ |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
314 //disable Button and setLoading... |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
315 button.disable(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
316 button.setLoading(true); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
317 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
318 var grid = button.up('grid'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
319 var selection = grid.getView().getSelectionModel().getSelection(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
320 var i18n = Lada.getApplication().bundle; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
321 var me = this; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
322 var columns = []; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
323 var columnNames = []; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
324 var visibleColumns = []; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
325 var displayName = ''; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
326 var data = []; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
327 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
328 // Write the columns to an array |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
329 try { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
330 for (key in selection[0].data) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
331 // Do not write owner or readonly or id |
1082
dbd435256f77
Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
999
diff
changeset
|
332 if (["owner", "readonly", "id", "probeId"].indexOf(key) == -1){ |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
333 columns.push(key); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
334 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
335 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
336 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
337 catch (e) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
338 console.log(e); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
339 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
340 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
341 //Retrieve visible columns' id's and names. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
342 // and set displayName |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
343 try { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
344 var grid = button.up('grid'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
345 var cman = grid.columnManager; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
346 var cols = cman.getColumns(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
347 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
348 displayName = grid.down('tbtext').text; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
349 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
350 for (key in cols) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
351 if (cols[key].dataIndex) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
352 visibleColumns[cols[key].dataIndex] = cols[key].text; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
353 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
354 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
355 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
356 catch (e) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
357 console.log(e); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
358 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
359 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
360 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
361 // Retrieve Data from selection |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
362 try { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
363 for (item in selection) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
364 var row = selection[item].data; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
365 var out = []; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
366 //Lookup every column and write to data array. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
367 for (key in columns){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
368 var attr = columns[key]; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
369 //Only write data to output when the column is not hidden. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
370 if (row[attr] != null && |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
371 visibleColumns[attr] != null) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
372 out.push(row[attr].toString()); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
373 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
374 else if (visibleColumns[attr] != null) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
375 out.push(''); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
376 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
377 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
378 data.push(out); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
379 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
380 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
381 catch (e){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
382 console.log(e); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
383 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
384 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
385 //Retrieve the names of the columns. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
386 try { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
387 var grid = button.up('grid'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
388 var cman = grid.columnManager; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
389 var cols = cman.getColumns(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
390 //Iterate columns and find column names for the key... |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
391 // This WILL run into bad behaviour when column-keys exist twice. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
392 for (key in columns){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
393 for (k in cols){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
394 if (cols[k].dataIndex == columns[key]){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
395 columnNames.push(cols[k].text); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
396 break; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
397 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
398 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
399 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
400 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
401 catch (e) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
402 console.log(e); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
403 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
404 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
405 var printData = { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
406 'layout': 'A4 landscape', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
407 'outputFormat': 'pdf', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
408 'attributes': { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
409 'title': 'Auszug aus LADA', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
410 'displayName': displayName, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
411 'table': { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
412 'columns': columnNames, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
413 'data': data |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
414 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
415 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
416 } |
1244
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
417 return printData; |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
418 }, |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
419 |
1244
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
420 /** |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
421 * this function uses an AJAX request in order to |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
422 * send the data to the endpoint of the mapfish-print |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
423 */ |
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
424 printpdf: function(data, endpoint, filename, button){ |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
425 Ext.Ajax.request({ |
1244
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
426 url: 'lada-printer/'+endpoint+'/buildreport.pdf', |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
427 //configure a proxy in apache conf! |
1244
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
428 jsonData: data, |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
429 binary: true, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
430 success: function(response) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
431 var content = response.responseBytes; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
432 var filetype = response.getResponseHeader('Content-Type'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
433 var blob = new Blob([content],{type: filetype}); |
1244
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
434 saveAs(blob, filename); |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
435 button.enable(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
436 button.setLoading(false); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
437 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
438 failure: function(response) { |
1244
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
439 var i18n = Lada.getApplication().bundle; |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
440 console.log('failure'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
441 // Error handling |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
442 // TODO |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
443 //console.log(response.responseText) |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
444 button.enable(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
445 button.setLoading(false); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
446 if (response.responseText) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
447 try { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
448 var json = Ext.JSON.decode(response.responseText); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
449 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
450 catch(e){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
451 console.log(e); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
452 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
453 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
454 if (json) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
455 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
456 formPanel.setMessages(json.errors, json.warnings); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
457 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
458 if(json.message){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
459 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
460 +' #'+json.message, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
461 Lada.getApplication().bundle.getMsg(json.message)); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
462 } else { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
463 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
464 i18n.getMsg('err.msg.print.noContact')); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
465 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
466 } else { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
467 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
468 i18n.getMsg('err.msg.print.noContact')); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
469 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
470 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
471 }); |
1244
d391f055022e
WIP Added Erfassungsbogen-Druck
Dustin Demuth <dustin@intevation.de>
parents:
1227
diff
changeset
|
472 } |
977
56470a075e6e
Added methods to the controllers to disable/enable buttons in the toolbar when rows are (de)selected
Dustin Demuth <dustin@intevation.de>
parents:
975
diff
changeset
|
473 |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
474 }); |