annotate app/view/grid/Messmethoden.js @ 758:b2fcbdc4969d

Filled MessmethodenGrid with life.
author Dustin Demuth <dustin@intevation.de>
date Wed, 06 May 2015 16:24:23 +0200
parents b8502964f5c3
children b7484c7da2d4
rev   line source
757
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
3 *
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
7 */
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
8
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
9 /*
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
10 * Grid to list Messmethoden
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
11 */
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
12 Ext.define('Lada.view.grid.Messmethoden', {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
13 extend: 'Ext.grid.Panel',
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
14 alias: 'widget.messmethodengrid',
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
15
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
16 requires: [
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
17 'Lada.view.widget.Messmethode'
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
18 ],
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
19
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
20 maxHeight: 350,
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
21 minHeight: 110,
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
22 viewConfig: {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
23 deferEmptyText: false
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
24 },
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
25 margin: '0, 5, 5, 5',
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
26
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
27 recordId: null,
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
28
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
29 initComponent: function() {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
30 var i18n = Lada.getApplication().bundle;
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
31 this.emptyText = i18n.getMsg('emptytext.mmtgrid');
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
32
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
33 this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
34 clicksToMoveEditor: 1,
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
35 autoCancel: false,
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
36 disabled: false,
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
37 pluginId: 'rowedit',
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
38 listeners:{
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
39 // Make row ineditable when readonly is set to true
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
40 // Normally this would belong into a controller an not the view.
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
41 // But the RowEditPlugin is not handled there.
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
42 beforeedit: function(e, o) {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
43 var readonlywin = o.grid.up('window').record.get('readonly');
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
44 var readonlygrid = o.record.get('readonly');
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
45 if (readonlywin == true || readonlygrid == true || this.disabled) {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
46 return false;
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
47 }
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
48 return true;
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
49 }
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
50 }
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
51 });
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
52
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
53 this.plugins = [this.rowEditing];
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
54
758
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
55
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
56
757
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
57 this.dockedItems = [{
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
58 xtype: 'toolbar',
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
59 dock: 'bottom',
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
60 items: ['->', {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
61 text: i18n.getMsg('add'),
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
62 icon: 'resources/img/list-add.png',
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
63 action: 'add',
758
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
64 recordId: this.recordId,
757
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
65 }, {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
66 text: i18n.getMsg('delete'),
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
67 icon: 'resources/img/list-remove.png',
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
68 action: 'delete'
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
69 }]
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
70 }];
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
71 this.columns = [{
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
72 header: 'Messmethode',
758
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
73 dataIndex: 'mmtId',
757
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
74 flex: 1,
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
75 renderer: function(value) {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
76 if (!value || value === '') {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
77 return '';
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
78 }
758
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
79 var store = Ext.data.StoreManager.get('messmethoden');
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
80 if (!store) {
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
81 store = Ext.create('Lada.store.Messmethoden');
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
82 }
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
83 return value + " - " + store.findRecord('id', value, 0, false, false, true).get('messmethode');
757
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
84 },
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
85 editor: {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
86 xtype: 'combobox',
758
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
87 store: Ext.data.StoreManager.get('messmethoden'),
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
88 //displayField: 'mmtId',
757
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
89 valueField: 'id',
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
90 allowBlank: false,
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
91 editable: true,
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
92 forceSelection: true,
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
93 autoSelect: true,
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
94 queryMode: 'local',
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
95 minChars: 0,
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
96 typeAhead: false,
758
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
97 triggerAction: 'all',
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
98 tpl: Ext.create("Ext.XTemplate",
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
99 '<tpl for="."><div class="x-combo-list-item x-boundlist-item" >' +
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
100 '{id} - {messmethode}</div></tpl>'),
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
101 displayTpl: Ext.create('Ext.XTemplate',
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
102 '<tpl for=".">{id} - {messmethode}</tpl>'),
757
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
103 }
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
104 }];
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
105 this.initData();
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
106 this.callParent(arguments);
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
107 },
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
108 initData: function() {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
109 if (this.store) {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
110 this.store.removeAll();
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
111 }
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
112 else {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
113 this.store = Ext.create('Lada.store.MmtMessprogramm');
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
114 }
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
115 this.store.load({
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
116 params: {
758
b2fcbdc4969d Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents: 757
diff changeset
117 messprogrammId: this.recordId
757
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
118 }
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
119 });
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
120 },
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
121 setReadOnly: function(b) {
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
122 if (b == true){
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
123 //Readonly
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
124 if (this.getPlugin('rowedit')){
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
125 this.getPlugin('rowedit').disable();
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
126 }
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
127 this.down('button[action=delete]').disable();
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
128 this.down('button[action=add]').disable();
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
129 }else{
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
130 //Writable
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
131 if (this.getPlugin('rowedit')){
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
132 this.getPlugin('rowedit').enable();
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
133 }
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
134 this.down('button[action=delete]').enable();
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
135 this.down('button[action=add]').enable();
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
136 }
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
137 }
b8502964f5c3 Added missing files. Added MmtMockup
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
138 });

http://lada.wald.intevation.org