comparison app/view/window/ProbeEdit.js @ 548:d47ee7439f44

Added new js files.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 06 Mar 2015 12:43:52 +0100
parents
children 48ee1adee0a2
comparison
equal deleted inserted replaced
547:f172b35a3b92 548:d47ee7439f44
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 Probe
11 */
12 Ext.define('Lada.view.window.ProbeEdit', {
13 extend: 'Ext.window.Window',
14 alias: 'widget.probenedit',
15
16 requires: [
17 'Lada.view.form.Probe',
18 'Lada.view.grid.Ort',
19 'Lada.view.grid.Probenzusatzwert',
20 'Lada.view.grid.PKommentar'
21 ],
22
23 collapsible: true,
24 maximizable: true,
25 autoShow: true,
26 autoScroll: true,
27 layout: 'fit',
28
29 record: null,
30
31 initComponent: function() {
32 if (this.record === null) {
33 Ext.Msg.alert('Keine valide Probe ausgewählt!');
34 this.callParent(arguments);
35 return;
36 }
37 this.title = '§3-Probe ' + this.record.get('probeId');
38 this.buttons = [{
39 text: 'Schließen',
40 scope: this,
41 handler: this.close
42 }];
43 this.width = 700;
44 this.height = Ext.getBody().getViewSize().height - 30;
45 // InitialConfig is the config object passed to the constructor on
46 // creation of this window. We need to pass it throuh to the form as
47 // we need the "modelId" param to load the correct item.
48
49 this.items = [{
50 border: 0,
51 autoScroll: true,
52 items: [{
53 xtype: 'probeform',
54 recordId: this.record.get('id')
55 }, {
56 xtype: 'fset',
57 name: 'orte',
58 title: 'Ortsangaben',
59 padding: '5, 5',
60 margin: 5,
61 items: [{
62 xtype: 'ortgrid',
63 recordId: this.record.get('id')
64 }]
65 }, {
66 xtype: 'fset',
67 name: 'probenzusaetzwerte',
68 title: 'Zusatzwerte',
69 padding: '5, 5',
70 margin: 5,
71 collapsible: true,
72 collapsed: true,
73 items: [{
74 xtype: 'probenzusatzwertgrid',
75 recordId: this.record.get('id')
76 }]
77 }, {
78 xtype: 'fset',
79 name: 'pkommentare',
80 title: 'Kommentare',
81 padding: '5, 5',
82 margin: 5,
83 collapsible: true,
84 collapsed: true,
85 items: [{
86 xtype: 'pkommentargrid',
87 recordId: this.record.get('id')
88 }]
89 }]
90 }];
91 this.callParent(arguments);
92 },
93
94 initData: function() {
95 this.clearMessages();
96 Ext.ClassManager.get('Lada.model.Probe').load(this.record.get('id'), {
97 failure: function(record, action) {
98 // TODO
99 },
100 success: function(record, response) {
101 this.down('probeform').setRecord(record);
102 var json = Ext.decode(response.response.responseText);
103 if (json) {
104 this.setMessages(json.errors, json.warnings);
105 }
106 },
107 scope: this
108 });
109 },
110
111 setMessages: function(errors, warnings) {
112 this.down('probeform').setMessages(errors, warnings);
113 var errorOrtText = '';
114 var errorOrt = false;
115 var warningOrtText = '';
116 var warningOrt = false;
117 var key;
118 var content;
119 var i;
120 var keyText;
121 var i18n = Lada.getApplication().bundle;
122 for (key in errors) {
123 if (key && key.contains('Ort')) {
124 errorOrt = true;
125 content = errors[key];
126 keyText = key[0].toUpperCase();
127 for (i = 0; i < content.length; i++) {
128 errorOrtText += keyText + ': ' +
129 i18n.getMsg(content[i].toString()) + '\n';
130 }
131 }
132 }
133 for (key in warnings) {
134 if (key && key.contains('Ort')) {
135 warningOrt = true;
136 content = warnings[key];
137 keyText = key[0].toUpperCase();
138 for (i = 0; i < content.length; i++) {
139 warningOrtText += keyText + ': ' +
140 i18n.getMsg(content[i].toString()) + '\n';
141 }
142 }
143 }
144 this.down('fset[name=orte]').showWarningOrError(
145 warningOrt,
146 warningOrtText === '' ? null : warningOrtText,
147 errorOrt,
148 errorOrtText === '' ? null : errorOrtText);
149 },
150
151 clearMessages: function() {
152 this.down('probeform').clearMessages();
153 this.down('fset[name=orte]').clearMessages();
154 }
155 });

http://lada.wald.intevation.org