Mercurial > lada > lada-client
comparison app/controller/form/Ortszuordnung.js @ 1291:e9f812528324
ortszuordnung form changes
removed discard button
cursor change if new position is to be selected on map
display of GemeindeId and Staat in ortzuordnung
author | Maximilian Krambach <mkrambach@intevation.de> |
---|---|
date | Wed, 01 Feb 2017 18:00:59 +0100 |
parents | bfdc00c24baf |
children | 16a80ca16732 |
comparison
equal
deleted
inserted
replaced
1290:d17501b967f2 | 1291:e9f812528324 |
---|---|
20 'ortszuordnungform button[action=setOrt]': { | 20 'ortszuordnungform button[action=setOrt]': { |
21 toggle: this.chooseLocation | 21 toggle: this.chooseLocation |
22 }, | 22 }, |
23 'ortszuordnungform button[action=save]': { | 23 'ortszuordnungform button[action=save]': { |
24 click: this.save | 24 click: this.save |
25 }, | |
26 'ortszuordnungform button[action=discard]': { | |
27 click: this.discard | |
28 }, | 25 }, |
29 'ortszuordnungform': { | 26 'ortszuordnungform': { |
30 validitychange: this.validityChange, | 27 validitychange: this.validityChange, |
31 dirtychange: this.validityChange | 28 dirtychange: this.validityChange |
32 } | 29 } |
71 formPanel.getForm().getRecord().save({ | 68 formPanel.getForm().getRecord().save({ |
72 success: function(record, response) { | 69 success: function(record, response) { |
73 var json = Ext.decode(response.response.responseText); | 70 var json = Ext.decode(response.response.responseText); |
74 if (json) { | 71 if (json) { |
75 button.setDisabled(true); | 72 button.setDisabled(true); |
76 button.up('toolbar').down('button[action=discard]') | |
77 .setDisabled(true); | |
78 formPanel.clearMessages(); | 73 formPanel.clearMessages(); |
79 formPanel.setRecord(record); | 74 formPanel.setRecord(record); |
80 formPanel.setMessages(json.errors, json.warnings); | 75 formPanel.setMessages(json.errors, json.warnings); |
81 formPanel.up('window').parentWindow.initData(); | 76 formPanel.up('window').parentWindow.initData(); |
82 } | 77 } |
89 | 84 |
90 } | 85 } |
91 }, | 86 }, |
92 failure: function(record, response) { | 87 failure: function(record, response) { |
93 button.setDisabled(true); | 88 button.setDisabled(true); |
94 button.up('toolbar').down('button[action=discard]') | |
95 .setDisabled(true); | |
96 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); | 89 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); |
97 var json = response.request.scope.reader.jsonData; | 90 var json = response.request.scope.reader.jsonData; |
98 if (json) { | 91 if (json) { |
99 if(Object.keys(json.errors).length > 0 || | 92 if(Object.keys(json.errors).length > 0 || |
100 Object.keys(json.warnings).length > 0) { | 93 Object.keys(json.warnings).length > 0) { |
114 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'), | 107 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'), |
115 i18n.getMsg('err.msg.response.body')); | 108 i18n.getMsg('err.msg.response.body')); |
116 } | 109 } |
117 } | 110 } |
118 }); | 111 }); |
119 }, | |
120 | |
121 /** | |
122 * The discard function resets the Location form | |
123 * to its original state. | |
124 */ | |
125 discard: function(button) { | |
126 var formPanel = button.up('form'); | |
127 var record = formPanel.getForm().getRecord(); | |
128 formPanel.getForm().loadRecord(record); | |
129 try { | |
130 if (record.get('ortId') !== undefined) { | |
131 formPanel.setOrt(record.get('ortId')); | |
132 } else { | |
133 formPanel.setOrt(record.get('ort')); | |
134 } | |
135 formPanel.down('button[action=setOrt]').toggle(false); | |
136 } | |
137 catch (e) { | |
138 } | |
139 }, | 112 }, |
140 | 113 |
141 /** | 114 /** |
142 * When the button is Active, a Record can be selected. | 115 * When the button is Active, a Record can be selected. |
143 * If the Record was selected from a grid this function | 116 * If the Record was selected from a grid this function |
167 osg.removeListener('select',oForm.setOrt, oForm); | 140 osg.removeListener('select',oForm.setOrt, oForm); |
168 } | 141 } |
169 }, | 142 }, |
170 | 143 |
171 /** | 144 /** |
172 * The validitychange function enables or disables the save and discard | 145 * The validitychange function enables or disables the save button which |
173 * button which are present in the toolbar of the form. | 146 * is present in the toolbar of the form. |
174 */ | 147 */ |
175 validityChange: function(form, valid) { | 148 validityChange: function(form, valid) { |
176 if (form.isDirty()) { | 149 if (form.isDirty()) { |
177 form.owner.down('button[action=discard]').setDisabled(false); | |
178 if (valid) { | 150 if (valid) { |
179 if (form.getValues().ortId !== '' | 151 if (form.getValues().ortId !== '' |
180 && /[UEZA]/.test(form.getValues().ortszuordnungTyp)) { | 152 && /[UEZA]/.test(form.getValues().ortszuordnungTyp)) { |
181 // valid ortzuordnung(Probe) | 153 // valid ortzuordnung(Probe) |
182 form.owner.down('button[action=save]').setDisabled(false); | 154 form.owner.down('button[action=save]').setDisabled(false); |
183 } else if (form.getValues().ort !== '' | 155 } else if (form.getValues().ort !== '' |
184 && /[UEZA]/.test(form.getValues().ortsTyp)) { | 156 && /[UEZA]/.test(form.getValues().ortsTyp)) { |
185 // valid ortzuordnung(messprogramm) | 157 // valid ortzuordnung(messprogramm) |
186 form.owner.down('button[action=save]').setDisabled(false); | 158 form.owner.down('button[action=save]').setDisabled(false); |
187 } else { | 159 } else { |
192 form.owner.down('button[action=save]').setDisabled(true); | 164 form.owner.down('button[action=save]').setDisabled(true); |
193 } | 165 } |
194 } else { | 166 } else { |
195 //not dirty | 167 //not dirty |
196 form.owner.down('button[action=save]').setDisabled(true); | 168 form.owner.down('button[action=save]').setDisabled(true); |
197 form.owner.down('button[action=discard]').setDisabled(true); | |
198 } | 169 } |
199 } | 170 } |
200 }); | 171 }); |