Mercurial > lada > lada-client
comparison app/controller/form/Probe.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 | aadb6e1f0a70 |
children | e89a31b2c17e |
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 * A Controller for a Probe form | |
11 */ | |
9 Ext.define('Lada.controller.form.Probe', { | 12 Ext.define('Lada.controller.form.Probe', { |
10 extend: 'Ext.app.Controller', | 13 extend: 'Ext.app.Controller', |
11 | 14 |
15 /** | |
16 * Initialize the Controller | |
17 * It has 4 listeners | |
18 */ | |
12 init: function() { | 19 init: function() { |
13 this.control({ | 20 this.control({ |
14 'probeform button[action=save]': { | 21 'probeform button[action=save]': { |
15 click: this.save | 22 click: this.save |
16 }, | 23 }, |
24 blur: this.checkDate | 31 blur: this.checkDate |
25 } | 32 } |
26 }); | 33 }); |
27 }, | 34 }, |
28 | 35 |
36 /** | |
37 * The save function saves the content of the Location form. | |
38 * On success it will reload the Store, | |
39 * on failure, it will display an Errormessage | |
40 */ | |
29 save: function(button) { | 41 save: function(button) { |
30 var formPanel = button.up('form'); | 42 var formPanel = button.up('form'); |
31 var data = formPanel.getForm().getFieldValues(true); | 43 var data = formPanel.getForm().getFieldValues(true); |
32 for (var key in data) { | 44 for (var key in data) { |
33 formPanel.getForm().getRecord().set(key, data[key]); | 45 formPanel.getForm().getRecord().set(key, data[key]); |
83 | 95 |
84 } | 96 } |
85 }); | 97 }); |
86 }, | 98 }, |
87 | 99 |
100 /** | |
101 * The discard function resets the Location form | |
102 * to its original state. | |
103 */ | |
88 discard: function(button) { | 104 discard: function(button) { |
89 var formPanel = button.up('form'); | 105 var formPanel = button.up('form'); |
90 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); | 106 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); |
91 }, | 107 }, |
92 | 108 |
109 /** | |
110 * The dirtyForm function enables or disables the save and discard | |
111 * button which are present in the toolbar of the form. | |
112 * The Buttons are only active if the content of the form was altered | |
113 * (the form is dirty). | |
114 * In Additon it calls the disableChildren() function of the window | |
115 * embedding the form. Likewise it calls the embedding windows | |
116 * enableChilren() function | |
117 */ | |
93 dirtyForm: function(form, dirty) { | 118 dirtyForm: function(form, dirty) { |
94 if (dirty) { | 119 if (dirty) { |
95 form.owner.down('button[action=save]').setDisabled(false); | 120 form.owner.down('button[action=save]').setDisabled(false); |
96 form.owner.down('button[action=discard]').setDisabled(false); | 121 form.owner.down('button[action=discard]').setDisabled(false); |
97 form.owner.up('window').disableChildren(); | 122 form.owner.up('window').disableChildren(); |
101 form.owner.down('button[action=discard]').setDisabled(true); | 126 form.owner.down('button[action=discard]').setDisabled(true); |
102 form.owner.up('window').enableChildren(); // todo this might not be true in all cases | 127 form.owner.up('window').enableChildren(); // todo this might not be true in all cases |
103 } | 128 } |
104 }, | 129 }, |
105 | 130 |
131 /** | |
132 * checkDate() is called when a xtype=datetime field was modified | |
133 * It checks for two things: | |
134 * - Is the date in the future | |
135 * - Does the date belong to a time period and the end is before start | |
136 * In both cases it adds a warning to the field which was checked. | |
137 */ | |
106 checkDate: function(field) { | 138 checkDate: function(field) { |
107 var now = Date.now(); | 139 var now = Date.now(); |
108 var w = 0 //amount of warnings | 140 var w = 0 //amount of warnings |
109 var e = 0 //errors | 141 var e = 0 //errors |
110 var emsg = ''; | 142 var emsg = ''; |