mirror of
https://github.com/zulip/zulip.git
synced 2025-10-30 19:43:47 +00:00
js: Reformat with Prettier.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
bd45216c21
commit
b65d2e063d
@@ -42,13 +42,15 @@ exports.populate_user_groups = function () {
|
||||
const user_groups_array = user_groups.get_realm_user_groups();
|
||||
|
||||
for (const data of user_groups_array) {
|
||||
user_groups_section.append(render_admin_user_group_list({
|
||||
user_group: {
|
||||
name: data.name,
|
||||
id: data.id,
|
||||
description: data.description,
|
||||
},
|
||||
}));
|
||||
user_groups_section.append(
|
||||
render_admin_user_group_list({
|
||||
user_group: {
|
||||
name: data.name,
|
||||
id: data.id,
|
||||
description: data.description,
|
||||
},
|
||||
}),
|
||||
);
|
||||
const pill_container = $('.pill-container[data-group-pills="' + data.id + '"]');
|
||||
const pills = user_pill.create_pills(pill_container);
|
||||
|
||||
@@ -78,9 +80,12 @@ exports.populate_user_groups = function () {
|
||||
pill_container.on("click", (e) => {
|
||||
e.stopPropagation();
|
||||
});
|
||||
pill_container.find(".pill").hover(() => {
|
||||
pill_container.find(".pill").find(".exit").css("opacity", "0.5");
|
||||
}, () => {});
|
||||
pill_container.find(".pill").hover(
|
||||
() => {
|
||||
pill_container.find(".pill").find(".exit").css("opacity", "0.5");
|
||||
},
|
||||
() => {},
|
||||
);
|
||||
}
|
||||
update_membership(data.id);
|
||||
|
||||
@@ -89,16 +94,23 @@ exports.populate_user_groups = function () {
|
||||
const group_data = user_groups.get_user_group_from_id(data.id);
|
||||
const original_group = Array.from(group_data.members);
|
||||
const same_groups = _.isEqual(_.sortBy(draft_group), _.sortBy(original_group));
|
||||
const description = $("#user-groups #" + data.id + " .description").text().trim();
|
||||
const name = $("#user-groups #" + data.id + " .name").text().trim();
|
||||
const description = $("#user-groups #" + data.id + " .description")
|
||||
.text()
|
||||
.trim();
|
||||
const name = $("#user-groups #" + data.id + " .name")
|
||||
.text()
|
||||
.trim();
|
||||
const user_group_status = $("#user-groups #" + data.id + " .user-group-status");
|
||||
|
||||
if (user_group_status.is(":visible")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (group_data.description === description && group_data.name === name &&
|
||||
(!draft_group.length || same_groups)) {
|
||||
if (
|
||||
group_data.description === description &&
|
||||
group_data.name === name &&
|
||||
(!draft_group.length || same_groups)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -112,13 +124,11 @@ exports.populate_user_groups = function () {
|
||||
const saved_button = $("#user-groups #" + data.id + " .save-status.sea-green");
|
||||
const save_instructions = $("#user-groups #" + data.id + " .save-instructions");
|
||||
|
||||
if (is_user_group_changed() &&
|
||||
!cancel_button.is(":visible")) {
|
||||
if (is_user_group_changed() && !cancel_button.is(":visible")) {
|
||||
saved_button.fadeOut(0);
|
||||
cancel_button.css({display: "inline-block", opacity: "0"}).fadeTo(400, 1);
|
||||
save_instructions.css({display: "block", opacity: "0"}).fadeTo(400, 1);
|
||||
} else if (!is_user_group_changed() &&
|
||||
cancel_button.is(":visible")) {
|
||||
} else if (!is_user_group_changed() && cancel_button.is(":visible")) {
|
||||
cancel_button.fadeOut();
|
||||
save_instructions.fadeOut();
|
||||
}
|
||||
@@ -131,7 +141,11 @@ exports.populate_user_groups = function () {
|
||||
if (!saved_button.is(":visible")) {
|
||||
cancel_button.fadeOut(0);
|
||||
save_instructions.fadeOut(0);
|
||||
saved_button.css({display: "inline-block", opacity: "0"}).fadeTo(400, 1).delay(2000).fadeTo(400, 0);
|
||||
saved_button
|
||||
.css({display: "inline-block", opacity: "0"})
|
||||
.fadeTo(400, 1)
|
||||
.delay(2000)
|
||||
.fadeTo(400, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,8 +174,12 @@ exports.populate_user_groups = function () {
|
||||
function save_name_desc() {
|
||||
const user_group_status = $("#user-groups #" + data.id + " .user-group-status");
|
||||
const group_data = user_groups.get_user_group_from_id(data.id);
|
||||
const description = $("#user-groups #" + data.id + " .description").text().trim();
|
||||
const name = $("#user-groups #" + data.id + " .name").text().trim();
|
||||
const description = $("#user-groups #" + data.id + " .description")
|
||||
.text()
|
||||
.trim();
|
||||
const name = $("#user-groups #" + data.id + " .name")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (group_data.description === description && group_data.name === name) {
|
||||
return;
|
||||
@@ -194,8 +212,10 @@ exports.populate_user_groups = function () {
|
||||
return true;
|
||||
}
|
||||
|
||||
const blur_exceptions = _.without([".pill-container", ".name", ".description", ".input", ".delete"],
|
||||
except_class);
|
||||
const blur_exceptions = _.without(
|
||||
[".pill-container", ".name", ".description", ".input", ".delete"],
|
||||
except_class,
|
||||
);
|
||||
if ($(event.relatedTarget).closest("#user-groups #" + data.id).length) {
|
||||
return blur_exceptions.some(
|
||||
(class_name) => $(event.relatedTarget).closest(class_name).length,
|
||||
@@ -212,8 +232,10 @@ exports.populate_user_groups = function () {
|
||||
if (do_not_blur(class_name, event)) {
|
||||
return;
|
||||
}
|
||||
if ($(event.relatedTarget).closest("#user-groups #" + data.id) &&
|
||||
$(event.relatedTarget).closest(".save-status.btn-danger").length) {
|
||||
if (
|
||||
$(event.relatedTarget).closest("#user-groups #" + data.id) &&
|
||||
$(event.relatedTarget).closest(".save-status.btn-danger").length
|
||||
) {
|
||||
exports.reload();
|
||||
return;
|
||||
}
|
||||
@@ -264,39 +286,41 @@ exports.set_up = function () {
|
||||
meta.loaded = true;
|
||||
exports.populate_user_groups();
|
||||
|
||||
$(".organization form.admin-user-group-form").off("submit").on("submit", function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$(".organization form.admin-user-group-form")
|
||||
.off("submit")
|
||||
.on("submit", function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const user_group_status = $("#admin-user-group-status");
|
||||
const user_group_status = $("#admin-user-group-status");
|
||||
|
||||
const group = {
|
||||
members: JSON.stringify([people.my_current_user_id()]),
|
||||
};
|
||||
const group = {
|
||||
members: JSON.stringify([people.my_current_user_id()]),
|
||||
};
|
||||
|
||||
for (const obj of $(this).serializeArray()) {
|
||||
if (obj.value.trim() === "") {
|
||||
continue;
|
||||
for (const obj of $(this).serializeArray()) {
|
||||
if (obj.value.trim() === "") {
|
||||
continue;
|
||||
}
|
||||
group[obj.name] = obj.value;
|
||||
}
|
||||
group[obj.name] = obj.value;
|
||||
}
|
||||
|
||||
channel.post({
|
||||
url: "/json/user_groups/create",
|
||||
data: group,
|
||||
success: function () {
|
||||
user_group_status.hide();
|
||||
ui_report.success(i18n.t("User group added!"), user_group_status);
|
||||
$("form.admin-user-group-form input[type='text']").val("");
|
||||
},
|
||||
error: function (xhr) {
|
||||
user_group_status.hide();
|
||||
const errors = JSON.parse(xhr.responseText).msg;
|
||||
xhr.responseText = JSON.stringify({msg: errors});
|
||||
ui_report.error(i18n.t("Failed"), xhr, user_group_status);
|
||||
},
|
||||
channel.post({
|
||||
url: "/json/user_groups/create",
|
||||
data: group,
|
||||
success: function () {
|
||||
user_group_status.hide();
|
||||
ui_report.success(i18n.t("User group added!"), user_group_status);
|
||||
$("form.admin-user-group-form input[type='text']").val("");
|
||||
},
|
||||
error: function (xhr) {
|
||||
user_group_status.hide();
|
||||
const errors = JSON.parse(xhr.responseText).msg;
|
||||
xhr.responseText = JSON.stringify({msg: errors});
|
||||
ui_report.error(i18n.t("Failed"), xhr, user_group_status);
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$("#user-groups").on("click", ".delete", function () {
|
||||
const group_id = parseInt($(this).parents(".user-group").attr("id"), 10);
|
||||
|
||||
Reference in New Issue
Block a user