mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: mandatory fields for compact-list (#29357)
In this PR we introduced mandatory fields for `group-list` https://github.com/discourse/discourse/pull/26612 The same solution should apply to `compact-list`.
This commit is contained in:
parent
ca9549b04f
commit
11b62847e7
@ -5,4 +5,5 @@
|
|||||||
@onChange={{this.onChangeListSetting}}
|
@onChange={{this.onChangeListSetting}}
|
||||||
@onChangeChoices={{this.onChangeChoices}}
|
@onChangeChoices={{this.onChangeChoices}}
|
||||||
@options={{hash allowAny=this.allowAny}}
|
@options={{hash allowAny=this.allowAny}}
|
||||||
|
@mandatoryValues={{this.setting.mandatory_values}}
|
||||||
/>
|
/>
|
@ -0,0 +1,39 @@
|
|||||||
|
import EmberObject from "@ember/object";
|
||||||
|
import { render } from "@ember/test-helpers";
|
||||||
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
|
import { module, test } from "qunit";
|
||||||
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
|
|
||||||
|
module("Integration | Component | compact-list site-setting", function (hooks) {
|
||||||
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
|
test("mandatory values", async function (assert) {
|
||||||
|
this.set(
|
||||||
|
"setting",
|
||||||
|
EmberObject.create({
|
||||||
|
allowsNone: undefined,
|
||||||
|
category: "foo",
|
||||||
|
description: "Choose setting",
|
||||||
|
overridden: false,
|
||||||
|
placeholder: null,
|
||||||
|
preview: null,
|
||||||
|
secret: false,
|
||||||
|
setting: "foo_bar",
|
||||||
|
type: "compact_list",
|
||||||
|
validValues: undefined,
|
||||||
|
default: "admin",
|
||||||
|
mandatory_values: "admin",
|
||||||
|
value: "admin|moderator",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await render(hbs`<SiteSetting @setting={{this.setting}} />`);
|
||||||
|
|
||||||
|
const subject = selectKit(".list-setting");
|
||||||
|
|
||||||
|
await subject.expand();
|
||||||
|
|
||||||
|
assert.dom(".selected-content button").hasClass("disabled");
|
||||||
|
});
|
||||||
|
});
|
@ -34,6 +34,9 @@ export default class SelectedChoice extends Component.extend(UtilsMixin) {
|
|||||||
|
|
||||||
@computed("item")
|
@computed("item")
|
||||||
get readOnly() {
|
get readOnly() {
|
||||||
|
if (typeof this.item === "string") {
|
||||||
|
return this.mandatoryValuesArray.includes(this.item);
|
||||||
|
}
|
||||||
return this.mandatoryValuesArray.includes(this.item.id);
|
return this.mandatoryValuesArray.includes(this.item.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user