comparison app/controller/form/Probe.js @ 717:f124d24c8ade

Datevalidation. When editing a timeperiod in a Probeform it is validated wheter begindate is before enddate. This only happens when the blur-event is fired. ToDo: Listen to Events from the Übernehmen Button of the DateTimePicker, ToDo: Somehow the ErrorMessages are not Cleared correctly when the form is restored.
author Dustin Demuth <dustin@intevation.de>
date Mon, 13 Apr 2015 16:22:34 +0200
parents f0bc5387abcc
children c2a6f7caa71b
comparison
equal deleted inserted replaced
716:b400629a2575 717:f124d24c8ade
17 'probeform button[action=discard]': { 17 'probeform button[action=discard]': {
18 click: this.discard 18 click: this.discard
19 }, 19 },
20 'probeform': { 20 'probeform': {
21 dirtychange: this.dirtyForm 21 dirtychange: this.dirtyForm
22 },
23 'probeform [xtype="datetime"] field': {
24 blur: this.checkDate
22 } 25 }
23 }); 26 });
24 }, 27 },
25 28
26 save: function(button) { 29 save: function(button) {
92 else { 95 else {
93 form.owner.down('button[action=save]').setDisabled(true); 96 form.owner.down('button[action=save]').setDisabled(true);
94 form.owner.down('button[action=discard]').setDisabled(true); 97 form.owner.down('button[action=discard]').setDisabled(true);
95 form.owner.up('window').enableChildren(); // todo this might not be true in all cases 98 form.owner.up('window').enableChildren(); // todo this might not be true in all cases
96 } 99 }
100 },
101
102 checkDate: function(field) {
103 var now = Date.now();
104 var w = 0 //amount of warnings
105 var e = 0 //errors
106 var emsg = '';
107 var wmsg = '';
108
109 if (field.getValue() > now){
110 wmsg += Lada.getApplication().bundle.getMsg('661');
111 w++;
112 }
113 // This field might be a field within a DateTime-Period.
114 // Search for Partner field (period: end/start) and validate
115 // End Before Start validation
116 if (field.period) {
117 var partners = new Array();
118 partners[0] = field.up('fieldset').down('datetime[period=start]').down().getValue()
119 partners[1] = field.up('fieldset').down('datetime[period=end]').down().getValue()
120 if (partners[0] && partners[1] && partners[0] > partners [1]) {
121 var msg = Lada.getApplication().bundle.getMsg('662');
122 field.up('fieldset').showWarningOrError(true, msg, false, '');
123 } else {
124 field.up('fieldset').clearMessages();
125 }
126 }
127
128 if (w) {
129 field.up().showWarnings(wmsg);
130 }
131 if (e) {
132 field.up().showErrors(emsg);
133 }
134
135 // Clear Warnings or Errors if none Are Present
136 if (w == 0 && e == 0) {
137 field.up().clearWarningOrError();
138 }
97 } 139 }
98 }); 140 });

http://lada.wald.intevation.org