diff --git a/web/src/dialog_widget.ts b/web/src/dialog_widget.ts index 973572c17f..7838bf4ea4 100644 --- a/web/src/dialog_widget.ts +++ b/web/src/dialog_widget.ts @@ -120,6 +120,24 @@ export function close(on_hidden_callback?: () => void): void { modals.close(current_dialog_widget_id(), {on_hidden: on_hidden_callback}); } +export function get_current_values($inputs: JQuery): Record { + const current_values: Record = {}; + $inputs.each(function () { + const property_name = $(this).attr("name")!; + if (property_name) { + if (this instanceof HTMLInputElement && this.type === "file" && this.files?.length) { + // If the input is a file input and a file has been selected, set value to file object + current_values[property_name] = this.files[0]; + } else if (property_name === "edit_bot_owner") { + current_values[property_name] = $(this).find(".dropdown_widget_value").text(); + } else { + current_values[property_name] = $(this).val(); + } + } + }); + return current_values; +} + export function launch(conf: DialogWidgetConfig): string { // Mandatory fields: // * html_heading @@ -176,28 +194,6 @@ export function launch(conf: DialogWidgetConfig): string { const $submit_button = $dialog.find(".dialog_submit_button"); - function get_current_values($inputs: JQuery): Record { - const current_values: Record = {}; - $inputs.each(function () { - const property_name = $(this).attr("name")!; - if (property_name) { - if ( - this instanceof HTMLInputElement && - this.type === "file" && - this.files?.length - ) { - // If the input is a file input and a file has been selected, set value to file object - current_values[property_name] = this.files[0]; - } else if (property_name === "edit_bot_owner") { - current_values[property_name] = $(this).find(".dropdown_widget_value").text(); - } else { - current_values[property_name] = $(this).val(); - } - } - }); - return current_values; - } - if (conf.update_submit_disabled_state_on_change) { const $inputs = $dialog.find(".modal__content").find("input,select,textarea,button");