comparison app/view/widget/base/Datetime.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 67963fcb7739
children c75f13578315
comparison
equal deleted inserted replaced
716:b400629a2575 717:f124d24c8ade
15 requires: [ 15 requires: [
16 'Lada.view.widget.base.DateTimeField' 16 'Lada.view.widget.base.DateTimeField'
17 ], 17 ],
18 18
19 layout: 'hbox', 19 layout: 'hbox',
20 20 tooltip: null,
21 border: 0, 21 border: 0,
22 22
23 margin: '0, 0, 5, 0', 23 margin: '0, 0, 5, 0',
24 24
25 initComponent: function() { 25 initComponent: function() {
29 fieldLabel: this.fieldLabel, 29 fieldLabel: this.fieldLabel,
30 labelWidth: this.labelWidth, 30 labelWidth: this.labelWidth,
31 flex: 1, 31 flex: 1,
32 name: this.name, 32 name: this.name,
33 msgTarget: 'none', 33 msgTarget: 'none',
34 listeners: this.listeners 34 listeners: this.listeners,
35 period: this.period
35 }); 36 });
36 this.items = [dateField, { 37 this.items = [dateField, {
37 xtype: 'image', 38 xtype: 'image',
38 name: 'warnImg', 39 name: 'warnImg',
39 src: 'resources/img/dialog-warning.png', 40 src: 'resources/img/dialog-warning.png',
50 }]; 51 }];
51 this.callParent(arguments); 52 this.callParent(arguments);
52 }, 53 },
53 54
54 showWarnings: function(warnings) { 55 showWarnings: function(warnings) {
56 this.clearWarningOrError();
55 var img = this.down('image[name=warnImg]'); 57 var img = this.down('image[name=warnImg]');
56 Ext.create('Ext.tip.ToolTip', { 58 this.tooltip = (!this.tooltip) ? Ext.create('Ext.tip.ToolTip', {
57 target: img.getEl(), 59 target: img.getEl(),
58 html: warnings 60 html: warnings
59 }); 61 }) : this.tooltip.html = warnings;
60 this.down('datetimefield').invalidCls = 'x-lada-warning'; 62 this.down('datetimefield').invalidCls = 'x-lada-warning';
61 this.down('datetimefield').markInvalid(''); 63 this.down('datetimefield').markInvalid('');
62 img.show(); 64 img.show();
63 var fieldset = this.up('fieldset[collapsible=true]'); 65 var fieldset = this.up('fieldset[collapsible=true]');
64 if (fieldset) { 66 if (fieldset) {
67 fieldset.showWarningOrError(true, warningText); 69 fieldset.showWarningOrError(true, warningText);
68 } 70 }
69 }, 71 },
70 72
71 showErrors: function(errors) { 73 showErrors: function(errors) {
74 this.clearWarningOrError();
72 var img = this.down('image[name=errorImg]'); 75 var img = this.down('image[name=errorImg]');
73 var warnImg = this.down('image[name=warnImg]'); 76 var warnImg = this.down('image[name=warnImg]');
74 warnImg.hide(); 77 warnImg.hide();
75 Ext.create('Ext.tip.ToolTip', { 78 this.tooltip = (!this.tooltip) ? Ext.create('Ext.tip.ToolTip', {
76 target: img.getEl(), 79 target: img.getEl(),
77 html: errors 80 html: errors
78 }); 81 }) : this.tooltip.html = errors;
79 this.down('datetimefield').invalidCls = 'x-lada-error'; 82 this.down('datetimefield').invalidCls = 'x-lada-error';
80 this.down('datetimefield').markInvalid(''); 83 this.down('datetimefield').markInvalid('');
81 img.show(); 84 img.show();
82 var fieldset = this.up('fieldset[collapsible=true]'); 85 var fieldset = this.up('fieldset[collapsible=true]');
83 if (fieldset) { 86 if (fieldset) {
86 fieldset.showWarningOrError(false, '', true, errorText); 89 fieldset.showWarningOrError(false, '', true, errorText);
87 } 90 }
88 }, 91 },
89 92
90 clearWarningOrError: function() { 93 clearWarningOrError: function() {
94 this.down('datetimefield').clearInvalid();
91 this.down('image[name=errorImg]').hide(); 95 this.down('image[name=errorImg]').hide();
92 this.down('image[name=warnImg]').hide(); 96 this.down('image[name=warnImg]').hide();
93 }, 97 },
94 98
95 setReadOnly: function(value) { 99 setReadOnly: function(value) {

http://lada.wald.intevation.org