comparison app/view/window/MessprogrammEdit.js @ 757:b8502964f5c3

Added missing files. Added MmtMockup
author Dustin Demuth <dustin@intevation.de>
date Wed, 06 May 2015 14:15:37 +0200
parents
children b2fcbdc4969d
comparison
equal deleted inserted replaced
756:f2db1ae1d012 757:b8502964f5c3
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.MessprogrammEdit', {
13 extend: 'Ext.window.Window',
14 alias: 'widget.messprogrammedit',
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 Ext.Msg.create(i18n.getMsg('err.msg.generic.title'),
35 i18n.getMsg('err.msg.novalidmessprogram'));
36 this.callParent(arguments);
37 return;
38 }
39 this.title = i18n.getMsg('messprogramm.window.edit.title');
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.get('id')
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 flex: 1
79 }, {
80 xtype: 'messmethodengrid',
81 flex: 1
82 }]
83 }]
84 }];
85 this.callParent(arguments);
86 },
87
88 initData: function() {
89 this.setLoading(true);
90 this.clearMessages();
91 me = this;
92 Ext.ClassManager.get('Lada.model.Messprogramm').load(this.record.get('id'), {
93 failure: function(record, action) {
94 me.setLoading(false);
95 // TODO
96 console.log('An unhandled Failure occured. See following Response and Record');
97 console.log(action);
98 console.log(record);
99 },
100 success: function(record, response) {
101 this.down('messprogrammform').setRecord(record);
102 this.record = record;
103 owner = this.record.get('owner');
104
105 // If this would be A probe, it would be always
106 // allowed to add Messungen:
107 /*
108 if (owner) {
109 me.enableAddMessungen();
110 }
111 */
112
113 var json = Ext.decode(response.response.responseText);
114 if (json) {
115 this.setMessages(json.errors, json.warnings);
116 }
117 // If the Messprogramm is ReadOnly, disable Inputfields and grids
118 if (this.record.get('readonly') === true) {
119 this.down('messprogrammform').setReadOnly(true);
120 this.disableChildren();
121 }
122 else {
123 this.down('messprogrammform').setReadOnly(false);
124 this.enableChildren();
125 }
126 me.setLoading(false);
127 },
128 scope: this
129 });
130 },
131
132 //This was used in a Probewindow, I left it here for reference...
133 /*
134 enableAddMessungen: function() {
135 this.down('fset[name=messungen]').down('messunggrid').setReadOnly(false);
136 },
137 */
138
139 disableChildren: function() {
140 // thera are no children....
141 },
142
143 enableChildren: function() {
144 // there are no children....
145 },
146
147 setMessages: function(errors, warnings) {
148 this.down('messprogrammform').setMessages(errors, warnings);
149 },
150
151 clearMessages: function() {
152 this.down('messprogrammform').clearMessages();
153 }
154 });

http://lada.wald.intevation.org