annotate app/controller/grid/MessungList.js @ 1076:e32c10cf5499

Added model/store, view and controller for messung list.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 08 Apr 2016 19:32:02 +0200
parents
children dbd435256f77
rev   line source
1076
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 /**
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 * Controller for the MessungList result grid.
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 */
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 Ext.define('Lada.controller.grid.MessungList', {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 extend: 'Ext.app.Controller',
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 requires: [
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 'Lada.view.window.ProbeEdit'
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 ],
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 /**
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 * Initialize the Controller with listeners
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 */
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 init: function() {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 this.control({
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 'messunglistgrid': {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 itemdblclick: this.editItem,
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 select: this.activateButtons,
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 deselect: this.deactivateButtons
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 });
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 this.callParent(arguments);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 },
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 /**
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 * This function is called after a Row in the
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 * {@link Lada.view.grid.ProbeList}
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 * was double-clicked.
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 * The function opens a {@link Lada.view.window.ProbeEdit}
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 * or a {@link Lada.view.window.Messprogramm}.
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 * To determine which window has to be opened, the function
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 * analyse the records modelname.
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 */
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 editItem: function(grid, record) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 var probeRecord = Ext.create('Lada.model.ProbeList');
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 probeRecord.setId(record.get('probeId'));
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 probeRecord.set('owner', record.get('owner'));
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 probeRecord.set('readonly', record.get('readonly'));
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 var probeWin = Ext.create('Lada.view.window.ProbeEdit', {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 record: probeRecord,
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 style: 'z-index: -1;' //Fixes an Issue where windows could not be created in IE8
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 });
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 probeWin.setPosition(30);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 probeWin.show();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 probeWin.initData();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 Ext.ClassManager.get('Lada.model.Probe').load(record.get('probeId'), {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 failure: function(record, action) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 me.setLoading(false);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 // TODO
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 console.log('An unhandled Failure occured. See following Response and Record');
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 console.log(action);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 console.log(record);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 },
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 success: function(precord, response) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 var messungWin = Ext.create('Lada.view.window.MessungEdit', {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 parentWindow: grid.up('window'),
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 probe: precord,
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 record: record,
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 grid: grid
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 });
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 messungWin.show();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 messungWin.setPosition(window.innerWidth - 30 - messungWin.width);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 messungWin.initData();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 });
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 },
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 /**
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 * Send the selection to a Printservice
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 */
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 printSelection: function(button) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 //disable Button and setLoading...
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 button.disable();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 button.setLoading(true);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 var grid = button.up('grid');
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 var selection = grid.getView().getSelectionModel().getSelection();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 var i18n = Lada.getApplication().bundle;
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 var me = this;
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 var columns = [];
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 var columnNames = [];
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 var visibleColumns = [];
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 var displayName = '';
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 var data = [];
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 // Write the columns to an array
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 try {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 for (key in selection[0].data) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 // Do not write owner or readonly or id
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 if (["owner", "readonly", "id", "probeId"].indexOf(key) == -1){
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 columns.push(key);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 catch (e) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 console.log(e);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 //Retrieve visible columns' id's and names.
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111 // and set displayName
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 try {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 var grid = button.up('grid');
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 var cman = grid.columnManager;
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115 var cols = cman.getColumns();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 displayName = grid.down('tbtext').text;
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 for (key in cols) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 if (cols[key].dataIndex) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 visibleColumns[cols[key].dataIndex] = cols[key].text;
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 catch (e) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126 console.log(e);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 // Retrieve Data from selection
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 try {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 for (item in selection) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 var row = selection[item].data;
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 var out = [];
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 //Lookup every column and write to data array.
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 for (key in columns){
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 var attr = columns[key];
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 //Only write data to output when the column is not hidden.
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 if (row[attr] != null &&
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140 visibleColumns[attr] != null) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 out.push(row[attr].toString());
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
142 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
143 else if (visibleColumns[attr] != null) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144 out.push('');
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 data.push(out);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
148 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 catch (e){
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
151 console.log(e);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
152 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
154 //Retrieve the names of the columns.
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
155 try {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
156 var grid = button.up('grid');
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
157 var cman = grid.columnManager;
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
158 var cols = cman.getColumns();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
159 //Iterate columns and find column names for the key...
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
160 // This WILL run into bad behaviour when column-keys exist twice.
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
161 for (key in columns){
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
162 for (k in cols){
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
163 if (cols[k].dataIndex == columns[key]){
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
164 columnNames.push(cols[k].text);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
165 break;
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
167 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
168 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
169 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
170 catch (e) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
171 console.log(e);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
172 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
173
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
174 var printData = {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
175 'layout': 'A4 landscape',
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
176 'outputFormat': 'pdf',
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
177 'attributes': {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
178 'title': 'Auszug aus LADA',
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
179 'displayName': displayName,
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
180 'table': {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
181 'columns': columnNames,
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
182 'data': data
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
183 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
184 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
185 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
186
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
187 Ext.Ajax.request({
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
188 url: 'lada-printer/buildreport.pdf',
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
189 //configure a proxy in apache conf!
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
190 jsonData: printData,
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
191 binary: true,
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
192 success: function(response) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
193 var content = response.responseBytes;
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
194 var filetype = response.getResponseHeader('Content-Type');
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
195 var blob = new Blob([content],{type: filetype});
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
196 saveAs(blob, 'lada-print.pdf');
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
197 button.enable();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
198 button.setLoading(false);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
199 },
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
200 failure: function(response) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
201 console.log('failure');
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
202 // Error handling
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
203 // TODO
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
204 //console.log(response.responseText)
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
205 button.enable();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
206 button.setLoading(false);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
207 if (response.responseText) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
208 try {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
209 var json = Ext.JSON.decode(response.responseText);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
210 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
211 catch(e){
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
212 console.log(e);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
213 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
214 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
215 if (json) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
216 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
217 formPanel.setMessages(json.errors, json.warnings);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
218 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
219 if(json.message){
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
220 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title')
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
221 +' #'+json.message,
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
222 Lada.getApplication().bundle.getMsg(json.message));
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
223 } else {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
224 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
225 i18n.getMsg('err.msg.print.noContact'));
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
226 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
227 } else {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
228 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
229 i18n.getMsg('err.msg.print.noContact'));
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
230 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
231 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
232 });
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
233 },
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
234
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
235 /**
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
236 * Toggles the buttons in the toolbar
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
237 **/
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
238 activateButtons: function(rowModel, record) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
239 var grid = rowModel.view.up('grid');
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
240 this.buttonToggle(true, grid);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
241 },
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
242
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
243 /**
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
244 * Toggles the buttons in the toolbar
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
245 **/
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
246 deactivateButtons: function(rowModel, record) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
247 var grid = rowModel.view.up('grid');
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
248 // Only disable buttons when nothing is selected
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
249 if (rowModel.selected.items == 0) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
250 this.buttonToggle(false, grid);
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
251 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
252 },
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
253
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
254 /**
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
255 * Enables/Disables a set of buttons
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
256 **/
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
257 buttonToggle: function(enabled, grid) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
258 if (!enabled) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
259 grid.down('button[action=print]').disable();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
260 grid.down('button[action=setStatus]').disable();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
261 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
262 else {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
263 grid.down('button[action=print]').enable();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
264 // TODO: enable button only on messungen with owner == true and
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
265 // readonly == false
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
266 grid.down('button[action=setStatus]').enable();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
267 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
268 },
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
269
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
270 reload: function(btn) {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
271 if (btn === 'yes') {
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
272 location.reload();
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
273 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
274 }
e32c10cf5499 Added model/store, view and controller for messung list.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
275 });

http://lada.wald.intevation.org