Mercurial > lada > lada-client
annotate app/view/widgets/LadaForm.js @ 162:5eb0cfac0e30
Added nested id attribute which comes in JSON response to the model as we need
it later in the grid view to be able to acess messungsIs and probeId in the
custom renderer.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Wed, 03 Jul 2013 14:02:35 +0200 |
parents | 819bfedb70de |
children | df5dcdff7b69 |
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); |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
62 }, |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
63 |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
64 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
|
65 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
|
66 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
|
67 |
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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 } |
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 |
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 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 console.log('Save was successfull'); |
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
|
85 this.fireEvent('savesuccess', this); |
66
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
86 } else { |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
87 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
|
88 this.form.markInvalid(this.errors); |
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
|
89 this.fireEvent('savefailure', this); |
66
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
90 } |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
91 }, |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
92 scope: this |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
93 }); |
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
|
94 |
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
|
95 //this.model.save({ |
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
|
96 // callback: function(records, operation) { |
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
|
97 // this.parseResponse(operation); |
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
|
98 // if (operation.wasSuccessful()) { |
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 // console.log('Save was successfull'); |
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 // this.fireEvent('savesuccess', this, records, operation); |
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 // } else { |
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 // console.log('Save was not successfull'); |
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 // this.form.markInvalid(this.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
|
104 // this.fireEvent('savefailure', this, records, operation); |
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 // } |
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 // if (callback) { |
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 // callback.call(scope || this, this, operation.wasSuccessful(), this.model); |
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 // } |
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 // }, |
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 // scope: this |
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 //}); |
66
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
112 } |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
113 }, |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
114 |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
115 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
|
116 this.bindModel(record); |
83
8525e3525538
Move parsing the response in a seperate function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
75
diff
changeset
|
117 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
|
118 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
|
119 }, |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
120 |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
121 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
|
122 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
|
123 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
|
124 }, |
5c58c0e8936b
Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
66
diff
changeset
|
125 |
5c58c0e8936b
Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
66
diff
changeset
|
126 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
|
127 var translated = {}; |
5c58c0e8936b
Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
66
diff
changeset
|
128 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
|
129 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
|
130 } |
5c58c0e8936b
Add function which translates the errorcodes returned from the server.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
66
diff
changeset
|
131 return translated; |
83
8525e3525538
Move parsing the response in a seperate function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
75
diff
changeset
|
132 }, |
85
079f99229eff
Added function to mark the form as readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
84
diff
changeset
|
133 setReadOnly: function (bReadOnly) { |
079f99229eff
Added function to mark the form as readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
84
diff
changeset
|
134 this.getForm().getFields().each (function (field) { |
079f99229eff
Added function to mark the form as readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
84
diff
changeset
|
135 //field.setDisabled(bReadOnly); |
079f99229eff
Added function to mark the form as readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
84
diff
changeset
|
136 field.setReadOnly(bReadOnly); |
079f99229eff
Added function to mark the form as readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
84
diff
changeset
|
137 }); |
079f99229eff
Added function to mark the form as readonly.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
84
diff
changeset
|
138 }, |
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
|
139 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
|
140 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 this.message = Lada.getApplication().bundle.getMsg(json.message); |
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
|
146 } |
87
ee1d1305dcff
Added field for netzbetreiber. Is needed because of FK constraints.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
85
diff
changeset
|
147 //this.setReadOnly(true); |
66
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
148 } |
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
|
149 // This parse method is used if the model.save() method is used to trigger |
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
|
150 // a request on the server side. In this case the response object is |
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
|
151 // different. |
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
|
152 //parseResponse: function(operation) { |
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
|
153 // this.errors = this.translateReturnCodes(operation.request.scope.reader.jsonData["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
|
154 // this.warnings = this.translateReturnCodes(operation.request.scope.reader.jsonData["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
|
155 // this.message = Lada.getApplication().bundle.getMsg(operation.request.scope.reader.jsonData["message"]); |
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
|
156 // //this.setReadOnly(true); |
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
|
157 //} |
66
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
158 |
fcb63271d1bd
Created custom Form element which is bound to the model
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
159 }); |