Skip to content
Permalink
Browse files

FIX: brings back castInteger as a safer migration path for sk2 (#8966)

  • Loading branch information
jjaffeux committed Feb 14, 2020
1 parent 09edde8 commit 7d94de6439c197b87f8d05d4e94e4c3f30295396
@@ -3,7 +3,10 @@
content=setting.validValues
value=value
onChange=(action (mut value))
allowAny=setting.allowsNone
options=(hash
castInteger=true
allowAny=setting.allowsNone
)
}}

{{preview}}
@@ -80,7 +80,10 @@ export default SelectKitComponent.extend({
},

selectedContent: computed("value.[]", "content.[]", function() {
const value = Ember.makeArray(this.value);
const value = Ember.makeArray(this.value).map(v =>
this.selectKit.options.castInteger && this._isNumeric(v) ? Number(v) : v
);

if (value.length) {
let content = [];

@@ -268,7 +268,8 @@ export default Component.extend(
limitMatches: null,
placement: "bottom-start",
filterComponent: "select-kit/select-kit-filter",
selectedNameComponent: "selected-name"
selectedNameComponent: "selected-name",
castInteger: false
},

autoFilterable: computed("content.[]", "selectKit.filter", function() {
@@ -961,7 +962,8 @@ export default Component.extend(
maximum: "options.maximum",
minimum: "options.minimum",
i18nPostfix: "options.i18nPostfix",
i18nPrefix: "options.i18nPrefix"
i18nPrefix: "options.i18nPrefix",
castInteger: "options.castInteger"
};

Object.keys(migrations).forEach(from => {
@@ -16,17 +16,23 @@ export default SelectKitComponent.extend({
if (!isEmpty(this.value)) {
let content;

const value =
this.selectKit.options.castInteger && this._isNumeric(this.value)
? Number(this.value)
: this.value;

if (this.selectKit.valueProperty) {
content = (this.content || []).findBy(
this.selectKit.valueProperty,
this.value
value
);

return this.selectKit.modifySelection(
content || this.defaultItem(this.value, this.value)
content || this.defaultItem(value, value)
);
} else {
return this.selectKit.modifySelection(
(this.content || []).filter(c => c === this.value)
(this.content || []).filter(c => c === value)
);
}
} else {

1 comment on commit 7d94de6

@discoursereviewbot

This comment has been minimized.

Copy link

discoursereviewbot commented on 7d94de6 Feb 14, 2020

system posted:

This commit appears in #8966 which was merged by @jjaffeux.

Please sign in to comment.
You can’t perform that action at this time.