1 /*jshint node:true, indent:2, curly:true, eqeqeq:true, immed:true,
2 latedef:true, newcap:true, noarg:true,
3 regexp:true, undef:true, trailing:true, white:true */
4 /*global XT:true, XV:true, XM:true, Globalize:true, enyo:true, _:true */
8 // ..........................................................
13 /** @lends XV.CreditCardGatewayCombobox# */{
14 name: "XV.CreditCardGatewayCombobox",
15 kind: "XV.ComboboxWidget",
19 collection: "XM.creditCardGateways",
20 controlValueChanged: function (inSender, inEvent) {
21 if (!XM.creditCardGateways.find(function (model) { return model.id === inEvent.value; })) {
22 this.doNotify({message: "_unsupportedGateway".loc()});
24 return this.inherited(arguments);
28 // ..........................................................
33 @class A combobox backed by the XM.countries collection.
34 @name XV.CountryCombobox
38 /** @lends XV.CountryCombobox# */{
39 name: "XV.CountryCombobox",
40 kind: "XV.ComboboxWidget",
41 collection: "XM.countries"
44 // ..........................................................
49 @class A combobox backed by the XM.honorifics collection.
50 @name XV.HonorificCombobox
53 enyo.kind(/** @lends XV.HonorificCombobox# */{
54 name: "XV.HonorificCombobox",
55 kind: "XV.ComboboxWidget",
57 label: "_honorific".loc(),
58 collection: "XM.honorifics"
61 // ..........................................................
62 // QUOTE LINE CHARACTERISTIC
66 name: "XV.QuoteLineCharacteristicCombobox",
67 kind: "XV.ComboboxWidget",
68 keyAttribute: "value",
70 this.inherited(arguments);
71 this.createComponent({
73 container: this.$.container,
74 classes: "xv-combobox-note"
78 Populate the note field
82 setNote: function (value) {
83 this.$.comboboxNote.setContent(value);
87 // ..........................................................
92 name: "XV.ShipViaCombobox",
93 kind: "XV.ComboboxWidget",
94 collection: "XM.shipVias",
95 label: "_shipVia".loc(),
99 // ..........................................................
104 @class A combobox backed by the XM.states collection.
105 @name XV.StateCombobox
109 name: "XV.StateCombobox",
110 kind: "XV.ComboboxWidget",
111 collection: "XM.states",
112 keyAttribute: "abbreviation",
117 @todo Document the create method.
119 create: function () {
120 this.inherited(arguments);
122 filter = function (models) {
123 return _.filter(models, function (model) {
124 var country = model.get('country') || {};
125 return country.id === that._countryId;
128 this.setFilter(filter);
131 @todo Document the countryChanged method.
133 countryChanged: function () {
134 var country = this.getCountry();
136 this._countryId = undefined;
137 } else if (typeof country === 'string') {
138 country = _.find(XM.countries.models, function (model) {
139 return model.get('name') === country;
141 this._countryId = country ? country.id : undefined;
142 } else if (typeof country === 'object') {
143 this._countryId = country.id;
144 } else if (typeof country === 'number') {
145 this._countryId = country;
147 this._countryId = undefined;
153 // ..........................................................
158 name: "XV.UnitCombobox",
159 kind: "XV.ComboboxWidget",
160 collection: "XM.units",
161 keyAttribute: "name",
163 setValue: function (value, options) {
164 if (value && value.id) {
165 this.inherited(arguments, [value.id, options]);
167 this.inherited(arguments);