Mercurial > lada > lada-client
diff app/controller/form/Ortszuordnung.js @ 1021:1df6b6210b42 stammdatengrids
WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Thu, 04 Feb 2016 16:31:46 +0100 |
parents | 75ce503ab296 |
children | 6d33a84979e4 |
line wrap: on
line diff
--- a/app/controller/form/Ortszuordnung.js Fri Jan 29 14:51:17 2016 +0100 +++ b/app/controller/form/Ortszuordnung.js Thu Feb 04 16:31:46 2016 +0100 @@ -17,6 +17,9 @@ */ init: function() { this.control({ + 'ortszuordnungform button[action=setOrt]': { + toggle: this.pickOrt + }, 'ortszuordnungform button[action=save]': { click: this.save }, @@ -25,9 +28,6 @@ }, 'ortszuordnungform': { dirtychange: this.dirtyForm - }, - 'ortszuordnungform combobox[name=ort]': { - select: this.updateDetails } }); }, @@ -38,6 +38,17 @@ * on failure, it will display an Errormessage */ save: function(button) { + + //try to disable ortPickerButton: + try { + var ob = this.up('form').down('ortszuordnungform button[action=setOrt]'); + if (ob.pressed) { + ob.toggle(false); + } + } + catch (e) { + } + var formPanel = button.up('ortszuordnungform'); var data = formPanel.getForm().getFieldValues(true); var i18n = Lada.getApplication().bundle; @@ -58,7 +69,6 @@ formPanel.setRecord(record); formPanel.setMessages(json.errors, json.warnings); formPanel.up('window').grid.store.reload(); - debugger; } }, failure: function(record, response) { @@ -98,6 +108,28 @@ }, /** + * When the button is Active, a Record can be selected. + * If the Record was selected from a grid this function + * sets the ortzuordnung. + * TODO: Check if the selected Record is a ORT + * TODO: Enable picking from Maps + */ + pickOrt: function(button, pressed, opts) { + var i18n = Lada.getApplication().bundle; + var oForm = button.up('form'); + var osg = button.up('window').down('ortstammdatengrid'); + if (button.pressed) { + button.setText(i18n.getMsg('ortszuordnung.form.setOrt.pressed')); + osg.addListener('select',oForm.setOrt, oForm); + } + else { + button.setText(i18n.getMsg('ortszuordnung.form.setOrt')); + osg.removeListener('select',oForm.setOrt, oForm); + } + }, + + + /** * The dirtyForm function enables or disables the save and discard * button which are present in the toolbar of the form. * The Buttons are only active if the content of the form was altered