edit_fields_modal: Rename modal_body_html and modal_label.

This commit renames modal_body_html and modal_label to
html_body and html_heading respectively. This change
will help us easily deduplicating the confirm_dialog
and edit_fields_modal code.
This commit is contained in:
sahil839
2021-07-05 15:05:18 +05:30
committed by Tim Abbott
parent 0edb413121
commit 19362f393e
4 changed files with 13 additions and 13 deletions

View File

@@ -27,7 +27,7 @@ import * as overlays from "./overlays";
*/ */
export function launch(modal_fields) { export function launch(modal_fields) {
const required_modal_fields = ["modal_label", "parent", "modal_body_html", "on_click"]; const required_modal_fields = ["html_heading", "parent", "html_body", "on_click"];
for (const field of required_modal_fields) { for (const field of required_modal_fields) {
if (!modal_fields[field]) { if (!modal_fields[field]) {
@@ -36,7 +36,7 @@ export function launch(modal_fields) {
} }
const html = render_edit_fields_modal({ const html = render_edit_fields_modal({
modal_label: modal_fields.modal_label, html_heading: modal_fields.html_heading,
}); });
const edit_fields_modal = $(html); const edit_fields_modal = $(html);
modal_fields.parent.append(edit_fields_modal); modal_fields.parent.append(edit_fields_modal);
@@ -45,7 +45,7 @@ export function launch(modal_fields) {
overlays.close_modal("#edit-fields-modal"); overlays.close_modal("#edit-fields-modal");
} }
edit_fields_modal.find(".edit-fields-modal-body").html(modal_fields.modal_body_html); edit_fields_modal.find(".edit-fields-modal-body").html(modal_fields.html_body);
if (modal_fields.post_render !== undefined) { if (modal_fields.post_render !== undefined) {
modal_fields.post_render(); modal_fields.post_render();

View File

@@ -47,7 +47,7 @@ function sort_url(a, b) {
function open_linkifier_edit_form(linkifier_id) { function open_linkifier_edit_form(linkifier_id) {
const linkifiers_list = page_params.realm_linkifiers; const linkifiers_list = page_params.realm_linkifiers;
const linkifier = linkifiers_list.find((linkifier) => linkifier.id === linkifier_id); const linkifier = linkifiers_list.find((linkifier) => linkifier.id === linkifier_id);
const modal_body_html = render_admin_linkifier_edit_form({ const html_body = render_admin_linkifier_edit_form({
linkifier_id, linkifier_id,
pattern: linkifier.pattern, pattern: linkifier.pattern,
url_format_string: linkifier.url_format, url_format_string: linkifier.url_format,
@@ -103,9 +103,9 @@ function open_linkifier_edit_form(linkifier_id) {
} }
edit_fields_modal.launch({ edit_fields_modal.launch({
modal_label: $t({defaultMessage: "Edit linkfiers"}), html_heading: $t({defaultMessage: "Edit linkfiers"}),
parent: modal_parent, parent: modal_parent,
modal_body_html, html_body,
on_click: submit_linkifier_form, on_click: submit_linkifier_form,
}); });
} }

View File

@@ -523,7 +523,7 @@ function handle_human_form(tbody, status_field) {
return; return;
} }
const modal_body_html = render_admin_human_form({ const html_body = render_admin_human_form({
user_id, user_id,
email: person.email, email: person.email,
full_name: person.full_name, full_name: person.full_name,
@@ -575,9 +575,9 @@ function handle_human_form(tbody, status_field) {
} }
edit_fields_modal.launch({ edit_fields_modal.launch({
modal_label: $t({defaultMessage: "Change user info and roles"}), html_heading: $t({defaultMessage: "Change user info and roles"}),
parent: modal_parent, parent: modal_parent,
modal_body_html, html_body,
on_click: submit_user_details, on_click: submit_user_details,
post_render: set_role_dropdown_and_fields_user_pills, post_render: set_role_dropdown_and_fields_user_pills,
}); });
@@ -595,7 +595,7 @@ function handle_bot_form(tbody, status_field) {
return; return;
} }
const modal_body_html = render_admin_bot_form({ const html_body = render_admin_bot_form({
user_id, user_id,
email: bot.email, email: bot.email,
full_name: bot.full_name, full_name: bot.full_name,
@@ -646,9 +646,9 @@ function handle_bot_form(tbody, status_field) {
} }
edit_fields_modal.launch({ edit_fields_modal.launch({
modal_label: $t({defaultMessage: "Change bot info and owner"}), html_heading: $t({defaultMessage: "Change bot info and owner"}),
parent: modal_parent, parent: modal_parent,
modal_body_html, html_body,
on_click: submit_bot_details, on_click: submit_bot_details,
post_render: get_bot_owner_widget, post_render: get_bot_owner_widget,
}); });

View File

@@ -1,7 +1,7 @@
<div id="edit-fields-modal" class="modal modal-bg hide fade" tabindex="-1" role="dialog" aria-labelledby="edit-fields-modal-label" aria-hidden="true"> <div id="edit-fields-modal" class="modal modal-bg hide fade" tabindex="-1" role="dialog" aria-labelledby="edit-fields-modal-label" aria-hidden="true">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{{t 'Close' }}"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="modal" aria-label="{{t 'Close' }}"><span aria-hidden="true">&times;</span></button>
<h3 id="edit-fields-modal-label">{{modal_label}}</h3> <h3 id="edit-fields-modal-label">{{html_heading}}</h3>
<div class="alert" id="edit-fields-modal-status"></div> <div class="alert" id="edit-fields-modal-status"></div>
</div> </div>
<div class="modal-body edit-fields-modal-body"></div> <div class="modal-body edit-fields-modal-body"></div>