settings: Extend settings_checkbox for dependent checkboxes.

This deduplicate code for the checkboxes which are dependent on other
parameters and it makes no sense changing them when that parameter is
false.  For example, changing `message_content_in_email_notifications`
makes sense only when `enable_offline_email_notifications` is true.
This commit is contained in:
Shubham Dhama
2018-09-02 13:15:06 +05:30
committed by Tim Abbott
parent d1c62369b7
commit 3e0b420423
2 changed files with 14 additions and 28 deletions

View File

@@ -47,20 +47,12 @@
"is_checked" page_params.enable_desktop_notifications
"label" settings_label.enable_desktop_notifications}}
<div class="input-group disableable {{#unless page_params.enable_desktop_notifications}}control-label-disabled{{/unless}}">
<label class="checkbox">
<input type="checkbox" name="pm_content_in_desktop_notifications"
id="pm_content_in_desktop_notifications"
{{#unless page_params.enable_desktop_notifications}}disabled="disabled"{{/unless}}
{{#if page_params.pm_content_in_desktop_notifications}}
checked="checked"
{{/if}} />
<span></span>
</label>
<label for="pm_content_in_desktop_notifications" id="pm_content_in_desktop_notifications_label" class="inline-block">
{{settings_label.pm_content_in_desktop_notifications}}
</label>
</div>
{{partial "settings_checkbox"
"setting_name" "pm_content_in_desktop_notifications"
"is_checked" page_params.pm_content_in_desktop_notifications
"is_parent_setting_enabled" page_params.enable_desktop_notifications
"is_nested" true
"label" settings_label.pm_content_in_desktop_notifications}}
{{partial "settings_checkbox"
"setting_name" "enable_sounds"
@@ -77,19 +69,12 @@
"is_checked" page_params.enable_offline_push_notifications
"label" settings_label.enable_offline_push_notifications}}
<div class="input-group disableable {{#unless page_params.enable_offline_push_notifications}}control-label-disabled{{/unless}}">
<label class="checkbox">
<input type="checkbox" name="enable_online_push_notifications" id="enable_online_push_notifications"
{{#unless page_params.enable_offline_push_notifications}}disabled="disabled"{{/unless}}
{{#if page_params.enable_online_push_notifications}}
checked="checked"
{{/if}} />
<span></span>
</label>
<label for="enable_online_push_notifications" id="enable_online_push_notifications_label" class="inline-block">
{{settings_label.enable_online_push_notifications}}
</label>
</div>
{{partial "settings_checkbox"
"setting_name" "enable_online_push_notifications"
"is_checked" page_params.enable_online_push_notifications
"is_parent_setting_enabled" page_params.enable_offline_push_notifications
"is_nested" true
"label" settings_label.enable_online_push_notifications}}
</div>
<div id="other_notifications">

View File

@@ -1,7 +1,8 @@
<div class="input-group">
<div class="input-group {{#if is_nested}}disableable{{/if}} {{#is_false is_parent_setting_enabled}}control-label-disabled{{/is_false}}">
<label class="checkbox">
<input type="checkbox" class="inline-block" name="{{setting_name}}"
id="{{prefix}}{{setting_name}}"
{{#is_false is_parent_setting_enabled}}disabled="disabled"{{/is_false}}
{{#if is_checked}}
checked="checked"
{{/if}} />