comparison app/controller/form/Messung.js @ 742:6e28ebbe1a73

added documentation for Form and Grid controllers
author Dustin Demuth <dustin@intevation.de>
date Thu, 23 Apr 2015 16:28:04 +0200
parents c2a6f7caa71b
children 24b5684d74d7
comparison
equal deleted inserted replaced
740:2e8da590ea0c 742:6e28ebbe1a73
4 * This file is Free Software under the GNU GPL (v>=3) 4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out 5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details. 6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */ 7 */
8 8
9 /**
10 * This is a controller for a Messung form
11 */
9 Ext.define('Lada.controller.form.Messung', { 12 Ext.define('Lada.controller.form.Messung', {
10 extend: 'Ext.app.Controller', 13 extend: 'Ext.app.Controller',
11 14
15 /**
16 * Initialize the Controller
17 * It has 3 listeners
18 */
12 init: function() { 19 init: function() {
13 this.control({ 20 this.control({
14 'messungform button[action=save]': { 21 'messungform button[action=save]': {
15 click: this.save 22 click: this.save
16 }, 23 },
21 dirtychange: this.dirtyForm 28 dirtychange: this.dirtyForm
22 } 29 }
23 }); 30 });
24 }, 31 },
25 32
33 /**
34 * The save function saves the content of the Location form.
35 * On success it will reload the Store,
36 * on failure, it will display an Errormessage
37 */
26 save: function(button) { 38 save: function(button) {
27 var formPanel = button.up('form'); 39 var formPanel = button.up('form');
28 formPanel.setLoading(true); 40 formPanel.setLoading(true);
29 var data = formPanel.getForm().getFieldValues(true); 41 var data = formPanel.getForm().getFieldValues(true);
30 for (var key in data) { 42 for (var key in data) {
93 formPanel.setLoading(false); 105 formPanel.setLoading(false);
94 } 106 }
95 }); 107 });
96 }, 108 },
97 109
98 discard: function(button) { 110 /**
111 * The discard function resets the Location form
112 * to its original state.
113 */
114 discard: function(button) {
99 var formPanel = button.up('form'); 115 var formPanel = button.up('form');
100 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); 116 formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
101 }, 117 },
102 118
103 dirtyForm: function(form, dirty) { 119 /**
120 * The dirtyForm function enables or disables the save and discard
121 * button which are present in the toolbar of the form.
122 * The Buttons are only active if the content of the form was altered
123 * (the form is dirty).
124 * In Additon it calls the disableChildren() function of the window
125 * embedding the form. Only when the record does not carry the readonly
126 * flag, the function calls the embedding windows enableChilren() function
127 */
128 dirtyForm: function(form, dirty) {
104 if (dirty) { 129 if (dirty) {
105 form.owner.down('button[action=save]').setDisabled(false); 130 form.owner.down('button[action=save]').setDisabled(false);
106 form.owner.down('button[action=discard]').setDisabled(false); 131 form.owner.down('button[action=discard]').setDisabled(false);
107 form.owner.up('window').disableChildren(); 132 form.owner.up('window').disableChildren();
108 } 133 }

http://lada.wald.intevation.org