annotate app/controller/grid/ProbeList.js @ 1086:61cc583c3649

Messprogramm form redesign
author Michael Stanko <mstanko@bfs.de>
date Fri, 29 Apr 2016 10:20:05 +0200
parents dbd435256f77
children a73726bba79c
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: [
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
15 'Lada.view.window.ProbeEdit',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
16 'Lada.view.window.GenProbenFromMessprogramm'
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
17 ],
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 * Initialize the Controller with listeners
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
21 */
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
22 init: function() {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
23 this.control({
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
24 '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
25 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
26 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
27 deselect: this.deactivateButtons
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
28 },
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
29 'probelistgrid toolbar button[action=addProbe]': {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
30 click: this.addProbeItem
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
31 },
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
32 'probelistgrid toolbar button[action=import]': {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
33 click: this.uploadFile
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
34 },
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
35 'probelistgrid toolbar button[action=export]': {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
36 click: this.downloadFile
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
37 },
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
38 'probelistgrid toolbar button[action=print]': {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
39 click: this.printSelection
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
40 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
41 });
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
42 this.callParent(arguments);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
43 },
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
44
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 * This function is called after a Row in the
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
47 * {@link Lada.view.grid.ProbeList}
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
48 * was double-clicked.
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
49 * The function opens a {@link Lada.view.window.ProbeEdit}
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
50 * or a {@link Lada.view.window.Messprogramm}.
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
51 * To determine which window has to be opened, the function
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
52 * analyse the records modelname.
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
53 */
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
54 editItem: function(grid, record) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
55 var winname = 'Lada.view.window.ProbeEdit';
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
56
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
57 var win = Ext.create(winname, {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
58 record: record,
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
59 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
60 });
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 win.show();
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
63 win.initData();
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
64 },
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
65
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
66 /**
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
67 * This function opens a new window to create a Probe
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
68 * {@link Lada.view.window.ProbeCreate}
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 addProbeItem: function() {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
71 var win = Ext.create('Lada.view.window.ProbeCreate');
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
72 win.show();
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
73 win.initData();
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
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
76 /**
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
77 * This function opens a {@link Lada.view.window.FileUpload}
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
78 * window to upload a LAF-File
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 uploadFile: function() {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
81 var win = Ext.create('Lada.view.window.FileUpload', {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
82 title: 'Datenimport',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
83 modal: true
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
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 },
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 * This function can be used to Download the items which
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
91 * were selected in the {@link Lada.view.grid.ProbeList}
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
92 * 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
93 */
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
94 downloadFile: function(button) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
95 var grid = button.up('grid');
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
96 var selection = grid.getView().getSelectionModel().getSelection();
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
97 var i18n = Lada.getApplication().bundle;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
98 var proben = [];
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
99 for (var i = 0; i < selection.length; i++) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
100 proben.push(selection[i].get('id'));
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 var me = this;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
103 Ext.Ajax.request({
999
f73ca04d73a7 Refactored Server URL
Dustin Demuth <dustin@intevation.de>
parents: 977
diff changeset
104 url: 'lada-server/data/export/laf',
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
105 jsonData: {'proben': proben},
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
106 success: function(response) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
107 var content = response.responseText;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
108 var blob = new Blob([content],{type: 'text/plain'});
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
109 saveAs(blob, 'export.laf');
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
110 },
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
111 failure: function(response) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
112 /*
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
113 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
114 unfortunately this seems to be filtered by the browser.
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
115 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
116 is true.
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 if (response.status == 0 && response.responseText === "") {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
119 Ext.MessageBox.confirm('Erneutes Login erforderlich',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
120 'Ihre Session ist abgelaufen.<br/>'+
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
121 '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
122 'Alle ungesicherten Daten gehen dabei verloren.<br/>' +
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
123 'Soll die Anwendung jetzt neu geladen werden?', this.reload);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
124 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
125 // further error handling
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
126 var json = Ext.JSON.decode(response.responseText);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
127 if (json) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
128 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
129 formPanel.setMessages(json.errors, json.warnings);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
130 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
131 if(json.message){
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
132 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
133 +' #'+json.message,
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
134 Lada.getApplication().bundle.getMsg(json.message));
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
135 } else {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
136 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
137 i18n.getMsg('err.msg.laf.filecreatefailed'));
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
138 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
139 } else {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
140 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
141 i18n.getMsg('err.msg.laf.filecreatefailed'));
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
142 }
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 * Send the selection to a Printservice
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 printSelection: function(button) {
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 //disable Button and setLoading...
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
153 button.disable();
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
154 button.setLoading(true);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
155
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
156 var grid = button.up('grid');
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
157 var selection = grid.getView().getSelectionModel().getSelection();
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
158 var i18n = Lada.getApplication().bundle;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
159 var me = this;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
160 var columns = [];
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
161 var columnNames = [];
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
162 var visibleColumns = [];
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
163 var displayName = '';
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
164 var data = [];
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
165
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
166 // Write the columns to an array
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
167 try {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
168 for (key in selection[0].data) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
169 // 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
170 if (["owner", "readonly", "id", "probeId"].indexOf(key) == -1){
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
171 columns.push(key);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
172 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
173 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
174 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
175 catch (e) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
176 console.log(e);
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 //Retrieve visible columns' id's and names.
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
180 // and set displayName
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
181 try {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
182 var grid = button.up('grid');
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
183 var cman = grid.columnManager;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
184 var cols = cman.getColumns();
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
185
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
186 displayName = grid.down('tbtext').text;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
187
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
188 for (key in cols) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
189 if (cols[key].dataIndex) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
190 visibleColumns[cols[key].dataIndex] = cols[key].text;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
191 }
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 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
194 catch (e) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
195 console.log(e);
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 // Retrieve Data from selection
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
200 try {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
201 for (item in selection) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
202 var row = selection[item].data;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
203 var out = [];
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
204 //Lookup every column and write to data array.
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
205 for (key in columns){
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
206 var attr = columns[key];
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
207 //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
208 if (row[attr] != null &&
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
209 visibleColumns[attr] != null) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
210 out.push(row[attr].toString());
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
211 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
212 else if (visibleColumns[attr] != null) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
213 out.push('');
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
214 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
215 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
216 data.push(out);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
217 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
218 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
219 catch (e){
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
220 console.log(e);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
221 }
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 //Retrieve the names of the columns.
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
224 try {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
225 var grid = button.up('grid');
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
226 var cman = grid.columnManager;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
227 var cols = cman.getColumns();
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
228 //Iterate columns and find column names for the key...
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
229 // 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
230 for (key in columns){
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
231 for (k in cols){
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
232 if (cols[k].dataIndex == columns[key]){
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
233 columnNames.push(cols[k].text);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
234 break;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
235 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
236 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
237 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
238 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
239 catch (e) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
240 console.log(e);
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 var printData = {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
244 'layout': 'A4 landscape',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
245 'outputFormat': 'pdf',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
246 'attributes': {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
247 'title': 'Auszug aus LADA',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
248 'displayName': displayName,
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
249 'table': {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
250 'columns': columnNames,
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
251 'data': data
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
252 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
253 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
254 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
255
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
256 Ext.Ajax.request({
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
257 url: 'lada-printer/buildreport.pdf',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
258 //configure a proxy in apache conf!
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
259 jsonData: printData,
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
260 binary: true,
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
261 success: function(response) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
262 var content = response.responseBytes;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
263 var filetype = response.getResponseHeader('Content-Type');
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
264 var blob = new Blob([content],{type: filetype});
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
265 saveAs(blob, 'lada-print.pdf');
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
266 button.enable();
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
267 button.setLoading(false);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
268 },
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
269 failure: function(response) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
270 console.log('failure');
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
271 // Error handling
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
272 // TODO
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
273 //console.log(response.responseText)
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
274 button.enable();
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
275 button.setLoading(false);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
276 if (response.responseText) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
277 try {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
278 var json = Ext.JSON.decode(response.responseText);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
279 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
280 catch(e){
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
281 console.log(e);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
282 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
283 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
284 if (json) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
285 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
286 formPanel.setMessages(json.errors, json.warnings);
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 if(json.message){
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
289 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
290 +' #'+json.message,
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
291 Lada.getApplication().bundle.getMsg(json.message));
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
292 } else {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
293 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
294 i18n.getMsg('err.msg.print.noContact'));
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
295 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
296 } else {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
297 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
298 i18n.getMsg('err.msg.print.noContact'));
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
299 }
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 });
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
302 },
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
303
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
304 /**
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
305 * 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
306 **/
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
307 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
308 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
309 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
310 },
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 /**
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 * 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
314 **/
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 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
316 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
317 // 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
318 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
319 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
320 }
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 },
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
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 /**
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 * 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
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 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
327 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
328 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
329 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
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 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
332 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
333 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
334 }
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
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
337 reload: function(btn) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
338 if (btn === 'yes') {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
339 location.reload();
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 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
342 });

http://lada.wald.intevation.org