annotate app/view/widget/DayOfYear.js @ 1211:85b018980347

Let each instance of a DayOfYear-widget have its own store. This prevents filtering of comboboxes affecting each other.
author Tom Gottfried <tom@intevation.de>
date Tue, 11 Oct 2016 17:40:37 +0200
parents 05c8bd380fd5
children 3e6756b0fc97
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,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
74 listeners: this.listeners
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
75 });
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
76 /* 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
77 * 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
78 DOYField.addListener('dirtychange', me.setFields);
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
79
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
80 /*
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
81 * 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
82 * 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
83 */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
84 this.items = [{
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
85 xtype: 'numberfield',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
86 isFormField: false,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
87 fieldLabel: this.fieldLabel,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
88 labelWidth: this.labelWidth,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
89 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
90 msgTarget: 'none',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
91 allowDecimals: false,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
92 maxLength: 2,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
93 enforceMaxLength: true,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
94 allowBlank: this.allowBlank,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
95 minValue: 1,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
96 maxValue: 31,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
97 emptyText: 'Tag',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
98 listeners: {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
99 /* 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
100 * 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
101 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
102 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
103 }, {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
104 xtype: 'combobox',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
105 isFormField: false,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
106 width: 100,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
107 msgTarget: 'none',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
108 store: monthsStore,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
109 allowBlank: this.allowBlank,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
110 forceSelection: true,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
111 valueField: 'id',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
112 displayField: 'name',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
113 emptyText: 'Monat',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
114 queryMode: 'local',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
115 listeners: {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
116 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
117 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
118 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
119 }, {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
120 xtype: 'image',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
121 name: 'warnImg',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
122 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
123 width: 14,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
124 height: 14,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
125 hidden: true
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
126 }, {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
127 xtype: 'image',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
128 name: 'errorImg',
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
129 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
130 width: 14,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
131 height: 14,
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
132 hidden: true
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
133 }, DOYField];
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
134
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
135 this.callParent(arguments);
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
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 * 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
140 * 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
141 */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
142 setFields: function() {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
143 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
144
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
145 // 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
146 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
147
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
148 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
149 // 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
150 doy -= 1;
1199
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
151 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
152 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
153 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
154 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
155 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
156 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
157 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
158 },
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 * 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
162 * 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
163 */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
164 setDOY: function() {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
165 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
166 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
167 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
168 var maxDay = panel.down('numberfield[hidden=false]').maxValue;
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
169
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
170 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
171 // 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
172 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
173
05c8bd380fd5 Align data model with 1-based day of year in server.
Tom Gottfried <tom@intevation.de>
parents: 1199
diff changeset
174 // 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
175 var 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
176 panel.down('numberfield[hidden]').setValue(doy);
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
177 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
178 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
179
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
180 /*
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
181 * 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
182 * 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
183 */
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
184 checkMaxDay: function() {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
185 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
186 .clearInvalid();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
187
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();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
196 if (curDay > maxDay) {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
197 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
198 .setValue(maxDay);
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
199 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
200 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
201
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
202
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
203 showWarnings: function(warnings) {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
204 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
205 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
206 target: img.getEl(),
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
207 html: warnings
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
208 });
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
209 img.show();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
210 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
211 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
212 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
213 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
214 if (fieldset) {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
215 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
216 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
217 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
218 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
219 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
220
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
221 showErrors: function(errors) {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
222 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
223 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
224 warnImg.hide();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
225 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
226 target: img.getEl(),
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
227 html: errors
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
228 });
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
229 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
230 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
231 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
232 img.show();
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
233 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
234 if (fieldset) {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
235 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
236 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
237 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
238 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
239 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
240
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
241 clearWarningOrError: function() {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
242 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
243 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
244 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
245
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
246 getValue: function() {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
247 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
248 },
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
249
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
250 setValue: function(value) {
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
251 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
252 }
0a7f0a09151c Replace date-time picker with appropriate widget to select day of year.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
253 });

http://lada.wald.intevation.org