Mercurial > lada > lada-client
comparison app/controller/form/Ortszuordnung.js @ 1343:cd16b30dbc10
correct behaviour of 'reverting changes' in ortszuordnung
author | Maximilian Krambach <mkrambach@intevation.de> |
---|---|
date | Mon, 06 Feb 2017 11:29:07 +0100 |
parents | 2e8eba3918b1 |
children | 2fc8e2b3c456 |
comparison
equal
deleted
inserted
replaced
1342:d5e270fa91e4 | 1343:cd16b30dbc10 |
---|---|
61 } | 61 } |
62 formPanel.getForm().getRecord().save({ | 62 formPanel.getForm().getRecord().save({ |
63 success: function(record, response) { | 63 success: function(record, response) { |
64 var json = Ext.decode(response.response.responseText); | 64 var json = Ext.decode(response.response.responseText); |
65 if (json) { | 65 if (json) { |
66 button.setDisabled(true); | |
67 formPanel.clearMessages(); | 66 formPanel.clearMessages(); |
68 formPanel.setRecord(record); | 67 formPanel.setRecord(record); |
69 formPanel.setMessages(json.errors, json.warnings); | 68 formPanel.setMessages(json.errors, json.warnings); |
70 formPanel.up('window').parentWindow.initData(); | 69 formPanel.up('window').parentWindow.initData(); |
70 button.setDisabled(true); | |
71 button.up('toolbar').down( | |
72 'button[action=revert]').setDisabled(true); | |
71 } | 73 } |
72 //try to refresh the Grid of the Probe | 74 //try to refresh the Grid of the Probe |
73 try { | 75 try { |
74 formPanel.up('window').parentWindow | 76 formPanel.up('window').parentWindow |
75 .down('ortszuordnunggrid').store.reload(); | 77 .down('ortszuordnunggrid').store.reload(); |
108 */ | 110 */ |
109 revert: function(button) { | 111 revert: function(button) { |
110 var form = button.up('form'); | 112 var form = button.up('form'); |
111 var osg = button.up('window').down('ortstammdatengrid'); | 113 var osg = button.up('window').down('ortstammdatengrid'); |
112 var recordData = form.getForm().getRecord().data; | 114 var recordData = form.getForm().getRecord().data; |
113 var currentOrt = null; | 115 var currentOrt = recordData.ortId; |
114 if (recordData.ortId !== undefined) { | |
115 currentOrt = recordData.ortId[0]; | |
116 } else { | |
117 currentOrt = recordData.ort; | |
118 } | |
119 var record = osg.store.getById(currentOrt); | 116 var record = osg.store.getById(currentOrt); |
120 var selmod = osg.getView().getSelectionModel(); | 117 var selmod = osg.getView().getSelectionModel(); |
121 form.getForm().reset(); | 118 form.getForm().reset(); |
122 var selmod = osg.getView().getSelectionModel(); | 119 form.setOrt(null, record); |
120 button.setDisabled(true); | |
121 button.up('toolbar').down('button[action=save]').setDisabled(true); | |
122 var selmod = osg.getView().getSelectionModel(); | |
123 selmod.select(record); | 123 selmod.select(record); |
124 }, | 124 }, |
125 | 125 |
126 /** | 126 /** |
127 * When the button is Active, a Record can be selected. | 127 * When the button is Active, a Record can be selected. |
188 /** | 188 /** |
189 * The validitychange function enables or disables the save button which | 189 * The validitychange function enables or disables the save button which |
190 * is present in the toolbar of the form. | 190 * is present in the toolbar of the form. |
191 */ | 191 */ |
192 validityChange: function(form, valid) { | 192 validityChange: function(form, valid) { |
193 if (form.isDirty()) { | 193 // the form itself seems to be always dirty because of the ortinfo |
194 // values put into the form at later moments. Check whether a real | |
195 // commit field is dirty | |
196 if (form.findField('ortszusatztext').isDirty() | |
197 || form.findField('ortszuordnungTyp').isDirty() | |
198 || form.findField('ortId').isDirty()) { | |
194 form.owner.down('button[action=revert]').setDisabled(false); | 199 form.owner.down('button[action=revert]').setDisabled(false); |
195 if (valid && form.getValues().ortId !== '') { | 200 if (valid && form.getValues().ortId !== '') { |
196 form.owner.down('button[action=save]').setDisabled(false); | 201 form.owner.down('button[action=save]').setDisabled(false); |
197 } else { | 202 } else { |
198 form.owner.down('button[action=save]').setDisabled(true); | 203 form.owner.down('button[action=save]').setDisabled(true); |