annotate app/view/grid/FilterResult.js @ 837:d054732bc7a2

Switch the Mode of the Filterresultgrid according to the selection of the radio buttons in the probenplanungswitcher
author Dustin Demuth <dustin@intevation.de>
date Mon, 06 Jul 2015 16:43:08 +0200
parents d369a7eb0a7f
children e44070aa45d2
rev   line source
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 /*
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 * Grid to list Proben
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 */
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 Ext.define('Lada.view.grid.FilterResult', {
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 extend: 'Ext.grid.Panel',
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 alias: 'widget.filterresultgrid',
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15
751
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
16 store: null, //'ProbenList',
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 multiSelect: true,
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 viewConfig: {
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
21 emptyText: 'Keine Ergebnisse gefunden.',
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 deferEmptyText: false
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 },
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 initComponent: function() {
837
d054732bc7a2 Switch the Mode of the Filterresultgrid according to the selection of the radio buttons in the probenplanungswitcher
Dustin Demuth <dustin@intevation.de>
parents: 806
diff changeset
26 var i18n = Lada.getApplication().bundle;
d054732bc7a2 Switch the Mode of the Filterresultgrid according to the selection of the radio buttons in the probenplanungswitcher
Dustin Demuth <dustin@intevation.de>
parents: 806
diff changeset
27
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 this.dockedItems = [{
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 xtype: 'toolbar',
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 dock: 'top',
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 items: [{
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
32 xtype: 'tbtext',
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
33 id: 'tbtitle',
837
d054732bc7a2 Switch the Mode of the Filterresultgrid according to the selection of the radio buttons in the probenplanungswitcher
Dustin Demuth <dustin@intevation.de>
parents: 806
diff changeset
34 text: i18n.getMsg('probelist')
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
35 },
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
36 '->',
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
37 {
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
38 text: 'Probe erstellen',
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 icon: 'resources/img/list-add.png',
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
40 action: 'addProbe',
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
41 disabled: false
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 }, {
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
43 text: 'Messprogramm erstellen',
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
44 icon: 'resources/img/list-add.png',
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
45 action: 'addMessprogramm',
837
d054732bc7a2 Switch the Mode of the Filterresultgrid according to the selection of the radio buttons in the probenplanungswitcher
Dustin Demuth <dustin@intevation.de>
parents: 806
diff changeset
46 disabled: true
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
47 },
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
48 '-',
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
49 {
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
50 text: 'Proben Importieren',
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 icon: 'resources/img/svn-commit.png',
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
52 action: 'import',
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
53 disabled: false
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 }, {
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
55 text: 'Proben Exportieren',
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 icon: 'resources/img/svn-update.png',
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
57 action: 'export',
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
58 disabled: true
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
59 }
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
60 ]
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 }];
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 this.columns = [];
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 this.callParent(arguments);
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 },
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 /**
751
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
67 * This sets the Store of the FilterResultGrid
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
68 */
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
69 setStore: function(store){
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
70 var i18n = Lada.getApplication().bundle;
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
71
751
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
72 this.removeDocked(Ext.getCmp('ptbar'), true);
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
73 this.reconfigure(store);
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
74 this.addDocked([{
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
75 xtype: 'pagingtoolbar',
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
76 id: 'ptbar',
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
77 dock: 'bottom',
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
78 store: store,
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
79 displayInfo: true
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
80 }]);
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
81
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
82 //Configure the Toolbar.
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
83 this.setMode(store);
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
84 },
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
85
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
86 /**
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
87 * Enables or disables Toolbar-Buttons according to the selected mode
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
88 */
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
89 setMode: function(store) {
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
90 var t = Ext.getCmp('tbtitle');
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
91 var i18n = Lada.getApplication().bundle;
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
92 if (store.model.modelName == 'Lada.model.ProbeList'){
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
93 t.setText(i18n.getMsg('probelist'));
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
94 this.down('button[action=addMessprogramm]').disable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
95 this.down('button[action=addProbe]').enable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
96 this.down('button[action=import]').enable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
97 this.down('button[action=export]').enable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
98 }
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
99 else if (store.model.modelName == 'Lada.model.MessprogrammList') {
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
100 t.setText(i18n.getMsg('probeplanning'));
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
101 this.down('button[action=addMessprogramm]').enable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
102 this.down('button[action=addProbe]').disable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
103 this.down('button[action=import]').disable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
104 this.down('button[action=export]').disable();
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
105 }
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
106 else {
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
107 t.setText('');
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
108 console.log('The model '+store.model.modelName+
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
109 'was not defined in the FilterResultGrid.' +
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
110 ' Hence the title could not be set.');
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
111 }
751
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
112 },
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
113
751
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
114 /**
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115 * Setup columns of the Grid dynamically based on a list of given cols.
795
255568e97c96 Latest commit broke the search function
Dustin Demuth <dustin@intevation.de>
parents: 792
diff changeset
116 * The function is called from the {@link Lada.controller.Filter#search
255568e97c96 Latest commit broke the search function
Dustin Demuth <dustin@intevation.de>
parents: 792
diff changeset
117 * search event}
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 */
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 setupColumns: function(cols) {
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 var resultColumns = [];
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 var fields = [];
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 resultColumns.push({
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 header: 'RW',
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 dataIndex: 'readonly',
682
7b6467edfdfc RW Column may not be sortable
Dustin Demuth <dustin@intevation.de>
parents: 656
diff changeset
126 sortable: false,
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 width: 30,
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 renderer: function(value) {
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 if (value) {
806
d369a7eb0a7f Exchanged Icon to display if Probe/Messprogramm is editable
Dustin Demuth <dustin@intevation.de>
parents: 795
diff changeset
130 return '<img src="resources/img/view-time-schedule-baselined.png"/>';
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 }
806
d369a7eb0a7f Exchanged Icon to display if Probe/Messprogramm is editable
Dustin Demuth <dustin@intevation.de>
parents: 795
diff changeset
132 return '<img src="resources/img/view-time-schedule-edit.png"/>';
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 }
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 });
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 fields.push(new Ext.data.Field({
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 name: 'readonly'
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 }));
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 for (var i = cols.length - 1; i >= 0; i--) {
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 if (cols[i] === 'id') {
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140 continue;
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 }
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
142 resultColumns.push(cols[i]);
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
143 fields.push(new Ext.data.Field({
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144 name: cols[i].dataIndex
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 }));
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 }
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 this.store.model.setFields(fields);
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
148 this.reconfigure(this.store, resultColumns);
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 }
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 });

http://lada.wald.intevation.org