Mercurial > lada > lada-client
annotate app/controller/grid/ProbeList.js @ 1235:d1f43f1e7e84
Fix setting Netzbetreiber in Messprogramm.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 31 Oct 2016 10:05:10 +0100 |
parents | 848b50a4a4eb |
children | d391f055022e |
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 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
39 'probelistgrid toolbar button[action=print]': { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
40 click: this.printSelection |
1111
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
41 }, |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
42 '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
|
43 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
|
44 collapsebody: this.collapseBody |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
45 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
46 }); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
47 this.callParent(arguments); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
48 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
49 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
50 /** |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
51 * This function is called after a Row in the |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
52 * {@link Lada.view.grid.ProbeList} |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
53 * was double-clicked. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
54 * The function opens a {@link Lada.view.window.ProbeEdit} |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
55 * or a {@link Lada.view.window.Messprogramm}. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
56 * To determine which window has to be opened, the function |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
57 * analyse the records modelname. |
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 editItem: function(grid, record) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
60 var winname = 'Lada.view.window.ProbeEdit'; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
61 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
62 var win = Ext.create(winname, { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
63 record: record, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
64 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
|
65 }); |
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
|
66 win.setPosition(30); |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
67 win.show(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
68 win.initData(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
69 }, |
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 /** |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
72 * This function opens a new window to create a Probe |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
73 * {@link Lada.view.window.ProbeCreate} |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
74 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
75 addProbeItem: function() { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
76 var win = Ext.create('Lada.view.window.ProbeCreate'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
77 win.show(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
78 win.initData(); |
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 /** |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
82 * This function opens a {@link Lada.view.window.FileUpload} |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
83 * window to upload a LAF-File |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
84 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
85 uploadFile: function() { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
86 var win = Ext.create('Lada.view.window.FileUpload', { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
87 title: 'Datenimport', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
88 modal: true |
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 win.show(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
92 }, |
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 /** |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
95 * This function can be used to Download the items which |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
96 * were selected in the {@link Lada.view.grid.ProbeList} |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
97 * 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
|
98 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
99 downloadFile: function(button) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
100 var grid = button.up('grid'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
101 var selection = grid.getView().getSelectionModel().getSelection(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
102 var i18n = Lada.getApplication().bundle; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
103 var proben = []; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
104 for (var i = 0; i < selection.length; i++) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
105 proben.push(selection[i].get('id')); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
106 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
107 var me = this; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
108 Ext.Ajax.request({ |
999 | 109 url: 'lada-server/data/export/laf', |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
110 jsonData: {'proben': proben}, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
111 success: function(response) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
112 var content = response.responseText; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
113 var blob = new Blob([content],{type: 'text/plain'}); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
114 saveAs(blob, 'export.laf'); |
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 failure: function(response) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
117 /* |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
118 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
|
119 unfortunately this seems to be filtered by the browser. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
120 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
|
121 is true. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
122 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
123 if (response.status == 0 && response.responseText === "") { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
124 Ext.MessageBox.confirm('Erneutes Login erforderlich', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
125 'Ihre Session ist abgelaufen.<br/>'+ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
126 '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
|
127 'Alle ungesicherten Daten gehen dabei verloren.<br/>' + |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
128 'Soll die Anwendung jetzt neu geladen werden?', this.reload); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
129 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
130 // further error handling |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
131 var json = Ext.JSON.decode(response.responseText); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
132 if (json) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
133 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
134 formPanel.setMessages(json.errors, json.warnings); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
135 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
136 if(json.message){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
137 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
|
138 +' #'+json.message, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
139 Lada.getApplication().bundle.getMsg(json.message)); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
140 } else { |
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 } else { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
145 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
146 i18n.getMsg('err.msg.laf.filecreatefailed')); |
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 }); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
150 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
151 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
152 /** |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
153 * Send the selection to a Printservice |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
154 */ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
155 printSelection: function(button) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
156 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
157 //disable Button and setLoading... |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
158 button.disable(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
159 button.setLoading(true); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
160 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
161 var grid = button.up('grid'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
162 var selection = grid.getView().getSelectionModel().getSelection(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
163 var i18n = Lada.getApplication().bundle; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
164 var me = this; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
165 var columns = []; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
166 var columnNames = []; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
167 var visibleColumns = []; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
168 var displayName = ''; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
169 var data = []; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
170 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
171 // Write the columns to an array |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
172 try { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
173 for (key in selection[0].data) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
174 // 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
|
175 if (["owner", "readonly", "id", "probeId"].indexOf(key) == -1){ |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
176 columns.push(key); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
177 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
178 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
179 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
180 catch (e) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
181 console.log(e); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
182 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
183 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
184 //Retrieve visible columns' id's and names. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
185 // and set displayName |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
186 try { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
187 var grid = button.up('grid'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
188 var cman = grid.columnManager; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
189 var cols = cman.getColumns(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
190 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
191 displayName = grid.down('tbtext').text; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
192 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
193 for (key in cols) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
194 if (cols[key].dataIndex) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
195 visibleColumns[cols[key].dataIndex] = cols[key].text; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
196 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
197 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
198 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
199 catch (e) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
200 console.log(e); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
201 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
202 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
203 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
204 // Retrieve Data from selection |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
205 try { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
206 for (item in selection) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
207 var row = selection[item].data; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
208 var out = []; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
209 //Lookup every column and write to data array. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
210 for (key in columns){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
211 var attr = columns[key]; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
212 //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
|
213 if (row[attr] != null && |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
214 visibleColumns[attr] != null) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
215 out.push(row[attr].toString()); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
216 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
217 else if (visibleColumns[attr] != null) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
218 out.push(''); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
219 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
220 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
221 data.push(out); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
222 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
223 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
224 catch (e){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
225 console.log(e); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
226 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
227 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
228 //Retrieve the names of the columns. |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
229 try { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
230 var grid = button.up('grid'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
231 var cman = grid.columnManager; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
232 var cols = cman.getColumns(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
233 //Iterate columns and find column names for the key... |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
234 // 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
|
235 for (key in columns){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
236 for (k in cols){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
237 if (cols[k].dataIndex == columns[key]){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
238 columnNames.push(cols[k].text); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
239 break; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
240 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
241 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
242 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
243 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
244 catch (e) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
245 console.log(e); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
246 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
247 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
248 var printData = { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
249 'layout': 'A4 landscape', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
250 'outputFormat': 'pdf', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
251 'attributes': { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
252 'title': 'Auszug aus LADA', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
253 'displayName': displayName, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
254 'table': { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
255 'columns': columnNames, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
256 'data': data |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
257 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
258 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
259 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
260 |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
261 Ext.Ajax.request({ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
262 url: 'lada-printer/buildreport.pdf', |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
263 //configure a proxy in apache conf! |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
264 jsonData: printData, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
265 binary: true, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
266 success: function(response) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
267 var content = response.responseBytes; |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
268 var filetype = response.getResponseHeader('Content-Type'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
269 var blob = new Blob([content],{type: filetype}); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
270 saveAs(blob, 'lada-print.pdf'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
271 button.enable(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
272 button.setLoading(false); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
273 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
274 failure: function(response) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
275 console.log('failure'); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
276 // Error handling |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
277 // TODO |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
278 //console.log(response.responseText) |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
279 button.enable(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
280 button.setLoading(false); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
281 if (response.responseText) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
282 try { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
283 var json = Ext.JSON.decode(response.responseText); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
284 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
285 catch(e){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
286 console.log(e); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
287 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
288 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
289 if (json) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
290 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
291 formPanel.setMessages(json.errors, json.warnings); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
292 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
293 if(json.message){ |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
294 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
|
295 +' #'+json.message, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
296 Lada.getApplication().bundle.getMsg(json.message)); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
297 } else { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
298 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
299 i18n.getMsg('err.msg.print.noContact')); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
300 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
301 } else { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
302 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
303 i18n.getMsg('err.msg.print.noContact')); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
304 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
305 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
306 }); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
307 }, |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
308 |
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
|
309 /** |
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
|
310 * Toggles the buttons in the toolbar |
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
|
311 **/ |
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
|
312 activateButtons: function(rowModel, record) { |
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
|
313 var grid = rowModel.view.up('grid'); |
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
|
314 this.buttonToggle(true, grid); |
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
|
315 }, |
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
|
316 |
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
|
317 /** |
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
|
318 * Toggles the buttons in the toolbar |
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
|
319 **/ |
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
|
320 deactivateButtons: function(rowModel, record) { |
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
|
321 var grid = rowModel.view.up('grid'); |
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
|
322 // Only disable buttons when nothing is selected |
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
|
323 if (rowModel.selected.items == 0) { |
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
|
324 this.buttonToggle(false, grid); |
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
|
325 } |
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
|
326 }, |
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
|
327 |
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
|
328 /** |
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
|
329 * Enables/Disables a set of buttons |
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
|
330 **/ |
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
|
331 buttonToggle: function(enabled, grid) { |
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
|
332 if (!enabled) { |
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
|
333 grid.down('button[action=export]').disable(); |
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
|
334 grid.down('button[action=print]').disable(); |
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
|
335 } |
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
|
336 else { |
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
|
337 grid.down('button[action=export]').enable(); |
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
|
338 grid.down('button[action=print]').enable(); |
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
|
339 } |
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
|
340 }, |
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
|
341 |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
342 reload: function(btn) { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
343 if (btn === 'yes') { |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
344 location.reload(); |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
345 } |
1111
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
346 }, |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
347 |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
348 expandBody: function(rowNode, record, expandRow) { |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
349 // var row = Ext.get('probe-row-' + record.get('id')); |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
350 // var messungGrid = Ext.create('Lada.view.grid.Messung', { |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
351 // recordId: record.get('id'), |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
352 // bottomBar: false, |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
353 // rowLines: true |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
354 // }); |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
355 // row.swallowEvent(['click', 'mousedown', 'mouseup', 'dblclick'], true); |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
356 // messungGrid.render(row); |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
357 }, |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
358 |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
359 collapseBody: function(rowNode, record, expandRow) { |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
360 // var element = Ext.get('probe-row-' + record.get('id')).down('div'); |
a73726bba79c
Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1082
diff
changeset
|
361 // element.destroy(); |
975
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
362 } |
fb99332bb48e
Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
363 }); |