]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * @class Ext.calendar.form.field.CalendarCombo\r | |
3 | * @extends Ext.form.ComboBox\r | |
4 | * <p>A custom combo used for choosing from the list of available calendars to assign an event to.</p>\r | |
5 | * <p>This is pretty much a standard combo that is simply pre-configured for the options needed by the\r | |
6 | * calendar components. The default configs are as follows:<pre><code>\r | |
7 | fieldLabel: 'Calendar',\r | |
8 | triggerAction: 'all',\r | |
9 | queryMode: 'local',\r | |
10 | forceSelection: true,\r | |
11 | selectOnFocus: true,\r | |
12 | width: 200\r | |
13 | </code></pre>\r | |
14 | * @constructor\r | |
15 | * @param {Object} config The config object\r | |
16 | */\r | |
17 | Ext.define('Ext.calendar.form.field.CalendarCombo', {\r | |
18 | extend: 'Ext.form.field.ComboBox',\r | |
19 | alias: 'widget.calendarpicker',\r | |
20 | requires: [\r | |
21 | 'Ext.calendar.data.CalendarMappings'\r | |
22 | ],\r | |
23 | \r | |
24 | fieldLabel: 'Calendar',\r | |
25 | triggerAction: 'all',\r | |
26 | queryMode: 'local',\r | |
27 | forceSelection: true,\r | |
28 | selectOnFocus: true,\r | |
29 | \r | |
30 | // private\r | |
31 | defaultCls: 'ext-color-default',\r | |
32 | \r | |
33 | // private\r | |
34 | initComponent: function(){\r | |
35 | this.valueField = Ext.calendar.data.CalendarMappings.CalendarId.name;\r | |
36 | this.displayField = Ext.calendar.data.CalendarMappings.Title.name;\r | |
37 | \r | |
38 | this.listConfig = Ext.apply(this.listConfig || {}, {\r | |
39 | getInnerTpl: this.getListItemTpl\r | |
40 | });\r | |
41 | \r | |
42 | this.callParent(arguments);\r | |
43 | },\r | |
44 | \r | |
45 | // private\r | |
46 | getListItemTpl: function(displayField) {\r | |
47 | return '<div class="x-combo-list-item ext-color-{' + Ext.calendar.data.CalendarMappings.CalendarId.name +\r | |
48 | '}"><div class="ext-cal-picker-icon"> </div>{' + displayField + '}</div>';\r | |
49 | },\r | |
50 | \r | |
51 | // private\r | |
52 | afterRender: function(){\r | |
53 | this.callParent(arguments);\r | |
54 | \r | |
55 | this.wrap = this.el.down('.x-form-text-wrap');\r | |
56 | this.wrap.addCls('ext-calendar-picker');\r | |
57 | \r | |
58 | this.icon = Ext.core.DomHelper.append(this.wrap, {\r | |
59 | tag: 'div', cls: 'ext-cal-picker-icon ext-cal-picker-mainicon'\r | |
60 | });\r | |
61 | },\r | |
62 | \r | |
63 | /* @private\r | |
64 | * Value can be a data value or record, or an array of values or records.\r | |
65 | */\r | |
66 | getStyleClass: function(value){\r | |
67 | var val = value;\r | |
68 | \r | |
69 | if (!Ext.isEmpty(val)) {\r | |
70 | if (Ext.isArray(val)) {\r | |
71 | val = val[0];\r | |
72 | }\r | |
73 | return 'ext-color-' + (val.data ? val.data[Ext.calendar.data.CalendarMappings.CalendarId.name] : val); \r | |
74 | }\r | |
75 | return '';\r | |
76 | },\r | |
77 | \r | |
78 | // inherited docs\r | |
79 | setValue: function(value) {\r | |
80 | if (!value && this.store.getCount() > 0) {\r | |
81 | // ensure that a valid value is always set if possible\r | |
82 | value = this.store.getAt(0).data[Ext.calendar.data.CalendarMappings.CalendarId.name];\r | |
83 | }\r | |
84 | \r | |
85 | if (this.wrap && value) {\r | |
86 | var currentClass = this.getStyleClass(this.getValue()),\r | |
87 | newClass = this.getStyleClass(value);\r | |
88 | \r | |
89 | this.wrap.replaceCls(currentClass, newClass);\r | |
90 | }\r | |
91 | \r | |
92 | this.callParent(arguments);\r | |
93 | }\r | |
94 | }); |