settings: Fix code for updating realm default language.

This commit fixes the bug when updating realm default
language setting by adding data-setting-widget-type
attribute to the relevant element with "prop-element"
class as get_input_element_value now expects every
element passed to it to have that attr after 64c8262eaf.

As a result we can now remove the code from
get_complete_data_for_subsection to handle realm
default language and just let get_input_element_value
handle it and it also helps in passing the parameter
unnecessary to request when the setting is not changed.
This commit is contained in:
Sahil Batra 2024-05-21 19:03:39 +05:30 committed by Tim Abbott
parent a530311646
commit ed8d7ed864
3 changed files with 3 additions and 6 deletions

View File

@ -726,6 +726,8 @@ export function get_input_element_value(
return get_dropdown_list_widget_setting_value($input_elem);
case "field-data-setting":
return get_field_data_input_value($input_elem);
case "language-setting":
return $input_elem.find(".language_selection_button span").attr("data-language-code");
default:
return undefined;
}

View File

@ -880,11 +880,6 @@ export function register_save_discard_widget_handlers(
let data = {};
switch (subsection) {
case "notifications":
data.default_language = $(
"#org-notifications .language_selection_widget .language_selection_button span",
).attr("data-language-code");
break;
case "join_settings": {
const org_join_restrictions = $("#id_realm_org_join_restrictions").val();
switch (org_join_restrictions) {

View File

@ -1,4 +1,4 @@
<div class="language_selection_widget input-group prop-element" id="id_{{section_name}}">
<div class="language_selection_widget input-group prop-element" id="id_{{section_name}}" data-setting-widget-type="language-setting">
<label class="settings-field-label">
{{section_title}}
{{#if help_link_widget_link}}