Mercurial > lada > lada-client
comparison app/view/window/Messprogramm.js @ 759:b7484c7da2d4
Unified the Messprogramm windows. Unfortunately the Roweditor of Messmethodengrid is broken in this commit. This is due to the fact that the Mmt store is noit autoloaded anymore
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Thu, 07 May 2015 10:55:44 +0200 |
parents | |
children | 2e7e1a8bf79f |
comparison
equal
deleted
inserted
replaced
758:b2fcbdc4969d | 759:b7484c7da2d4 |
---|---|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out | |
6 * the documentation coming with IMIS-Labordaten-Application for details. | |
7 */ | |
8 | |
9 /* | |
10 * Window to edit a Messprogramm | |
11 */ | |
12 Ext.define('Lada.view.window.Messprogramm', { | |
13 extend: 'Ext.window.Window', | |
14 alias: 'widget.messprogramm', | |
15 | |
16 requires: [ | |
17 'Lada.view.form.Messprogramm', | |
18 'Lada.view.grid.Messmethoden', | |
19 ], | |
20 | |
21 collapsible: true, | |
22 maximizable: true, | |
23 autoShow: true, | |
24 autoScroll: true, | |
25 layout: 'fit', | |
26 constrain: true, | |
27 | |
28 record: null, | |
29 | |
30 initComponent: function() { | |
31 var i18n = Lada.getApplication().bundle; | |
32 | |
33 if (this.record == null) { | |
34 this.title = i18n.getMsg('messprogramm.window.create.title'); | |
35 } | |
36 else { | |
37 this.title = i18n.getMsg('messprogramm.window.edit.title'); | |
38 } | |
39 | |
40 this.buttons = [{ | |
41 text: i18n.getMsg('close'), | |
42 scope: this, | |
43 handler: this.close | |
44 }]; | |
45 this.width = 700; | |
46 | |
47 // add listeners to change the window appearence when it becomes inactive | |
48 this.on({ | |
49 activate: function(){ | |
50 this.getEl().removeCls('window-inactive'); | |
51 }, | |
52 deactivate: function(){ | |
53 this.getEl().addCls('window-inactive'); | |
54 } | |
55 }); | |
56 | |
57 this.height = Ext.getBody().getViewSize().height - 30; | |
58 // InitialConfig is the config object passed to the constructor on | |
59 // creation of this window. We need to pass it throuh to the form as | |
60 // we need the "Id" param to load the correct item. | |
61 this.items = [{ | |
62 border: 0, | |
63 autoScroll: true, | |
64 items: [{ | |
65 xtype: 'messprogrammform', | |
66 recordId: this.record? this.record.get('id') : null | |
67 }, { | |
68 //Messmethoden | |
69 xtype: 'fieldset', | |
70 title: i18n.getMsg('mmtmessprogramm.form.fieldset.title'), | |
71 autoScroll: true, | |
72 margin: 5, | |
73 layout: { | |
74 type: 'hbox', | |
75 }, | |
76 items: [{ | |
77 xtype: 'messmethodengrid', | |
78 recordId: this.record? this.record.get('id') : null, | |
79 disabled: this.record? false : true, | |
80 flex: 1 | |
81 }] | |
82 }] | |
83 }]; | |
84 this.callParent(arguments); | |
85 }, | |
86 | |
87 /** | |
88 * Init Data is longer than in other windows. | |
89 * If the Window was used to CREATE a Messprogramm, | |
90 * it will load an empty record | |
91 * if it was used to EDIT an existing Messprogramm, | |
92 * it will load this record AND create a grid to | |
93 * enable the editing of Messmethoden | |
94 * which are associated to the Messprogramm | |
95 */ | |
96 initData: function() { | |
97 var i18n = Lada.getApplication().bundle; | |
98 this.clearMessages(); | |
99 me = this; | |
100 | |
101 // If a record was passed to this window, | |
102 // create a Edit window | |
103 if (this.record) { | |
104 this.setLoading(true); | |
105 Ext.ClassManager.get('Lada.model.Messprogramm').load(this.record.get('id'), { | |
106 failure: function(record, action) { | |
107 me.setLoading(false); | |
108 // TODO | |
109 console.log('An unhandled Failure occured. See following Response and Record'); | |
110 console.log(action); | |
111 console.log(record); | |
112 }, | |
113 success: function(record, response) { | |
114 this.down('messprogrammform').setRecord(record); | |
115 this.record = record; | |
116 | |
117 var json = Ext.decode(response.response.responseText); | |
118 if (json) { | |
119 this.setMessages(json.errors, json.warnings); | |
120 } | |
121 // If the Messprogramm is ReadOnly, disable Inputfields and grids | |
122 if (this.record.get('readonly') === true) { | |
123 this.down('messprogrammform').setReadOnly(true); | |
124 this.disableChildren(); | |
125 } | |
126 else { | |
127 this.down('messprogrammform').setReadOnly(false); | |
128 this.enableChildren(); | |
129 } | |
130 me.setLoading(false); | |
131 }, | |
132 scope: this | |
133 }); | |
134 | |
135 } | |
136 // Create a Create Window | |
137 else { | |
138 var record = Ext.create('Lada.model.Messprogramm'); | |
139 this.down('messprogrammform').setRecord(record); | |
140 } | |
141 }, | |
142 | |
143 //This was used in a Probewindow, I left it here for reference... | |
144 /* | |
145 enableAddMessungen: function() { | |
146 this.down('fset[name=messungen]').down('messunggrid').setReadOnly(false); | |
147 }, | |
148 */ | |
149 | |
150 disableChildren: function() { | |
151 // there are no children.... | |
152 }, | |
153 | |
154 enableChildren: function() { | |
155 // there are no children.... | |
156 }, | |
157 | |
158 setMessages: function(errors, warnings) { | |
159 this.down('messprogrammform').setMessages(errors, warnings); | |
160 }, | |
161 | |
162 clearMessages: function() { | |
163 this.down('messprogrammform').clearMessages(); | |
164 } | |
165 }); |