group-settings: Use group_setting_value_pill_input template.

We now use group_setting_value_pill_input template for user
group permission settings to avoid duplicate code.
This commit is contained in:
Sahil Batra 2024-11-18 19:08:57 +05:30 committed by Tim Abbott
parent d5a391a56b
commit 3af84d6e69
5 changed files with 32 additions and 71 deletions

View File

@ -260,28 +260,27 @@ export function set_up_handlers(): void {
settings_components.enable_opening_typeahead_on_clicking_label($container);
can_add_members_group_widget = settings_components.create_group_setting_widget({
$pill_container: $container.find(".can-add-members-group-container .pill-container"),
$pill_container: $("#id_new_group_can_add_members_group"),
setting_name: "can_add_members_group",
});
const $pill_container = $container.find(".can-manage-group-container .pill-container");
can_manage_group_widget = settings_components.create_group_setting_widget({
$pill_container,
$pill_container: $("#id_new_group_can_manage_group"),
setting_name: "can_manage_group",
});
can_join_group_widget = settings_components.create_group_setting_widget({
$pill_container: $container.find(".can-join-group-container .pill-container"),
$pill_container: $("#id_new_group_can_join_group"),
setting_name: "can_join_group",
});
can_leave_group_widget = settings_components.create_group_setting_widget({
$pill_container: $container.find(".can-leave-group-container .pill-container"),
$pill_container: $("#id_new_group_can_leave_group"),
setting_name: "can_leave_group",
});
can_mention_group_widget = settings_components.create_group_setting_widget({
$pill_container: $container.find(".can-mention-group-container .pill-container"),
$pill_container: $("#id_new_group_can_mention_group"),
setting_name: "can_mention_group",
});
}

View File

@ -154,33 +154,32 @@ function show_membership_settings(group) {
}
function show_general_settings(group) {
const $edit_container = get_edit_container(group);
settings_components.create_group_setting_widget({
$pill_container: $edit_container.find(".can-add-members-group-container .pill-container"),
$pill_container: $("#id_can_add_members_group"),
setting_name: "can_add_members_group",
group,
});
settings_components.create_group_setting_widget({
$pill_container: $edit_container.find(".can-manage-group-container .pill-container"),
$pill_container: $("#id_can_manage_group"),
setting_name: "can_manage_group",
group,
});
settings_components.create_group_setting_widget({
$pill_container: $edit_container.find(".can-join-group-container .pill-container"),
$pill_container: $("#id_can_join_group"),
setting_name: "can_join_group",
group,
});
settings_components.create_group_setting_widget({
$pill_container: $edit_container.find(".can-leave-group-container .pill-container"),
$pill_container: $("#id_can_leave_group"),
setting_name: "can_leave_group",
group,
});
settings_components.create_group_setting_widget({
$pill_container: $edit_container.find(".can-mention-group-container .pill-container"),
$pill_container: $("#id_can_mention_group"),
setting_name: "can_mention_group",
group,
});

View File

@ -1,49 +1,24 @@
<div class="input-group can-manage-group-container">
<label class="group-setting-label">{{t "Who can administer this group" }}</label>
<div class="pill-container person_picker prop-element" id="id_{{can_manage_group_widget_name}}" data-setting-widget-type="group-setting-type">
<div class="input" contenteditable="true"
data-placeholder="{{t 'Add roles, groups or users' }}">
{{~! Squash whitespace so that placeholder is displayed when empty. ~}}
</div>
</div>
</div>
{{> ../settings/group_setting_value_pill_input
setting_name="can_manage_group"
label=(t 'Who can administer this group')
prefix=prefix }}
<div class="input-group can-mention-group-container">
<label class="group-setting-label">{{t "Who can mention this group" }}</label>
<div class="pill-container person_picker prop-element" id="id_{{can_mention_group_widget_name}}" data-setting-widget-type="group-setting-type">
<div class="input" contenteditable="true"
data-placeholder="{{t 'Add roles, groups or users' }}">
{{~! Squash whitespace so that placeholder is displayed when empty. ~}}
</div>
</div>
</div>
{{> ../settings/group_setting_value_pill_input
setting_name="can_mention_group"
label=(t 'Who can mention this group')
prefix=prefix }}
<div class="input-group can-add-members-group-container">
<label class="group-setting-label">{{t "Who can add members to this group" }}</label>
<div class="pill-container person_picker prop-element" id="id_{{can_add_members_group_widget_name}}" data-setting-widget-type="group-setting-type">
<div class="input" contenteditable="true"
data-placeholder="{{t 'Add roles, groups or users' }}">
{{~! Squash whitespace so that placeholder is displayed when empty. ~}}
</div>
</div>
</div>
{{> ../settings/group_setting_value_pill_input
setting_name="can_add_members_group"
label=(t 'Who can add members to this group')
prefix=prefix }}
<div class="input-group can-join-group-container">
<label class="group-setting-label">{{t "Who can join this group" }}</label>
<div class="pill-container person_picker prop-element" id="id_{{can_join_group_widget_name}}" data-setting-widget-type="group-setting-type">
<div class="input" contenteditable="true"
data-placeholder="{{t 'Add roles, groups or users' }}">
{{~! Squash whitespace so that placeholder is displayed when empty. ~}}
</div>
</div>
</div>
{{> ../settings/group_setting_value_pill_input
setting_name="can_join_group"
label=(t 'Who can join this group')
prefix=prefix }}
<div class="input-group can-leave-group-container">
<label class="group-setting-label">{{t "Who can leave this group" }}</label>
<div class="pill-container person_picker prop-element" id="id_{{can_leave_group_widget_name}}" data-setting-widget-type="group-setting-type">
<div class="input" contenteditable="true"
data-placeholder="{{t 'Add roles, groups or users' }}">
{{~! Squash whitespace so that placeholder is displayed when empty. ~}}
</div>
</div>
</div>
{{> ../settings/group_setting_value_pill_input
setting_name="can_leave_group"
label=(t 'Who can leave this group')
prefix=prefix }}

View File

@ -28,13 +28,7 @@
</h3>
</div>
{{> group_permissions
can_add_members_group_widget_name="new_group_can_add_members_group"
can_join_group_widget_name="new_group_can_join_group"
can_leave_group_widget_name="new_group_can_leave_group"
can_mention_group_widget_name="new_group_can_mention_group"
can_manage_group_widget_name="new_group_can_manage_group"
}}
{{> group_permissions prefix="id_new_group_"}}
</div>
</section>
</div>

View File

@ -43,13 +43,7 @@
{{> ../settings/settings_save_discard_widget section_name="group-permissions" }}
</div>
{{> group_permissions
can_add_members_group_widget_name="can_add_members_group"
can_join_group_widget_name="can_join_group"
can_leave_group_widget_name="can_leave_group"
can_mention_group_widget_name="can_mention_group"
can_manage_group_widget_name="can_manage_group"
}}
{{> group_permissions prefix="id_"}}
</div>
<div class="group_detail_box">