annotate app/view/widgets/LadaForm.js @ 280:1afccc0cab90

Issue55: Added ignoreFields parameter to the setReadonly function to be able to ignore some fields when setting the form into read only state.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Thu, 08 Aug 2013 11:11:55 +0200
parents 0d6552bb28ea
children dec0893d38e3
rev   line source
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
1 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
2 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
3
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
4 alias: 'widget.ladaform',
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
5 /**
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
6 * http://moduscreate.com/expert-ext-js-model-integration-in-forms/
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
7 */
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
8
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
9 /**
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
10 * 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
11 */
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
12 model: null,
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
13 /**
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
14 * 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
15 * 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
16 */
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
17 modelId: null,
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
18 bodyPadding: '10 10',
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
19 border: 0,
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
20
75
4a82e28dfcc4 Translate error codes and store them as attributes of the form
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 74
diff changeset
21 errors: null,
4a82e28dfcc4 Translate error codes and store them as attributes of the form
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 74
diff changeset
22 warnings: null,
4a82e28dfcc4 Translate error codes and store them as attributes of the form
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 74
diff changeset
23 message: null,
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
24 success: null,
87
ee1d1305dcff Added field for netzbetreiber. Is needed because of FK constraints.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 85
diff changeset
25 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
26
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
27 initComponent: function() {
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
28
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
29 this.callParent();
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
30
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
31 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
32
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
33 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
34
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
35 //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
36 if (this.modelId) {
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
37
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
38 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
39 failure: this.onModelLoadFailure,
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
40 success: this.onModelLoadSuccess,
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
41 scope: this
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
42 });
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
43
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
44 //Load an empty record to be inserted
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
45 } else {
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
46 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
47 }
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
48
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
49 } else {
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
50
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
51 //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
52 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
53
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
54 }
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.addEvents('loadsuccess', 'loadfailure', 'savesuccess', 'savefailure');
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
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
59 bindModel: function(model) {
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
60 this.model = model;
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
61 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
62 // 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
63 // true
401d559e0461 Fix rendering the form readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 189
diff changeset
64 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
65 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
66 }
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
67 },
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
68
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
69 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
70 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
71 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
72
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
73 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
74 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
75 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
76 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
77 if (this.model.getId()) {
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
78 url += this.model.getEidi();
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
79 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
80 }
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
81
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
82 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
83 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
84 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
85 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
86 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
87 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
88 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
89 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
90 this.fireEvent('savesuccess', 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
91 } else {
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
92 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
93 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
94 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
95 }
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
96 },
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
97 scope: this
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
98 });
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
99 }
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
100 },
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
101
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
102 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
103 this.bindModel(record);
83
8525e3525538 Move parsing the response in a seperate function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 75
diff changeset
104 this.parseResponse(operation);
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
105 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
106 },
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
107
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
108 onModelLoadFailure: function(record, operation) {
83
8525e3525538 Move parsing the response in a seperate function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 75
diff changeset
109 this.parseResponse(operation);
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
110 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
111 },
5c58c0e8936b Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 66
diff changeset
112
5c58c0e8936b Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 66
diff changeset
113 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
114 var translated = {};
5c58c0e8936b Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 66
diff changeset
115 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
116 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
117 }
5c58c0e8936b Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 66
diff changeset
118 return translated;
83
8525e3525538 Move parsing the response in a seperate function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 75
diff changeset
119 },
280
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
120 /**
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
121 * 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
122 * @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
123 * 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
124 * @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
125 */
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
126 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
127 console.log(ignoreFields);
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
128 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
129 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
130 }
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
131 /* 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
132 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
133 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
134 // 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
135 var ignore = false;
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
136 for (var i = ignoreFields.length - 1; i >= 0; i--){
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
137 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
138 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
139 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
140 };
1afccc0cab90 Issue55: Added ignoreFields parameter to the setReadonly function to be able
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 270
diff changeset
141 };
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
142 //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
143 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
144 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
145 }
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
146 });
08144d625b2b Only iterate over fields of the form is readonly. This increases the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 221
diff changeset
147 /* 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
148 var childs = this.query('toolbar');
08144d625b2b Only iterate over fields of the form is readonly. This increases the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 221
diff changeset
149 for (var i = childs.length - 1; i >= 0; i--){
08144d625b2b Only iterate over fields of the form is readonly. This increases the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 221
diff changeset
150 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
151 }
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
152 /* Find Save-Button and hide it */
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
153 var win = this.up('window');
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
154 var buttons = win.query('.button');
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
155 for (var j = buttons.length - 1; j >= 0; j--){
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
156 if (buttons[j].text === 'Speichern') {
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
157 buttons[j].setVisible(false);
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
158 };
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
159 };
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
160 }
85
079f99229eff Added function to mark the form as readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 84
diff changeset
161 },
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
162 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
163 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
164 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
165 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
166 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
167 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
168 this.message = Lada.getApplication().bundle.getMsg(json.message);
185
df5dcdff7b69 Enabled readonly mode
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 133
diff changeset
169 } else {
211
401d559e0461 Fix rendering the form readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 189
diff changeset
170 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
171 }
66
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
172 }
fcb63271d1bd Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
173 });

http://lada.wald.intevation.org