Mercurial > lada > lada-client
comparison 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 |
comparison
equal
deleted
inserted
replaced
1014:e9e974d31924 | 1021:1df6b6210b42 |
---|---|
15 /** | 15 /** |
16 * Initialize the Controller with 4 listeners | 16 * Initialize the Controller with 4 listeners |
17 */ | 17 */ |
18 init: function() { | 18 init: function() { |
19 this.control({ | 19 this.control({ |
20 'ortszuordnungform button[action=setOrt]': { | |
21 toggle: this.pickOrt | |
22 }, | |
20 'ortszuordnungform button[action=save]': { | 23 'ortszuordnungform button[action=save]': { |
21 click: this.save | 24 click: this.save |
22 }, | 25 }, |
23 'ortszuordnungform button[action=discard]': { | 26 'ortszuordnungform button[action=discard]': { |
24 click: this.discard | 27 click: this.discard |
25 }, | 28 }, |
26 'ortszuordnungform': { | 29 'ortszuordnungform': { |
27 dirtychange: this.dirtyForm | 30 dirtychange: this.dirtyForm |
28 }, | |
29 'ortszuordnungform combobox[name=ort]': { | |
30 select: this.updateDetails | |
31 } | 31 } |
32 }); | 32 }); |
33 }, | 33 }, |
34 | 34 |
35 /** | 35 /** |
36 * The save function saves the content of the Ort form. | 36 * The save function saves the content of the Ort form. |
37 * On success it will reload the Store, | 37 * On success it will reload the Store, |
38 * on failure, it will display an Errormessage | 38 * on failure, it will display an Errormessage |
39 */ | 39 */ |
40 save: function(button) { | 40 save: function(button) { |
41 | |
42 //try to disable ortPickerButton: | |
43 try { | |
44 var ob = this.up('form').down('ortszuordnungform button[action=setOrt]'); | |
45 if (ob.pressed) { | |
46 ob.toggle(false); | |
47 } | |
48 } | |
49 catch (e) { | |
50 } | |
51 | |
41 var formPanel = button.up('ortszuordnungform'); | 52 var formPanel = button.up('ortszuordnungform'); |
42 var data = formPanel.getForm().getFieldValues(true); | 53 var data = formPanel.getForm().getFieldValues(true); |
43 var i18n = Lada.getApplication().bundle; | 54 var i18n = Lada.getApplication().bundle; |
44 for (var key in data) { | 55 for (var key in data) { |
45 formPanel.getForm().getRecord().set(key, data[key]); | 56 formPanel.getForm().getRecord().set(key, data[key]); |
56 .setDisabled(true); | 67 .setDisabled(true); |
57 formPanel.clearMessages(); | 68 formPanel.clearMessages(); |
58 formPanel.setRecord(record); | 69 formPanel.setRecord(record); |
59 formPanel.setMessages(json.errors, json.warnings); | 70 formPanel.setMessages(json.errors, json.warnings); |
60 formPanel.up('window').grid.store.reload(); | 71 formPanel.up('window').grid.store.reload(); |
61 debugger; | |
62 } | 72 } |
63 }, | 73 }, |
64 failure: function(record, response) { | 74 failure: function(record, response) { |
65 button.setDisabled(true); | 75 button.setDisabled(true); |
66 button.up('toolbar').down('button[action=discard]') | 76 button.up('toolbar').down('button[action=discard]') |
96 var formPanel = button.up('form'); | 106 var formPanel = button.up('form'); |
97 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); | 107 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); |
98 }, | 108 }, |
99 | 109 |
100 /** | 110 /** |
111 * When the button is Active, a Record can be selected. | |
112 * If the Record was selected from a grid this function | |
113 * sets the ortzuordnung. | |
114 * TODO: Check if the selected Record is a ORT | |
115 * TODO: Enable picking from Maps | |
116 */ | |
117 pickOrt: function(button, pressed, opts) { | |
118 var i18n = Lada.getApplication().bundle; | |
119 var oForm = button.up('form'); | |
120 var osg = button.up('window').down('ortstammdatengrid'); | |
121 if (button.pressed) { | |
122 button.setText(i18n.getMsg('ortszuordnung.form.setOrt.pressed')); | |
123 osg.addListener('select',oForm.setOrt, oForm); | |
124 } | |
125 else { | |
126 button.setText(i18n.getMsg('ortszuordnung.form.setOrt')); | |
127 osg.removeListener('select',oForm.setOrt, oForm); | |
128 } | |
129 }, | |
130 | |
131 | |
132 /** | |
101 * The dirtyForm function enables or disables the save and discard | 133 * The dirtyForm function enables or disables the save and discard |
102 * button which are present in the toolbar of the form. | 134 * button which are present in the toolbar of the form. |
103 * The Buttons are only active if the content of the form was altered | 135 * The Buttons are only active if the content of the form was altered |
104 * (the form is dirty). | 136 * (the form is dirty). |
105 */ | 137 */ |