Mercurial > lada > lada-client
comparison app/controller/form/Ortszuordnung.js @ 1347:2fc8e2b3c456
fix ortszuordnung 'revert' if record is new ortszuordnung
author | Maximilian Krambach <mkrambach@intevation.de> |
---|---|
date | Mon, 06 Feb 2017 12:33:00 +0100 |
parents | cd16b30dbc10 |
children |
comparison
equal
deleted
inserted
replaced
1346:8742d020c685 | 1347:2fc8e2b3c456 |
---|---|
111 revert: function(button) { | 111 revert: function(button) { |
112 var form = button.up('form'); | 112 var form = button.up('form'); |
113 var osg = button.up('window').down('ortstammdatengrid'); | 113 var osg = button.up('window').down('ortstammdatengrid'); |
114 var recordData = form.getForm().getRecord().data; | 114 var recordData = form.getForm().getRecord().data; |
115 var currentOrt = recordData.ortId; | 115 var currentOrt = recordData.ortId; |
116 var record = osg.store.getById(currentOrt); | |
117 var selmod = osg.getView().getSelectionModel(); | 116 var selmod = osg.getView().getSelectionModel(); |
118 form.getForm().reset(); | 117 form.getForm().reset(); |
119 form.setOrt(null, record); | 118 if (!currentOrt) { |
119 selmod.deselectAll(); | |
120 } else { | |
121 var record = osg.store.getById(currentOrt); | |
122 form.setOrt(null, record); | |
123 selmod.select(record); | |
124 } | |
120 button.setDisabled(true); | 125 button.setDisabled(true); |
121 button.up('toolbar').down('button[action=save]').setDisabled(true); | 126 button.up('toolbar').down('button[action=save]').setDisabled(true); |
122 var selmod = osg.getView().getSelectionModel(); | |
123 selmod.select(record); | |
124 }, | 127 }, |
125 | 128 |
126 /** | 129 /** |
127 * When the button is Active, a Record can be selected. | 130 * When the button is Active, a Record can be selected. |
128 * If the Record was selected from a grid this function | 131 * If the Record was selected from a grid this function |
188 /** | 191 /** |
189 * The validitychange function enables or disables the save button which | 192 * The validitychange function enables or disables the save button which |
190 * is present in the toolbar of the form. | 193 * is present in the toolbar of the form. |
191 */ | 194 */ |
192 validityChange: function(form, valid) { | 195 validityChange: function(form, valid) { |
193 // the form itself seems to be always dirty because of the ortinfo | 196 // the simple form.isDirty() check seems to fail for a lot of cases |
194 // values put into the form at later moments. Check whether a real | 197 var ortIdIsDirty = true; |
195 // commit field is dirty | 198 if (form.getRecord().data.ortId == form.findField('ortId').getValue()) { |
199 ortIdIsDirty = false; | |
200 } | |
196 if (form.findField('ortszusatztext').isDirty() | 201 if (form.findField('ortszusatztext').isDirty() |
197 || form.findField('ortszuordnungTyp').isDirty() | 202 || form.findField('ortszuordnungTyp').isDirty() |
198 || form.findField('ortId').isDirty()) { | 203 || ortIdIsDirty) { |
199 form.owner.down('button[action=revert]').setDisabled(false); | 204 form.owner.down('button[action=revert]').setDisabled(false); |
200 if (valid && form.getValues().ortId !== '') { | 205 if (valid && form.getValues().ortId !== '') { |
201 form.owner.down('button[action=save]').setDisabled(false); | 206 form.owner.down('button[action=save]').setDisabled(false); |
202 } else { | 207 } else { |
203 form.owner.down('button[action=save]').setDisabled(true); | 208 form.owner.down('button[action=save]').setDisabled(true); |