annotate app/view/widget/DayOfYear.js @ 1222:4e62bc6e7250

Fixed parsing of empty data and require the import response window.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 27 Oct 2016 16:26:07 +0200
parents 3e6756b0fc97
children 01f083db45b7
rev   line source
1199
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
3 *
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
7 */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
8
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
9 /**
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
10 * Panel to select month and day of month,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
11 * that can be serialized to day of year
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
12 */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
13 Ext.define('Lada.view.widget.DayOfYear', {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
14 extend: 'Ext.panel.Panel',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
15 alias: 'widget.dayofyear',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
16
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
17 layout: {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
18 type: 'hbox',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
19 pack: 'end',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
20 defaultMargins: '3'
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
21 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
22
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
23 initComponent: function() {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
24 var me = this;
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
25
1211
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
26 var monthsStore = Ext.create('Ext.data.Store', {
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
27 fields: ['id', 'name'],
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
28 data: [{
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
29 'id': 0,
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
30 'name': 'Januar'
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
31 }, {
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
32 'id': 1,
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
33 'name': 'Februar'
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
34 }, {
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
35 'id': 2,
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
36 'name': 'März'
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
37 }, {
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
38 'id': 3,
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
39 'name': 'April'
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
40 }, {
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
41 'id': 4,
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
42 'name': 'Mai'
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
43 }, {
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
44 'id': 5,
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
45 'name': 'Juni'
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
46 }, {
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
47 'id': 6,
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
48 'name': 'Juli'
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
49 }, {
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
50 'id': 7,
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
51 'name': 'August'
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
52 }, {
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
53 'id': 8,
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
54 'name': 'September'
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
55 }, {
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
56 'id': 9,
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
57 'name': 'Oktober'
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
58 }, {
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
59 'id': 10,
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
60 'name': 'November'
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
61 }, {
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
62 'id': 11,
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
63 'name': 'Dezember'
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
64 }]
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
65 });
85b018980347 Let each instance of a DayOfYear-widget have its own store.
Tom Gottfried <tom@intevation.de>
parents: 1207
diff changeset
66
1199
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
67 /*
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
68 * Create hidden field to hold the day of year value
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
69 * for/of the record of the form.
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
70 */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
71 var DOYField = Ext.create('Ext.form.field.Number', {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
72 name: this.name,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
73 hidden: true,
1212
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
74 allowBlank: this.allowBlank,
1199
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
75 listeners: this.listeners
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
76 });
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
77 /* Use dirtychange to avoid endless loop with change listeners on
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
78 * visible items. This one is for initialisation by the form. */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
79 DOYField.addListener('dirtychange', me.setFields);
1212
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
80 DOYField.addListener('validitychange', me.validityChange);
1199
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
81
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
82 /*
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
83 * Add hidden field and visible fields to let the user choose
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
84 * day and month to the panel.
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
85 */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
86 this.items = [{
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
87 xtype: 'numberfield',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
88 isFormField: false,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
89 fieldLabel: this.fieldLabel,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
90 labelWidth: this.labelWidth,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
91 width: 50 + this.labelWidth,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
92 msgTarget: 'none',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
93 allowDecimals: false,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
94 maxLength: 2,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
95 enforceMaxLength: true,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
96 allowBlank: this.allowBlank,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
97 minValue: 1,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
98 maxValue: 31,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
99 emptyText: 'Tag',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
100 listeners: {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
101 /* we have to listen on change because checkMaxDay() might
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
102 * change the value. UI events like blur do not track this. */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
103 change: { fn: me.setDOY }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
104 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
105 }, {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
106 xtype: 'combobox',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
107 isFormField: false,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
108 width: 100,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
109 msgTarget: 'none',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
110 store: monthsStore,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
111 allowBlank: this.allowBlank,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
112 forceSelection: true,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
113 valueField: 'id',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
114 displayField: 'name',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
115 emptyText: 'Monat',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
116 queryMode: 'local',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
117 listeners: {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
118 collapse: { fn: me.setDOY },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
119 change: { fn: me.checkMaxDay }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
120 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
121 }, {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
122 xtype: 'image',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
123 name: 'warnImg',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
124 src: 'resources/img/dialog-warning.png',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
125 width: 14,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
126 height: 14,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
127 hidden: true
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
128 }, {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
129 xtype: 'image',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
130 name: 'errorImg',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
131 src: 'resources/img/emblem-important.png',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
132 width: 14,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
133 height: 14,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
134 hidden: true
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
135 }, DOYField];
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
136
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
137 this.callParent(arguments);
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
138 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
139
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
140 /*
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
141 * Set values in panel items for day and month
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
142 * from hidden day of year field
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
143 */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
144 setFields: function() {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
145 var panel = this.up('panel');
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
146
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
147 // create a date object with arbitrary non-leap year
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
148 var doy = panel.down('numberfield[hidden]').getValue();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
149
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
150 if (doy != null) {
1207
05c8bd380fd5 Align data model with 1-based day of year in server.
Tom Gottfried <tom@intevation.de>
parents: 1199
diff changeset
151 // day of year is 0-based in ExtJS, but 1-based in the model
05c8bd380fd5 Align data model with 1-based day of year in server.
Tom Gottfried <tom@intevation.de>
parents: 1199
diff changeset
152 doy -= 1;
1199
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
153 var date = Ext.Date.subtract(
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
154 new Date(1970, 0, 1), Ext.Date.DAY, -doy);
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
155 var month = date.getMonth();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
156 var day = date.getDate();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
157 panel.down('combobox').setValue(month);
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
158 panel.down('numberfield[hidden=false]').setValue(day);
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
159 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
160 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
161
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
162 /*
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
163 * Function to be called from listeners of visible items
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
164 * to set the value of the hidden day of year field.
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
165 */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
166 setDOY: function() {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
167 var panel = this.up('panel');
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
168 var month = panel.down('combobox').getValue();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
169 var day = panel.down('numberfield[hidden=false]').getValue();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
170 var maxDay = panel.down('numberfield[hidden=false]').maxValue;
1212
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
171 var doy = null;
1199
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
172
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
173 if (month != null && day != null && day <= maxDay) {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
174 // create a date object with arbitrary non-leap year
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
175 var date = new Date(1970, month, day);
1207
05c8bd380fd5 Align data model with 1-based day of year in server.
Tom Gottfried <tom@intevation.de>
parents: 1199
diff changeset
176
05c8bd380fd5 Align data model with 1-based day of year in server.
Tom Gottfried <tom@intevation.de>
parents: 1199
diff changeset
177 // day of year is 0-based in ExtJS, but 1-based in the model
1212
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
178 doy = Ext.Date.getDayOfYear(date) + 1;
1199
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
179 }
1212
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
180 panel.down('numberfield[hidden]').setValue(doy);
1199
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
181 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
182
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
183 /*
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
184 * Call from listener of month selection widget to set maximum and
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
185 * validate associated day value.
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
186 */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
187 checkMaxDay: function() {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
188 // create a date object with arbitrary non-leap year
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
189 var maxDay = Ext.Date.getDaysInMonth(
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
190 new Date(1970, this.getValue()));
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
191 this.up('panel').down('numberfield[hidden=false]')
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
192 .setMaxValue(maxDay);
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
193
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
194 var curDay = this.up('panel')
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
195 .down('numberfield[hidden=false]').getValue();
1212
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
196 if (curDay) {
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
197 if (curDay > maxDay) {
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
198 this.up('panel').down('numberfield[hidden=false]')
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
199 .setValue(maxDay);
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
200 }
1199
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
201 this.up('panel').down('numberfield[hidden=false]')
1212
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
202 .clearInvalid();
1199
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
203 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
204 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
205
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
206
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
207 showWarnings: function(warnings) {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
208 var img = this.down('image[name=warnImg]');
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
209 Ext.create('Ext.tip.ToolTip', {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
210 target: img.getEl(),
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
211 html: warnings
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
212 });
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
213 img.show();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
214 this.down('numberfield[hidden=false]').invalidCls = 'x-lada-warning';
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
215 this.down('numberfield[hidden=false]').markInvalid('');
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
216 this.down('combobox').markInvalid('');
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
217 var fieldset = this.up('fieldset[collapsible=true]');
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
218 if (fieldset) {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
219 var i18n = Lada.getApplication().bundle;
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
220 var warningText = i18n.getMsg(this.name) + ': ' + warnings;
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
221 fieldset.showWarningOrError(true, warningText);
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
222 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
223 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
224
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
225 showErrors: function(errors) {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
226 var img = this.down('image[name=errorImg]');
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
227 var warnImg = this.down('image[name=warnImg]');
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
228 warnImg.hide();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
229 Ext.create('Ext.tip.ToolTip', {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
230 target: img.getEl(),
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
231 html: errors
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
232 });
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
233 this.down('numberfield[hidden=false]').invalidCls = 'x-lada-error';
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
234 this.down('numberfield[hidden=false]').markInvalid('');
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
235 this.down('combobox').markInvalid('');
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
236 img.show();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
237 var fieldset = this.up('fieldset[collapsible=true]');
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
238 if (fieldset) {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
239 var i18n = Lada.getApplication().bundle;
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
240 var errorText = i18n.getMsg(this.name) + ': ' + errors;
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
241 fieldset.showWarningOrError(false, '', true, errorText);
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
242 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
243 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
244
1212
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
245 /*
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
246 * When the hidden field is validated as part of a form, make the result
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
247 * user visible.
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
248 */
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
249 validityChange: function(field, isValid) {
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
250 if (!isValid) {
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
251 var errors = field.getActiveErrors()
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
252 field.up('panel').down('combobox').markInvalid(errors);
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
253 field.up('panel').down('numberfield[hidden=false]')
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
254 .markInvalid(errors);
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
255 } else {
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
256 field.up('panel').down('combobox').clearInvalid();
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
257 field.up('panel').down('numberfield[hidden=false]').clearInvalid();
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
258 }
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
259 },
3e6756b0fc97 Fix and complement validation of Messprogramm from.
Tom Gottfried <tom@intevation.de>
parents: 1211
diff changeset
260
1199
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
261 clearWarningOrError: function() {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
262 this.down('image[name=errorImg]').hide();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
263 this.down('image[name=warnImg]').hide();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
264 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
265
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
266 getValue: function() {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
267 this.down('numberfield[hidden]').getValue();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
268 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
269
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
270 setValue: function(value) {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
271 this.down('numberfield[hidden]').setValue(value);
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
272 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
273 });

http://lada.wald.intevation.org