popovers: Make a single click handler for opening bot owner popover.

We remove handle_bot_owner_profile function and we handle the opening
of popover of bot owner from a single click handler in popovers.js
using 'view_user_profile' class.

We also rename 'view_user_profile' class to 'view_full_user_profile'
for the button in popover, which is used to open full user profile.
This commit is contained in:
sahil839
2020-09-19 18:45:44 +05:30
committed by Tim Abbott
parent 4dc3e5f96f
commit 231af0f84d
3 changed files with 6 additions and 15 deletions

View File

@@ -893,7 +893,7 @@ exports.register_click_handlers = function () {
e.preventDefault();
});
$("body").on("click", ".info_popover_actions .view_user_profile", (e) => {
$("body").on("click", ".info_popover_actions .view_full_user_profile", (e) => {
const user_id = elem_to_user_id($(e.target).parents("ul"));
const user = people.get_by_user_id(user_id);
exports.show_user_profile(user);
@@ -913,10 +913,12 @@ exports.register_click_handlers = function () {
});
});
$("body").on("click", ".bot-owner-name", (e) => {
$("body").on("click", ".view_user_profile", (e) => {
const user_id = parseInt($(e.target).attr("data-user-id"), 10);
const user = people.get_by_user_id(user_id);
exports.show_user_info_popover(e.target, user);
e.stopPropagation();
e.preventDefault();
});
$("body").on("click", "#user-profile-modal #name #edit-button", () => {

View File

@@ -583,16 +583,6 @@ function handle_reactivation(tbody, status_field) {
});
}
function handle_bot_owner_profile(tbody) {
tbody.on("click", ".user_row .view_user_profile", (e) => {
const owner_id = parseInt($(e.target).attr("data-user-id"), 10);
const owner = people.get_by_user_id(owner_id);
popovers.show_user_info_popover(e.target, owner);
e.stopPropagation();
e.preventDefault();
});
}
function handle_human_form(tbody, status_field) {
tbody.on("click", ".open-user-form", (e) => {
e.stopPropagation();
@@ -686,7 +676,6 @@ section.bots.handle_events = () => {
const tbody = $("#admin_bots_table").expectOne();
const status_field = $("#bot-field-status").expectOne();
handle_bot_owner_profile(tbody);
handle_bot_deactivation(tbody, status_field);
handle_reactivation(tbody, status_field);
handle_bot_form(tbody, status_field);

View File

@@ -35,7 +35,7 @@
{{#if is_bot}}
{{#if bot_owner}}
<li>{{#tr this}}Owner{{/tr}}:
<span class="bot-owner-name" data-user-id='{{ bot_owner.user_id }}'>
<span class="bot-owner-name view_user_profile" data-user-id='{{ bot_owner.user_id }}'>
{{bot_owner.full_name}}
</span>
</li>
@@ -92,7 +92,7 @@
<hr>
{{#if show_user_profile}}
<li>
<a tabindex="0" class="view_user_profile">
<a tabindex="0" class="view_full_user_profile">
{{#if is_me}}
<i class="fa fa-user" aria-hidden="true"></i> {{#tr this}}View your profile{{/tr}}
{{else}}