This new iteration of select-kit focuses on following best principales and disallowing mutations inside select-kit components. A best effort has been made to avoid breaking changes, however if you content was a flat array, eg: ["foo", "bar"] You will need to set valueProperty=null and nameProperty=null on the component. Also almost every component should have an `onChange` handler now to decide what to do with the updated data. **select-kit will not mutate your data by itself anymore**
55 lines
1.4 KiB
JavaScript
55 lines
1.4 KiB
JavaScript
import discourseComputed from "discourse-common/utils/decorators";
|
|
import Component from "@ember/component";
|
|
import { computed } from "@ember/object";
|
|
|
|
export default Component.extend({
|
|
tokenSeparator: "|",
|
|
|
|
init() {
|
|
this._super(...arguments);
|
|
|
|
this.trustLevelOptions = [
|
|
{
|
|
name: I18n.t("admin.groups.manage.membership.trust_levels_none"),
|
|
value: 0
|
|
},
|
|
{ name: 1, value: 1 },
|
|
{ name: 2, value: 2 },
|
|
{ name: 3, value: 3 },
|
|
{ name: 4, value: 4 }
|
|
];
|
|
},
|
|
|
|
groupTrustLevel: computed(
|
|
"model.grant_trust_level",
|
|
"trustLevelOptions",
|
|
function() {
|
|
return (
|
|
this.model.get("grant_trust_level") ||
|
|
this.trustLevelOptions.firstObject.value
|
|
);
|
|
}
|
|
),
|
|
|
|
@discourseComputed("model.visibility_level", "model.public_admission")
|
|
disableMembershipRequestSetting(visibility_level, publicAdmission) {
|
|
visibility_level = parseInt(visibility_level, 10);
|
|
return publicAdmission || visibility_level > 1;
|
|
},
|
|
|
|
@discourseComputed(
|
|
"model.visibility_level",
|
|
"model.allow_membership_requests"
|
|
)
|
|
disablePublicSetting(visibility_level, allowMembershipRequests) {
|
|
visibility_level = parseInt(visibility_level, 10);
|
|
return allowMembershipRequests || visibility_level > 1;
|
|
},
|
|
|
|
actions: {
|
|
onChangeEmailDomainsSetting(value) {
|
|
this.set("model.emailDomains", value.join(this.tokenSeparator));
|
|
}
|
|
}
|
|
});
|