# HG changeset patch # User Maximilian Krambach # Date 1486132278 -3600 # Node ID cf73b7d7cf99104a1809b765b874d1ccf4451f58 # Parent c413ec1aaa2e820c9983191337b84c877e7909cc reinserted discard button and functionality diff -r c413ec1aaa2e -r cf73b7d7cf99 app/controller/form/Ortszuordnung.js --- a/app/controller/form/Ortszuordnung.js Fri Feb 03 15:26:41 2017 +0100 +++ b/app/controller/form/Ortszuordnung.js Fri Feb 03 15:31:18 2017 +0100 @@ -23,6 +23,9 @@ 'ortszuordnungform button[action=save]': { click: this.save }, + 'ortszuordnungform button[action=revert]': { + click: this.revert + }, 'ortszuordnungform': { validitychange: this.validityChange, dirtychange: this.validityChange @@ -47,7 +50,6 @@ } var data = formPanel.getForm().getFieldValues(false); var i18n = Lada.getApplication().bundle; - //TODO: the forms seem not to submit anything into record. var recordData = formPanel.getForm().getRecord().data; if (recordData['probeId'] !== undefined) { // TODO: as model.ort.ortId and model.ortszuordnung.ortId coexist, @@ -110,6 +112,26 @@ }, /** + * reverts the form to the currently saved state + */ + revert: function(button) { + var form = button.up('form'); + var osg = button.up('window').down('ortstammdatengrid'); + var recordData = form.getForm().getRecord().data; + var currentOrt = null; + if (recordData.ortId !== undefined) { + currentOrt = recordData.ortId; + } else { + currentOrt = recordData.ort; + } + var record = osg.store.getById(currentOrt); + var selmod = osg.getView().getSelectionModel(); + form.getForm().reset(); + var selmod = osg.getView().getSelectionModel(); + selmod.select(record); + }, + + /** * When the button is Active, a Record can be selected. * If the Record was selected from a grid this function * sets the ortzuordnung.