discourse/app/assets/javascripts/select-kit/addon/components/selected-choice.js
Krzysztof Kotlarek 98fc614162
FEATURE: mandatory fields for group site setting (#26612)
Automatically add `moderators` and `admins` auto groups to specific site settings.

In the new group-based permissions systems, we just want to check the user’s groups since it more accurately reflects reality

Affected settings:
- tag_topic_allowed_groups
- create_tag_allowed_groups
- send_email_messages_allowed_groups
- personal_message_enabled_groups
- here_mention_allowed_groups
- approve_unless_allowed_groups
- approve_new_topics_unless_allowed_groups
- skip_review_media_groups
- email_in_allowed_groups
- create_topic_allowed_groups
- edit_wiki_post_allowed_groups
- edit_post_allowed_groups
- self_wiki_allowed_groups
- flag_post_allowed_groups
- post_links_allowed_groups
- embedded_media_post_allowed_groups
- profile_background_allowed_groups
- user_card_background_allowed_groups
- invite_allowed_groups
- ignore_allowed_groups
- user_api_key_allowed_groups
2024-04-18 08:53:52 +10:00

35 lines
805 B
JavaScript

import Component from "@ember/component";
import { computed } from "@ember/object";
import { guidFor } from "@ember/object/internals";
import UtilsMixin from "select-kit/mixins/utils";
export default Component.extend(UtilsMixin, {
tagName: "",
item: null,
selectKit: null,
extraClass: null,
id: null,
init() {
this._super(...arguments);
this.set("id", guidFor(this));
},
itemValue: computed("item", function () {
return this.getValue(this.item);
}),
itemName: computed("item", function () {
return this.getName(this.item);
}),
mandatoryValuesArray: computed("item", function () {
return this.get("mandatoryValues")?.split("|") || [];
}),
readOnly: computed("item", function () {
return this.mandatoryValuesArray.includes(this.item.id);
}),
});