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.$.fittableColumns,
74 classes: "xv-combobox-note"
76 // TODO: git rid of this
77 this.$.input.applyStyle("padding-top", "8px");
78 this.$.input.applyStyle("padding-left", "8px");
81 Populate the note field
85 setNote: function (value) {
86 this.$.comboboxNote.setContent(value);
90 // ..........................................................
95 name: "XV.ShipViaCombobox",
96 kind: "XV.ComboboxWidget",
97 collection: "XM.shipVias",
98 label: "_shipVia".loc(),
102 // ..........................................................
107 @class A combobox backed by the XM.states collection.
108 @name XV.StateCombobox
112 name: "XV.StateCombobox",
113 kind: "XV.ComboboxWidget",
114 collection: "XM.states",
115 keyAttribute: "abbreviation",
120 @todo Document the create method.
122 create: function () {
123 this.inherited(arguments);
125 filter = function (models) {
126 return _.filter(models, function (model) {
127 var country = model.get('country') || {};
128 return country.id === that._countryId;
131 this.setFilter(filter);
134 @todo Document the countryChanged method.
136 countryChanged: function () {
137 var country = this.getCountry();
139 this._countryId = undefined;
140 } else if (typeof country === 'string') {
141 country = _.find(XM.countries.models, function (model) {
142 return model.get('name') === country;
144 this._countryId = country ? country.id : undefined;
145 } else if (typeof country === 'object') {
146 this._countryId = country.id;
147 } else if (typeof country === 'number') {
148 this._countryId = country;
150 this._countryId = undefined;
156 // ..........................................................
161 name: "XV.UnitCombobox",
162 kind: "XV.ComboboxWidget",
163 collection: "XM.units",
164 keyAttribute: "name",
166 setValue: function (value, options) {
167 if (value && value.id) {
168 this.inherited(arguments, [value.id, options]);
170 this.inherited(arguments);