annotate app/view/grid/MKommentar.js @ 683:612f4f933083

Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
author Dustin Demuth <dustin@intevation.de>
date Wed, 25 Mar 2015 09:07:20 +0100
parents 6fe3cef53e74
children 69cb367c0a63
rev   line source
596
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 /*
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 * Grid to list Kommentare for Messunge
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 */
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 Ext.define('Lada.view.grid.MKommentar', {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 extend: 'Ext.grid.Panel',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 alias: 'widget.mkommentargrid',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 maxHeight: 350,
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 emptyText: 'Keine Kommentare gefunden.',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 minHeight: 110,
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 viewConfig: {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 deferEmptyText: false
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 },
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 recordId: null,
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 initComponent: function() {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 clicksToMoveEditor: 1,
683
612f4f933083 Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
Dustin Demuth <dustin@intevation.de>
parents: 664
diff changeset
28 autoCancel: false,
612f4f933083 Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
Dustin Demuth <dustin@intevation.de>
parents: 664
diff changeset
29 listeners:{
612f4f933083 Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
Dustin Demuth <dustin@intevation.de>
parents: 664
diff changeset
30 // Make row ineditable when readonly is set to true
612f4f933083 Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
Dustin Demuth <dustin@intevation.de>
parents: 664
diff changeset
31 // Normally this would belong into a controller an not the view.
612f4f933083 Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
Dustin Demuth <dustin@intevation.de>
parents: 664
diff changeset
32 beforeedit: function(e, o) {
612f4f933083 Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
Dustin Demuth <dustin@intevation.de>
parents: 664
diff changeset
33 if (o.record.get('readonly') == true) {
612f4f933083 Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
Dustin Demuth <dustin@intevation.de>
parents: 664
diff changeset
34 return false;
612f4f933083 Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
Dustin Demuth <dustin@intevation.de>
parents: 664
diff changeset
35 }
612f4f933083 Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
Dustin Demuth <dustin@intevation.de>
parents: 664
diff changeset
36 return true;
612f4f933083 Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
Dustin Demuth <dustin@intevation.de>
parents: 664
diff changeset
37 }
612f4f933083 Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
Dustin Demuth <dustin@intevation.de>
parents: 664
diff changeset
38 }
612f4f933083 Made Grid-Rows uneditable if the dataset contains readonly=true. This only affects the Grids using the RowEdit Plugin
Dustin Demuth <dustin@intevation.de>
parents: 664
diff changeset
39 });
596
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 this.plugins = [this.rowEditing];
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 this.dockedItems = [{
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 xtype: 'toolbar',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 dock: 'bottom',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 items: ['->', {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 text: 'Hinzufügen',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 icon: 'resources/img/list-add.png',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 action: 'add'
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 }, {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 text: 'Löschen',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 icon: 'resources/img/list-remove.png',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 action: 'delete'
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 }]
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 }];
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 this.columns = [{
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 header: 'Erzeuger',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 dataIndex: 'erzeuger',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 renderer: function(value) {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 if (!value || value === '') {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 return '';
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 var mstore = Ext.data.StoreManager.get('messstellen');
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 return mstore.getById(value).get('messStelle');
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 },
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 editor: {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 xtype: 'combobox',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 store: Ext.data.StoreManager.get('messstellen'),
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 displayField: 'messStelle',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 valueField: 'id',
664
6fe3cef53e74 Field Validity in MKommentar Grid
Dustin Demuth <dustin@intevation.de>
parents: 626
diff changeset
69 allowBlank: false,
6fe3cef53e74 Field Validity in MKommentar Grid
Dustin Demuth <dustin@intevation.de>
parents: 626
diff changeset
70 editable: false,
596
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 }, {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 header: 'Datum',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 dataIndex: 'datum',
626
13e5473d1af5 Datum Spalte zu einer Datumsspalte gemacht
Dustin Demuth <dustin@intevation.de>
parents: 596
diff changeset
75 xtype: 'datecolumn',
664
6fe3cef53e74 Field Validity in MKommentar Grid
Dustin Demuth <dustin@intevation.de>
parents: 626
diff changeset
76 format: 'd.m.Y',
596
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 editor: {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 xtype: 'datefield',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 allowBlank: false,
664
6fe3cef53e74 Field Validity in MKommentar Grid
Dustin Demuth <dustin@intevation.de>
parents: 626
diff changeset
80 format: 'd.m.Y',
6fe3cef53e74 Field Validity in MKommentar Grid
Dustin Demuth <dustin@intevation.de>
parents: 626
diff changeset
81 maxValue: Ext.Date.format(new Date(), 'd.m.Y')
596
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 }, {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 header: 'Text',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 dataIndex: 'text',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 flex: 1,
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 editor: {
664
6fe3cef53e74 Field Validity in MKommentar Grid
Dustin Demuth <dustin@intevation.de>
parents: 626
diff changeset
88 allowBlank: false,
6fe3cef53e74 Field Validity in MKommentar Grid
Dustin Demuth <dustin@intevation.de>
parents: 626
diff changeset
89 maxLength: 1000,
6fe3cef53e74 Field Validity in MKommentar Grid
Dustin Demuth <dustin@intevation.de>
parents: 626
diff changeset
90 enforceMaxLength: true
596
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 }];
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 this.initData();
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 this.callParent(arguments);
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 },
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 initData: function() {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 if (this.store) {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 this.store.removeAll();
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 else {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 this.store = Ext.create('Lada.store.MKommentare');
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 this.store.load({
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 params: {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 messungsId: this.recordId
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 });
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 });

http://lada.wald.intevation.org