mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
FIX: corrects min/max logic for mini-tag-chooser (#8871)
This commit is contained in:
@ -69,7 +69,9 @@ export default ComboBox.extend(TagsMixin, {
|
|||||||
|
|
||||||
maximumSelectedTags: computed(function() {
|
maximumSelectedTags: computed(function() {
|
||||||
return parseInt(
|
return parseInt(
|
||||||
this.options.limit || this.options.maximum || this.maxTagsPerTopic,
|
this.options.limit ||
|
||||||
|
this.selectKit.options.maximum ||
|
||||||
|
this.maxTagsPerTopic,
|
||||||
10
|
10
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@ -81,7 +83,8 @@ export default ComboBox.extend(TagsMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
caretIcon: computed("value.[]", function() {
|
caretIcon: computed("value.[]", function() {
|
||||||
return this.selectKit.options.maximum >= makeArray(this.value).length
|
const maximum = this.selectKit.options.maximum;
|
||||||
|
return maximum && makeArray(this.value).length >= parseInt(maximum, 10)
|
||||||
? null
|
? null
|
||||||
: "plus";
|
: "plus";
|
||||||
}),
|
}),
|
||||||
@ -89,18 +92,19 @@ export default ComboBox.extend(TagsMixin, {
|
|||||||
modifySelection(content) {
|
modifySelection(content) {
|
||||||
let joinedTags = makeArray(this.value).join(", ");
|
let joinedTags = makeArray(this.value).join(", ");
|
||||||
|
|
||||||
if (!this.selectKit.options.maximum >= makeArray(this.value).length) {
|
const minimum = this.selectKit.options.minimum;
|
||||||
|
if (minimum && makeArray(this.value).length < parseInt(minimum, 10)) {
|
||||||
const key =
|
const key =
|
||||||
this.selectKit.options.minimumLabel ||
|
this.selectKit.options.minimumLabel ||
|
||||||
"select_kit.min_content_not_reached";
|
"select_kit.min_content_not_reached";
|
||||||
const label = I18n.t(key, { count: this.selectKit.options.minimum });
|
const label = I18n.t(key, { count: this.selectKit.options.minimum });
|
||||||
content.title = content.name = content.label = label;
|
content.title = content.name = content.label = label;
|
||||||
}
|
} else {
|
||||||
|
content.title = content.name = content.value = content.label = joinedTags;
|
||||||
|
|
||||||
content.title = content.name = content.value = content.label = joinedTags;
|
if (content.label.length > 32) {
|
||||||
|
content.label = `${content.label.slice(0, 32)}...`;
|
||||||
if (content.label.length > 32) {
|
}
|
||||||
content.label = `${content.label.slice(0, 32)}...`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
|
@ -255,9 +255,9 @@ export default Component.extend(
|
|||||||
icon: null,
|
icon: null,
|
||||||
icons: null,
|
icons: null,
|
||||||
maximum: null,
|
maximum: null,
|
||||||
|
maximumLabel: null,
|
||||||
minimum: null,
|
minimum: null,
|
||||||
minimumLabel: null,
|
minimumLabel: null,
|
||||||
maximumLabel: null,
|
|
||||||
autoInsertNoneItem: true,
|
autoInsertNoneItem: true,
|
||||||
clearOnClick: false,
|
clearOnClick: false,
|
||||||
closeOnChange: true,
|
closeOnChange: true,
|
||||||
|
@ -24,7 +24,8 @@ export default Mixin.create({
|
|||||||
allowAnyTag: reads("site.can_create_tag"),
|
allowAnyTag: reads("site.can_create_tag"),
|
||||||
|
|
||||||
validateCreate(filter, content) {
|
validateCreate(filter, content) {
|
||||||
if (this.selectKit.options.maximum >= makeArray(this.value).length) {
|
const maximum = this.selectKit.options.maximum;
|
||||||
|
if (maximum && makeArray(this.value).length >= parseInt(maximum, 10)) {
|
||||||
this.addError(
|
this.addError(
|
||||||
I18n.t("select_kit.max_content_reached", {
|
I18n.t("select_kit.max_content_reached", {
|
||||||
count: this.selectKit.limit
|
count: this.selectKit.limit
|
||||||
|
Reference in New Issue
Block a user