annotate app/view/widgets/LadaForm.js @ 494:f699f6683b16

Fixed typo in pflichtmessgroessen store.
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 03 Nov 2014 12:11:06 +0100
parents 850ccfe5f3c4
children 7c0653e8d9f7
rev   line source
472
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 406
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 406
diff changeset
2 * Software engineering by Intevation GmbH
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 406
diff changeset
3 *
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 406
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 406
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 406
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 406
diff changeset
7 */
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 406
diff changeset
8
283
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
9 /**
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
10 * Generic Lada specific form.
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
11 *
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
12 * See http://moduscreate.com/expert-ext-js-model-integration-in-forms/ for
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
13 * more details
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
14 */
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
15 Ext.define('Lada.view.widgets.LadaForm', {
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
16 extend: 'Ext.form.Panel',
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
17
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
18 alias: 'widget.ladaform',
283
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
19 bodyPadding: '10 10',
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
20 border: 0,
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
21
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
22 /**
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
23 * Can be a reference to a model instance or a model class name.
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
24 */
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
25 model: null,
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
26 /**
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
27 * Set to the id of the model instance and the model will be loaded for you.
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
28 * Only applicable if model provided is a model class name (string).
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
29 */
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
30 modelId: null,
283
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
31 /**
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
32 * List of errors in the form. Typically set after the server validates the form submission
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
33 */
75
4a82e28dfcc4 Translate error codes and store them as attributes of the form
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 74
diff changeset
34 errors: null,
283
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
35 /**
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
36 * List of warnings in the form. Typically set after the server validates the form submission
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
37 */
75
4a82e28dfcc4 Translate error codes and store them as attributes of the form
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 74
diff changeset
38 warnings: null,
283
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
39 /**
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
40 * The generic (error) message for the form. Typically set after the server validates the form submission
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
41 */
75
4a82e28dfcc4 Translate error codes and store them as attributes of the form
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 74
diff changeset
42 message: null,
283
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
43 /**
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
44 * Flag to indicate if the validation succeeds. Typically set after the server validates the form submission
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
45 */
133
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
46 success: null,
283
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
47 /**
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
48 * Flag to indicate if the form should be rendered in readonly mode. Will
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
49 * be set after calling the {setReadOnly} function.
dec0893d38e3 Added docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 280
diff changeset
50 */
87
ee1d1305dcff Added field for netzbetreiber. Is needed because of FK constraints.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 85
diff changeset
51 readonly: false,
75
4a82e28dfcc4 Translate error codes and store them as attributes of the form
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 74
diff changeset
52
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
53 initComponent: function() {
491
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
54 this.callParent(arguments);
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
55
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
56 this.getForm().trackResetOnLoad = true; //Workaround
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
57
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
58 if (Ext.isString(this.model)) {
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
59 //Load a model to be updated
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
60 if (this.modelId) {
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
61 Ext.ClassManager.get(this.model).load(this.modelId, {
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
62 failure: this.onModelLoadFailure,
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
63 success: this.onModelLoadSuccess,
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
64 scope: this
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
65 });
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
66 //Load an empty record to be inserted
491
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
67 }
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
68 else {
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
69 this.bindModel(Ext.create(this.model, {}));
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
70 }
491
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
71 }
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
72 else {
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
73
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
74 //Bind the provided model to be updated
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
75 this.bindModel(this.model);
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
76
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
77 }
491
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
78 this.addEvents(
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
79 'loadsuccess',
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
80 'loadfailure',
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
81 'savesuccess',
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
82 'savefailure');
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
83 },
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
84
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
85 bindModel: function(model) {
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
86 this.model = model;
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
87 this.loadRecord(model);
189
214d1b274a50 As the model now should have a readonly flag, the check if the form must be
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 188
diff changeset
88 // Set the form to readonly if the models readonly attribute is
211
401d559e0461 Fix rendering the form readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 189
diff changeset
89 // true
401d559e0461 Fix rendering the form readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 189
diff changeset
90 if (model.get('readonly') === true) {
189
214d1b274a50 As the model now should have a readonly flag, the check if the form must be
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 188
diff changeset
91 this.setReadOnly(true);
214d1b274a50 As the model now should have a readonly flag, the check if the form must be
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 188
diff changeset
92 }
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
93 },
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
94
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
95 commit: function(callback, scope) {
84
5ad82cff1a21 Only submit form if internal validation is ok.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 83
diff changeset
96 if (this.form.isDirty() && this.form.isValid()) {
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
97 this.form.updateRecord(this.model);
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
98
133
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
99 var data = this.model.getAllData();
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
100 var baseUrl = this.model.getProxy().url;
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
101 var url = baseUrl;
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
102 var method = "POST";
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
103 if (this.model.getId()) {
490
446e99cfd425 Updated views and controllers using the new model and stores.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 472
diff changeset
104 url += this.model.getId();
133
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
105 method = "PUT";
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
106 }
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
107
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
108 Ext.Ajax.request({
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
109 url: url,
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
110 jsonData: data,
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
111 method: method,
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
112 callback: function(option, success, response) {
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
113 this.parseResponse(response);
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
114 if (this.success) {
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
115 console.log('Save was successfull');
255
82118c01bc52 #57: Open Edit-Dialog after creating a new Probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 228
diff changeset
116 this.fireEvent('savesuccess', this, this.model, response);
491
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
117 }
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
118 else {
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
119 console.log('Save was not successfull');
75
4a82e28dfcc4 Translate error codes and store them as attributes of the form
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 74
diff changeset
120 this.form.markInvalid(this.errors);
255
82118c01bc52 #57: Open Edit-Dialog after creating a new Probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 228
diff changeset
121 this.fireEvent('savefailure', this, this.model, response);
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
122 }
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
123 },
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
124 scope: this
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
125 });
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
126 }
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
127 },
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
128
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
129 onModelLoadSuccess: function(record, operation) {
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
130 this.bindModel(record);
406
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
131 this.parseResponse(operation.response);
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
132 this.fireEvent('loadsuccess', this, record, operation);
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
133 },
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
134
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
135 onModelLoadFailure: function(record, operation) {
406
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
136 this.parseResponse(operation.response);
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
137 this.fireEvent('loadfailure', this, record, operation);
74
5c58c0e8936b Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 66
diff changeset
138 },
5c58c0e8936b Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 66
diff changeset
139
5c58c0e8936b Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 66
diff changeset
140 translateReturnCodes: function(codes) {
5c58c0e8936b Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 66
diff changeset
141 var translated = {};
5c58c0e8936b Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 66
diff changeset
142 for (var k in codes) {
5c58c0e8936b Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 66
diff changeset
143 translated[k] = Lada.getApplication().bundle.getMsg(codes[k]);
5c58c0e8936b Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 66
diff changeset
144 }
5c58c0e8936b Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 66
diff changeset
145 return translated;
83
8525e3525538 Move parsing the response in a seperate function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 75
diff changeset
146 },
280
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
147 /**
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
148 * Will set the form into readonly state.
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
149 * @param {Boolean} Flag to indicate if the form should be set to readonly
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
150 * or not.
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
151 * @param {Array} [ignoreFields="[]"] A list of fieldnames to ignore.
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
152 */
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
153 setReadOnly: function (bReadOnly, ignoreFields) {
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
154 if(typeof(ignoreFields)==='undefined') {
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
155 ignoreFields = Array();
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
156 }
221
cf83b382dc02 setReadOnly now also iterates over the toolbars within the form and hide them
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 211
diff changeset
157 /* Iterate over all fields and set them readonly */
228
08144d625b2b Only iterate over fields of the form is readonly. This increases the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 221
diff changeset
158 if (bReadOnly) {
08144d625b2b Only iterate over fields of the form is readonly. This increases the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 221
diff changeset
159 this.getForm().getFields().each (function (field) {
280
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
160 // Check if the field name is in the list of fields to ignore
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
161 var ignore = false;
491
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
162 for (var i = ignoreFields.length - 1; i >= 0; i--) {
280
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
163 console.log(ignoreFields[i] + "===" + field.getName());
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
164 if (ignoreFields[i] === field.getName(true)) {
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
165 ignore = true;
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
166 };
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
167 };
228
08144d625b2b Only iterate over fields of the form is readonly. This increases the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 221
diff changeset
168 //field.setDisabled(bReadOnly);
280
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
169 if (!ignore) {
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
170 field.setReadOnly(true);
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
171 }
228
08144d625b2b Only iterate over fields of the form is readonly. This increases the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 221
diff changeset
172 });
08144d625b2b Only iterate over fields of the form is readonly. This increases the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 221
diff changeset
173 /* Iterate over all toolbars of lists and hide them */
08144d625b2b Only iterate over fields of the form is readonly. This increases the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 221
diff changeset
174 var childs = this.query('toolbar');
491
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
175 for (var i = childs.length - 1; i >= 0; i--) {
228
08144d625b2b Only iterate over fields of the form is readonly. This increases the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 221
diff changeset
176 childs[i].setVisible(false);
08144d625b2b Only iterate over fields of the form is readonly. This increases the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 221
diff changeset
177 }
361
8a3991b5c200 Only hide save buttons if there are no fields which should be ignore while
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 283
diff changeset
178 /*
8a3991b5c200 Only hide save buttons if there are no fields which should be ignore while
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 283
diff changeset
179 * Find Save-Button and hide it. Only hide it if there are not
8a3991b5c200 Only hide save buttons if there are no fields which should be ignore while
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 283
diff changeset
180 * fields left in the form which are editable
8a3991b5c200 Only hide save buttons if there are no fields which should be ignore while
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 283
diff changeset
181 * */
8a3991b5c200 Only hide save buttons if there are no fields which should be ignore while
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 283
diff changeset
182 if (ignoreFields.length == 0) {
8a3991b5c200 Only hide save buttons if there are no fields which should be ignore while
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 283
diff changeset
183 var win = this.up('window');
8a3991b5c200 Only hide save buttons if there are no fields which should be ignore while
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 283
diff changeset
184 var buttons = win.query('.button');
491
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
185 for (var j = buttons.length - 1; j >= 0; j--) {
361
8a3991b5c200 Only hide save buttons if there are no fields which should be ignore while
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 283
diff changeset
186 if (buttons[j].text === 'Speichern') {
8a3991b5c200 Only hide save buttons if there are no fields which should be ignore while
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 283
diff changeset
187 buttons[j].setVisible(false);
8a3991b5c200 Only hide save buttons if there are no fields which should be ignore while
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 283
diff changeset
188 };
270
0d6552bb28ea Add cancel Button to the editproben window and only show save button if the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 255
diff changeset
189 };
361
8a3991b5c200 Only hide save buttons if there are no fields which should be ignore while
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 283
diff changeset
190 }
221
cf83b382dc02 setReadOnly now also iterates over the toolbars within the form and hide them
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 211
diff changeset
191 }
85
079f99229eff Added function to mark the form as readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 84
diff changeset
192 },
491
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
193
133
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
194 parseResponse: function(response) {
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
195 var json = Ext.decode(response.responseText);
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
196 if (json) {
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
197 this.success = json.success;
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
198 this.errors = this.translateReturnCodes(json.errors);
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
199 this.warnings = this.translateReturnCodes(json.warnings);
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
200 this.message = Lada.getApplication().bundle.getMsg(json.message);
406
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
201 var e = Ext.Object.isEmpty(this.warnings);
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
202 if (!Ext.Object.isEmpty(this.warnings) ||
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
203 !Ext.Object.isEmpty(this.errors)) {
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
204 this.createMessages();
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
205 }
491
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
206 }
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
207 else {
211
401d559e0461 Fix rendering the form readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 189
diff changeset
208 this.setReadOnly(this.model.get('readonly'));
133
819bfedb70de Do not use the model.save mathod to store items in the databut but trigger a
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 87
diff changeset
209 }
406
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
210 },
491
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
211
406
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
212 createMessages: function() {
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
213 var messages = Ext.create('Ext.form.Panel', {
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
214 bodyPadding: '5 5 5 5'
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
215 });
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
216 for (var key in this.warnings) {
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
217 var label = Ext.create('Ext.container.Container', {
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
218 layout: 'hbox',
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
219 bodyPadding: '5 5 5 5',
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
220 items: [{
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
221 xtype: 'image',
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
222 src: 'gfx/icon-warning.gif',
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
223 width: 18,
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
224 height: 18
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
225 }, {
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
226 xtype: 'label',
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
227 text: key + ": " + this.warnings[key],
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
228 margin: '4 0 0 5'
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
229 }]
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
230 });
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
231 messages.insert(0, label);
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
232 }
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
233 for (var key in this.errors) {
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
234 var label = Ext.create('Ext.container.Container', {
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
235 layout: 'hbox',
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
236 bodyPadding: '5 5 5 5',
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
237 items: [{
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
238 xtype: 'image',
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
239 src: 'gfx/icon-error.gif',
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
240 width: 18,
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
241 height: 18
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
242 }, {
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
243 xtype: 'label',
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
244 text: key + ": " + this.errors[key],
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
245 margin: '4 0 0 5'
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
246 }]
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
247 });
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
248 messages.insert(0, label);
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
249 }
de73dc41f1d3 Show warnings in proben edit form.
Raimund Renkert <rrenkert@intevation.de>
parents: 361
diff changeset
250 this.insert(0, messages);
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
251 }
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
252 });

http://lada.wald.intevation.org