Skip to content

Commit

Permalink
org_settings: Optimize data collected by populate_data_for_request.
Browse files Browse the repository at this point in the history
With the help of `check_property_changed` function now we collect the data
whose values are changed from the current one. Currently this optimizes
only for those elements whose values are collected by
`populate_data_for_request` function i.e. it doesn't optimize data
collected by `get_complete_data_for_subsection`.
  • Loading branch information
pragatiagrawal31 authored and timabbott committed Jun 25, 2019
1 parent bdbf63e commit e42abc2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
11 changes: 11 additions & 0 deletions frontend_tests/node_tests/settings_org.js
Expand Up @@ -191,6 +191,17 @@ function createSaveButtons(subsection) {
}

function test_submit_settings_form(submit_form) {
Object.assign(page_params, {
realm_bot_creation_policy: '2',
realm_email_address_visibility: '2',
realm_add_emoji_by_admins_only: true,
realm_create_stream_by_admins_only: true,
realm_waiting_period_threshold: 1,
realm_default_language: '"es"',
realm_default_twenty_four_hour_time: 'false',
realm_invite_to_stream_policy: 2,
});

global.patch_builtin('setTimeout', func => func());
const ev = {
preventDefault: noop,
Expand Down
28 changes: 15 additions & 13 deletions static/js/settings_org.js
Expand Up @@ -803,19 +803,21 @@ exports.build_page = function () {
var properties_elements = get_subsection_property_elements(subsection);
_.each(properties_elements, function (input_elem) {
input_elem = $(input_elem);
var input_type = input_elem.data("setting-widget-type");
if (input_type) {
var property_name = input_elem.attr('id').replace("id_realm_", "");
if (input_type === 'bool') {
data[property_name] = JSON.stringify(input_elem.prop('checked'));
return;
}
if (input_type === 'text') {
data[property_name] = JSON.stringify(input_elem.val().trim());
return;
}
if (input_type === 'integer') {
data[property_name] = JSON.stringify(parseInt(input_elem.val().trim(), 10));
if (check_property_changed(input_elem)) {
var input_type = input_elem.data("setting-widget-type");
if (input_type) {
var property_name = input_elem.attr('id').replace("id_realm_", "");
if (input_type === 'bool') {
data[property_name] = JSON.stringify(input_elem.prop('checked'));
return;
}
if (input_type === 'text') {
data[property_name] = JSON.stringify(input_elem.val().trim());
return;
}
if (input_type === 'integer') {
data[property_name] = JSON.stringify(parseInt(input_elem.val().trim(), 10));
}
}
}
});
Expand Down

0 comments on commit e42abc2

Please sign in to comment.