annotate app/view/grid/FilterResult.js @ 797:b8fd43021c29

Added a Window to alter Orte of a Messprogramm
author Dustin Demuth <dustin@intevation.de>
date Wed, 20 May 2015 16:48:03 +0200
parents 255568e97c96
children d369a7eb0a7f
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() {
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 this.dockedItems = [{
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 xtype: 'toolbar',
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 dock: 'top',
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 items: [{
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
30 xtype: 'tbtext',
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
31 id: 'tbtitle',
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
32 text: '',
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
33 },
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
34 '->',
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 text: 'Probe erstellen',
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 icon: 'resources/img/list-add.png',
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
38 action: 'addProbe',
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
39 disabled: false
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 }, {
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
41 text: 'Messprogramm erstellen',
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
42 icon: 'resources/img/list-add.png',
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
43 action: 'addMessprogramm',
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
44 disabled: false
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
45 },
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
46 '-',
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 text: 'Proben Importieren',
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 icon: 'resources/img/svn-commit.png',
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
50 action: 'import',
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
51 disabled: false
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 }, {
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
53 text: 'Proben Exportieren',
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 icon: 'resources/img/svn-update.png',
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
55 action: 'export',
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
56 disabled: true
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
57 }
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
58 ]
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 }];
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 this.columns = [];
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 this.callParent(arguments);
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 },
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 /**
751
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
65 * This sets the Store of the FilterResultGrid
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
66 */
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
67 setStore: function(store){
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
68 var i18n = Lada.getApplication().bundle;
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
69
751
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
70 this.removeDocked(Ext.getCmp('ptbar'), true);
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
71 this.reconfigure(store);
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
72 this.addDocked([{
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
73 xtype: 'pagingtoolbar',
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
74 id: 'ptbar',
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
75 dock: 'bottom',
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
76 store: store,
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
77 displayInfo: true
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
78 }]);
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
79
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
80 //Configure the Toolbar.
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
81 this.setMode(store);
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
82 },
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
83
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 * 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
86 */
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
87 setMode: function(store) {
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
88 var t = Ext.getCmp('tbtitle');
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
89 var i18n = Lada.getApplication().bundle;
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
90 if (store.model.modelName == 'Lada.model.ProbeList'){
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
91 t.setText(i18n.getMsg('probelist'));
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
92 this.down('button[action=addMessprogramm]').disable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
93 this.down('button[action=addProbe]').enable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
94 this.down('button[action=import]').enable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
95 this.down('button[action=export]').enable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
96 }
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
97 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
98 t.setText(i18n.getMsg('probeplanning'));
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
99 this.down('button[action=addMessprogramm]').enable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
100 this.down('button[action=addProbe]').disable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
101 this.down('button[action=import]').disable();
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
102 this.down('button[action=export]').disable();
753
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
103 }
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
104 else {
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
105 t.setText('');
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
106 console.log('The model '+store.model.modelName+
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
107 'was not defined in the FilterResultGrid.' +
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
108 ' Hence the title could not be set.');
4dd0c645ea8b Display a Title in the Toolbar
Dustin Demuth <dustin@intevation.de>
parents: 751
diff changeset
109 }
751
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
110 },
792
d572ee3271ac some work on a context-sensitive toolbar
Dustin Demuth <dustin@intevation.de>
parents: 755
diff changeset
111
751
704bb359c0fe dynamically exchange the store of the resultfiltergrid
Dustin Demuth <dustin@intevation.de>
parents: 682
diff changeset
112 /**
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 * 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
114 * 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
115 * search event}
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116 */
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 setupColumns: function(cols) {
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 var resultColumns = [];
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 var fields = [];
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 resultColumns.push({
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 header: 'RW',
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 dataIndex: 'readonly',
682
7b6467edfdfc RW Column may not be sortable
Dustin Demuth <dustin@intevation.de>
parents: 656
diff changeset
124 sortable: false,
548
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 width: 30,
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126 renderer: function(value) {
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 if (value) {
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 return '<img src="resources/img/lock_16x16.png"/>';
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 }
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 return '<img src="resources/img/unlock_16x16.png"/>';
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 }
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 });
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 fields.push(new Ext.data.Field({
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 name: 'readonly'
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 }));
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 for (var i = cols.length - 1; i >= 0; i--) {
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 if (cols[i] === 'id') {
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 continue;
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 }
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140 resultColumns.push(cols[i]);
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 fields.push(new Ext.data.Field({
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
142 name: cols[i].dataIndex
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
143 }));
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144 }
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 this.store.model.setFields(fields);
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 this.reconfigure(this.store, resultColumns);
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 }
d47ee7439f44 Added new js files.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
148 });

http://lada.wald.intevation.org