mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: brings back castInteger as a safer migration path for sk2 (#8966)
This commit is contained in:
parent
09edde8ef7
commit
7d94de6439
4 changed files with 21 additions and 7 deletions
|
@ -3,7 +3,10 @@
|
||||||
content=setting.validValues
|
content=setting.validValues
|
||||||
value=value
|
value=value
|
||||||
onChange=(action (mut value))
|
onChange=(action (mut value))
|
||||||
allowAny=setting.allowsNone
|
options=(hash
|
||||||
|
castInteger=true
|
||||||
|
allowAny=setting.allowsNone
|
||||||
|
)
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{preview}}
|
{{preview}}
|
||||||
|
|
|
@ -80,7 +80,10 @@ export default SelectKitComponent.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
selectedContent: computed("value.[]", "content.[]", function() {
|
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) {
|
if (value.length) {
|
||||||
let content = [];
|
let content = [];
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,8 @@ export default Component.extend(
|
||||||
limitMatches: null,
|
limitMatches: null,
|
||||||
placement: "bottom-start",
|
placement: "bottom-start",
|
||||||
filterComponent: "select-kit/select-kit-filter",
|
filterComponent: "select-kit/select-kit-filter",
|
||||||
selectedNameComponent: "selected-name"
|
selectedNameComponent: "selected-name",
|
||||||
|
castInteger: false
|
||||||
},
|
},
|
||||||
|
|
||||||
autoFilterable: computed("content.[]", "selectKit.filter", function() {
|
autoFilterable: computed("content.[]", "selectKit.filter", function() {
|
||||||
|
@ -961,7 +962,8 @@ export default Component.extend(
|
||||||
maximum: "options.maximum",
|
maximum: "options.maximum",
|
||||||
minimum: "options.minimum",
|
minimum: "options.minimum",
|
||||||
i18nPostfix: "options.i18nPostfix",
|
i18nPostfix: "options.i18nPostfix",
|
||||||
i18nPrefix: "options.i18nPrefix"
|
i18nPrefix: "options.i18nPrefix",
|
||||||
|
castInteger: "options.castInteger"
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.keys(migrations).forEach(from => {
|
Object.keys(migrations).forEach(from => {
|
||||||
|
|
|
@ -16,17 +16,23 @@ export default SelectKitComponent.extend({
|
||||||
if (!isEmpty(this.value)) {
|
if (!isEmpty(this.value)) {
|
||||||
let content;
|
let content;
|
||||||
|
|
||||||
|
const value =
|
||||||
|
this.selectKit.options.castInteger && this._isNumeric(this.value)
|
||||||
|
? Number(this.value)
|
||||||
|
: this.value;
|
||||||
|
|
||||||
if (this.selectKit.valueProperty) {
|
if (this.selectKit.valueProperty) {
|
||||||
content = (this.content || []).findBy(
|
content = (this.content || []).findBy(
|
||||||
this.selectKit.valueProperty,
|
this.selectKit.valueProperty,
|
||||||
this.value
|
value
|
||||||
);
|
);
|
||||||
|
|
||||||
return this.selectKit.modifySelection(
|
return this.selectKit.modifySelection(
|
||||||
content || this.defaultItem(this.value, this.value)
|
content || this.defaultItem(value, value)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return this.selectKit.modifySelection(
|
return this.selectKit.modifySelection(
|
||||||
(this.content || []).filter(c => c === this.value)
|
(this.content || []).filter(c => c === value)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue