dialog_widget: Update `get_current_values` function.

Updated `get_current_values` function to not include undefined keys
in current_values object and if the input field is of type file and
a file is selected then set the value equal to file object.
This commit is contained in:
Hardik Dharmani 2023-05-09 02:10:31 +05:30 committed by Tim Abbott
parent 461d935463
commit 81dfaa0602
1 changed files with 8 additions and 1 deletions

View File

@ -147,7 +147,14 @@ export function launch(conf: WidgetConfig): void {
const current_values: Record<string, unknown> = {};
$inputs.each(function () {
const property_name = $(this).attr("name")!;
if (property_name) {
if ($(this).is("input[type='file']") && $(this).prop("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).prop("files")[0];
} else {
current_values[property_name] = $(this).val();
}
}
});
return current_values;
}