FIX: Show max tag error and prevent search (#26233)
Show the tag limit and prevent searches when max is 0
This commit is contained in:
parent
11099434b5
commit
f30cc5ebed
|
@ -67,6 +67,29 @@ module(
|
|||
);
|
||||
});
|
||||
|
||||
test("disables search and shows limit when max_tags_per_topic is zero", async function (assert) {
|
||||
this.set("value", ["cat", "kit"]);
|
||||
this.siteSettings.max_tags_per_topic = 0;
|
||||
|
||||
await render(hbs`<MiniTagChooser @value={{this.value}} />`);
|
||||
|
||||
assert.strictEqual(this.subject.header().value(), "cat,kit");
|
||||
await this.subject.expand();
|
||||
|
||||
const error = query(".select-kit-error").innerText;
|
||||
assert.strictEqual(
|
||||
error,
|
||||
I18n.t("select_kit.max_content_reached", {
|
||||
count: 0,
|
||||
})
|
||||
);
|
||||
await this.subject.fillInFilter("dawg");
|
||||
assert.notOk(
|
||||
exists(".select-kit-collection .select-kit-row"),
|
||||
"it doesn’t show any options"
|
||||
);
|
||||
});
|
||||
|
||||
test("required_tag_group", async function (assert) {
|
||||
this.set("value", ["foo", "bar"]);
|
||||
|
||||
|
|
|
@ -70,6 +70,13 @@ export default MultiSelectComponent.extend(TagsMixin, {
|
|||
}),
|
||||
|
||||
search(filter) {
|
||||
const maximum = this.selectKit.options.maximum;
|
||||
if (maximum === 0) {
|
||||
const key = "select_kit.max_content_reached";
|
||||
this.addError(I18n.t(key, { count: maximum }));
|
||||
return [];
|
||||
}
|
||||
|
||||
const data = {
|
||||
q: filter || "",
|
||||
limit: this.maxTagSearchResults,
|
||||
|
|
|
@ -371,7 +371,9 @@ export default Component.extend(
|
|||
},
|
||||
|
||||
addError(error) {
|
||||
this.errorsCollection.pushObject(error);
|
||||
if (!this.errorsCollection.includes(error)) {
|
||||
this.errorsCollection.pushObject(error);
|
||||
}
|
||||
|
||||
this._safeAfterRender(() => this.popper && this.popper.update());
|
||||
},
|
||||
|
@ -649,6 +651,12 @@ export default Component.extend(
|
|||
return [];
|
||||
}
|
||||
|
||||
if (this.selectKit.options.maximum === 0) {
|
||||
this.set("selectKit.isLoading", false);
|
||||
this.set("selectKit.hasNoContent", false);
|
||||
return [];
|
||||
}
|
||||
|
||||
content = content.concat(makeArray(result));
|
||||
content = this.selectKit.modifyContent(content).filter(Boolean);
|
||||
|
||||
|
|
Loading…
Reference in New Issue