annotate app/view/widget/DynamicGrid.js @ 1281:8012e5212bd5

Fixed initial length of deskriptor string.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 18 Jan 2017 14:54:38 +0100
parents 96f9417c105e
children 01f083db45b7
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 * Grid to list the result of the Filter
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.view.widget.DynamicGrid', {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
13 extend: 'Ext.grid.Panel',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
14
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
15 store: null,
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
16
980
7867752a0d58 Tidied up borders of the viewport
Dustin Demuth <dustin@intevation.de>
parents: 976
diff changeset
17 border: false,
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
18 multiSelect: true,
976
3c770fc7cf19 Added a variable which makes it possible to detect if a grid is dynamic
Dustin Demuth <dustin@intevation.de>
parents: 975
diff changeset
19 allowDeselect: true,
3c770fc7cf19 Added a variable which makes it possible to detect if a grid is dynamic
Dustin Demuth <dustin@intevation.de>
parents: 975
diff changeset
20
3c770fc7cf19 Added a variable which makes it possible to detect if a grid is dynamic
Dustin Demuth <dustin@intevation.de>
parents: 975
diff changeset
21 isDynamic: true,
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
22
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
23 viewConfig: {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
24 deferEmptyText: false
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
25 },
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
26
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
27 initComponent: function() {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
28 var i18n = Lada.getApplication().bundle;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
29 this.callParent(arguments);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
30 },
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 /**
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
33 * This sets the Store of the DynamicGrid
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 setStore: function(store){
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
36 var i18n = Lada.getApplication().bundle;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
37 this.reconfigure(store);
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1005
diff changeset
38 var ptbar = this.down('pagingtoolbar');
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1005
diff changeset
39 if (ptbar) {
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1005
diff changeset
40 this.removeDocked(ptbar);
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1005
diff changeset
41 }
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 1005
diff changeset
42
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
43 this.addDocked([{
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
44 xtype: 'pagingtoolbar',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
45 dock: 'bottom',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
46 store: store,
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
47 displayInfo: true
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
48 }]);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
49
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
50 },
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
51
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
52 /**
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
53 * Setup columns of the Grid dynamically based on a list of given cols.
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
54 * The function is called from the {@link Lada.controller.Filter#search
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
55 * search event}
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
56 * The Images for the Read-Write Icon are defined in CSS
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
57 */
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
58 setupColumns: function(cols) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
59 var caf = this.generateColumnsAndFields(cols);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
60 var columns = caf[0];
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
61 var fields = caf[1];
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
62 this.store.model.setFields(fields);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
63 this.reconfigure(this.store, columns);
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 * generateColumnsAndFields
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
68 * generates an array of columns which are used for the dynamic grid
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
69 * @return an array of two arrays: [0] is an array of colums [1] an array
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
70 * of fields
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
71 **/
1077
2a5d42045c63 Display Messungen query mode and use the new messung list grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
72 generateColumnsAndFields: function(cols) {
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
73 var resultColumns = [];
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
74 var fields = [];
1259
bfdd875cdb5f Add tooltip to DynamicGrid
Evi Huber <ehuber@bfs.de>
parents: 1217
diff changeset
75 var i18n = Lada.getApplication().bundle;
bfdd875cdb5f Add tooltip to DynamicGrid
Evi Huber <ehuber@bfs.de>
parents: 1217
diff changeset
76 switch(this.xtype) {
bfdd875cdb5f Add tooltip to DynamicGrid
Evi Huber <ehuber@bfs.de>
parents: 1217
diff changeset
77 case 'probelistgrid':
bfdd875cdb5f Add tooltip to DynamicGrid
Evi Huber <ehuber@bfs.de>
parents: 1217
diff changeset
78 var tooltiptext = i18n.getMsg('probe')+' '+i18n.getMsg('open');
bfdd875cdb5f Add tooltip to DynamicGrid
Evi Huber <ehuber@bfs.de>
parents: 1217
diff changeset
79 break;
bfdd875cdb5f Add tooltip to DynamicGrid
Evi Huber <ehuber@bfs.de>
parents: 1217
diff changeset
80 case 'messunglistgrid':
bfdd875cdb5f Add tooltip to DynamicGrid
Evi Huber <ehuber@bfs.de>
parents: 1217
diff changeset
81 var tooltiptext = i18n.getMsg('messung')+' '+i18n.getMsg('open');
bfdd875cdb5f Add tooltip to DynamicGrid
Evi Huber <ehuber@bfs.de>
parents: 1217
diff changeset
82 break;
bfdd875cdb5f Add tooltip to DynamicGrid
Evi Huber <ehuber@bfs.de>
parents: 1217
diff changeset
83 case 'messprogrammelistgrid':
bfdd875cdb5f Add tooltip to DynamicGrid
Evi Huber <ehuber@bfs.de>
parents: 1217
diff changeset
84 var tooltiptext = i18n.getMsg('messprogramm')+' '+i18n.getMsg('open');
bfdd875cdb5f Add tooltip to DynamicGrid
Evi Huber <ehuber@bfs.de>
parents: 1217
diff changeset
85 }
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
86
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
87 fields.push(new Ext.data.Field({
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
88 name: 'owner'
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 fields.push(new Ext.data.Field({
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
91 name: 'readonly'
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
92 }));
1082
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
93 fields.push(new Ext.data.Field({
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
94 name: 'statusEdit'
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
95 }));
1111
a73726bba79c Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1082
diff changeset
96 fields.push(new Ext.data.Field({
a73726bba79c Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1082
diff changeset
97 name: 'id'
a73726bba79c Use custom row expander in probe list grid to display messung grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1082
diff changeset
98 }));
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
99
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
100 resultColumns.push({
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
101 xtype: 'actioncolumn',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
102 text: 'RW',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
103 dataIndex: 'readonly',
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
104 sortable: false,
1259
bfdd875cdb5f Add tooltip to DynamicGrid
Evi Huber <ehuber@bfs.de>
parents: 1217
diff changeset
105 tooltip: tooltiptext,
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
106 width: 30,
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
107 getClass: function (val, meta, rec) {
1082
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
108 if (rec.get('readonly') === false &&
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
109 rec.get('owner') === true &&
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
110 !rec.get('statusEdit')) {
1217
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1213
diff changeset
111 return 'edit';
1005
52b02b0225e8 Made changes to the edit button
Dustin Demuth <dustin@intevation.de>
parents: 980
diff changeset
112 }
1082
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
113 else if (rec.get('readonly') === false &&
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
114 rec.get('owner') === true &&
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
115 rec.get('statusEdit')) {
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
116 return 'editstatus';
1005
52b02b0225e8 Made changes to the edit button
Dustin Demuth <dustin@intevation.de>
parents: 980
diff changeset
117 }
1082
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
118 else if (rec.get('readonly') === true &&
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
119 rec.get('statusEdit')) {
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
120 return 'noeditstatus';
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
121 }
dbd435256f77 Open status edit window and send status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1077
diff changeset
122 return 'noedit';
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
123 },
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
124 handler: function(grid, rowIndex, colIndex) {
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
125 var rec = grid.getStore().getAt(rowIndex);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
126 grid.fireEvent('itemdblclick', grid, rec);
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
127 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
128 });
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
129
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
130 for (var i = cols.length - 1; i >= 0; i--) {
1077
2a5d42045c63 Display Messungen query mode and use the new messung list grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
131 fields.push(new Ext.data.Field({
2a5d42045c63 Display Messungen query mode and use the new messung list grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
132 name: cols[i].dataIndex
2a5d42045c63 Display Messungen query mode and use the new messung list grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
133 }));
2a5d42045c63 Display Messungen query mode and use the new messung list grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
134 if (cols[i] === 'id' || cols[i].dataIndex === 'probeId') {
975
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
135 continue;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
136 }
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
137 resultColumns.push(cols[i]);
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 var caf = new Array();
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
140 caf[0] = resultColumns;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
141 caf[1] = fields;
fb99332bb48e Severe changes concerning the Resultgrids.
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
142 return caf;
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

http://lada.wald.intevation.org