org settings: Display empty input when message retention days is forever.

Currently we display -1 in input box of id_realm_message_retention_days
when realm_message_retention_days is -1, which isn't user friendly.
Displaying the input box as empty is more intuitive.

And if the user tries to submit an empty input box we throw invalid JSON
error that isn't user friendly either, so fixed that too. In the ideal
case, we shouldn't send the request at first place to the backend when we
don't have any input.
This commit is contained in:
Pragati Agrawal 2020-06-21 15:05:02 +05:30 committed by Tim Abbott
parent 1562ec758e
commit 33fa307c95
1 changed files with 5 additions and 2 deletions

View File

@ -237,6 +237,9 @@ function set_message_retention_setting_dropdown() {
$("#id_realm_message_retention_setting").val(value); $("#id_realm_message_retention_setting").val(value);
change_element_block_display_property('id_realm_message_retention_days', change_element_block_display_property('id_realm_message_retention_days',
value === "retain_for_period"); value === "retain_for_period");
if (get_property_value('realm_message_retention_days') === settings_config.retain_message_forever) {
$("#id_realm_message_retention_days").val('');
}
} }
function set_org_join_restrictions_dropdown() { function set_org_join_restrictions_dropdown() {
@ -721,8 +724,8 @@ exports.build_page = function () {
if (message_retention_setting_value === 'retain_forever') { if (message_retention_setting_value === 'retain_forever') {
data.message_retention_days = JSON.stringify('forever'); data.message_retention_days = JSON.stringify('forever');
} else { } else {
data.message_retention_days = exports.get_input_element_value( data.message_retention_days = JSON.stringify(exports.get_input_element_value(
$('#id_realm_message_retention_days')); $('#id_realm_message_retention_days')));
} }
} else if (subsection === 'other_settings') { } else if (subsection === 'other_settings') {
const code_block_language_value = exports.default_code_language_widget.value(); const code_block_language_value = exports.default_code_language_widget.value();