Rollback pushNotificationFlexTab

pull/8411/head
Guilherme Gazzo 8 years ago
parent f4adff436e
commit 8e712192b0
No known key found for this signature in database
GPG Key ID: 1F85C9AD922D0829
  1. 14
      package-lock.json
  2. 4
      packages/rocketchat-push-notifications/client/stylesheets/pushNotifications.css
  3. 404
      packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.html
  4. 78
      packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js

14
package-lock.json generated

@ -1868,7 +1868,7 @@
"bcrypt": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-1.0.3.tgz",
"integrity": "sha512-pRyDdo73C8Nim3jwFJ7DWe3TZCgwDfWZ6nHS5LSdU77kWbj1frruvdndP02AOavtD4y8v6Fp2dolbHgp4SDrfg==",
"integrity": "sha1-sC3cbAtS6ha40883XVoy54DatUg=",
"requires": {
"nan": "2.6.2",
"node-pre-gyp": "0.6.36"
@ -5329,7 +5329,7 @@
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
@ -8255,7 +8255,7 @@
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
"requires": {
"brace-expansion": "1.1.8"
}
@ -8526,7 +8526,7 @@
"npmlog": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
"integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==",
"integrity": "sha1-CKfyqL9zRgR3mp76StXMcXq7lUs=",
"requires": {
"are-we-there-yet": "1.1.4",
"console-control-strings": "1.1.0",
@ -10930,7 +10930,7 @@
"semver": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz",
"integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg=="
"integrity": "sha1-4FnAnYVx8FQII3M0M1BdOi8AsY4="
},
"send": {
"version": "0.1.0",
@ -12707,7 +12707,7 @@
"uuid": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz",
"integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g=="
"integrity": "sha1-PdPT55Crwk17DToDT/q6vijrvAQ="
},
"validate-npm-package-license": {
"version": "3.0.1",
@ -12922,7 +12922,7 @@
"wide-align": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
"integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==",
"integrity": "sha1-Vx4PGwYEY268DfwhsDObvjE0FxA=",
"requires": {
"string-width": "1.0.2"
}

@ -1,5 +1,9 @@
.flex-tab {
& .push-notifications {
& .input.checkbox.toggle {
width: 40px;
}
& ul {
& li {
margin-bottom: 20px;

@ -1,304 +1,136 @@
<template name="pushNotificationsFlexTab">
<main class="rc-user-info__scroll">
<div class="rc-user-info__row rc-user-info__row--separator">
<div class="rc-switch-double">
<div class="rc-switch-double__label">
{{_ "Turn_OFF"}}
<div class="rc-switch-double__description">
{{_ "Mute_all_notifications"}}
</div>
</div>
<div class="rc-switch rc-switch--blue">
<label class="rc-switch__label">
<input type="checkbox" class="rc-switch__input js-input-check" value="0" id="disableNotifications" name="disableNotifications" checked="{{$eq disableNotifications false}}">
<span class="rc-switch__button">
<span class="rc-switch__button-inside"></span>
</span>
</label>
</div>
<div class="rc-switch-double__label">
{{_ "Turn_ON"}}
<div class="rc-switch-double__description">
{{_ "Receive_alerts"}}
</div>
</div>
</div>
<div class="list-view push-notifications">
<div class="title">
<h2>{{_ "Notifications"}}</h2>
</div>
<div class="rc-user-info__row rc-user-info__row--separator">
<div class="rc-switch-double">
<div class="rc-switch-double__label">
{{_ "Hide_counter"}}
<div class="rc-switch-double__description">
{{_ "Do_not_display_unread_counter"}}
<form>
<ul class="list clearfix">
<li class="disable-notifications">
<label>{{_ "Disable_Notifications"}}</label>
<div class="input checkbox toggle">
<input type="checkbox" id="disableNotifications" name="disableNotifications" value="1" checked="{{$eq disableNotifications true}}" />
<label for="disableNotifications"></label>
</div>
</div>
<div class="rc-switch rc-switch--blue">
<label class="rc-switch__label">
<input type="checkbox" class="rc-switch__input js-input-check" id="hideUnreadStatus" name="hideUnreadStatus" value="1" checked="{{$eq hideUnreadStatus true}}">
<span class="rc-switch__button">
<span class="rc-switch__button-inside"></span>
</span>
</label>
</div>
<div class="rc-switch-double__label">
{{_ "Show_counter"}}
<div class="rc-switch-double__description">
{{_ "Display_unread_counter"}}
</div>
</div>
</div>
</div>
<div class="rc-user-info__row rc-user-info__row--separator">
<div class="rc-switch-double">
<div class="rc-switch-double__label">
{{_ "User_default"}}
<div class="rc-switch-double__description">
{{_ "Keep_default_user_settings"}}
</div>
</div>
<div class="rc-switch rc-switch--blue">
<label class="rc-switch__label">
<input type="checkbox" class="rc-switch__input js-input-check" id="customize" name="customize" value="1" checked="{{$eq customize true}}">
<span class="rc-switch__button">
<span class="rc-switch__button-inside"></span>
</span>
</label>
</div>
<div class="rc-switch-double__label">
{{_ "Customize"}}
<div class="rc-switch-double__description">
{{_ "Create_unique_rules_for_this_channel"}}
</div>
</div>
</div>
</div>
{{#if $eq disableNotifications false}}
<div class="rc-user-info__row rc-user-info__row--separator">
<div class="rc-user-info__config">
<div class="rc-user-info__config-header">
{{> icon block="rc-user-info__config-icon" icon="computer"}}
<span class="rc-user-info__config-label">Desktop</span>
</div>
<div class="rc-user-info__config-content">
<div class="rc-user-info__config-name">Alerts:</div>
<div class="rc-user-info__config-value">
{{# with desktopNotifications}}
{{subValue 'desktopNotifications'}}
{{> icon block="rc-user-info__config-content-icon" icon="arrow-down"}}
{{/with}}
</div>
</div>
<div class="rc-user-info__config-content">
<div class="rc-user-info__config-name">Audio:</div>
<div class="rc-user-info__config-value">
{{audioNotificationValue}}
{{> icon block="rc-user-info__config-content-icon" icon="arrow-down"}}
</div>
</div>
<div class="rc-user-info__config-content">
<div class="rc-user-info__config-name">Notifications Duration:</div>
<div class="rc-user-info__config-value">
</li>
{{#if $neq disableNotifications true}}
<li class="audio-notifications">
<label>{{_ "Audio"}}</label>
<div>
{{#if editing 'audioNotifications'}}
<label><input type="radio" name="audioNotifications" value="default" checked="{{$eq audioNotifications 'default'}}" /> {{_ "Default"}} ({{_ defaultAudioNotification}})</label>
<label><input type="radio" name="audioNotifications" value="all" checked="{{$eq audioNotifications 'all'}}" /> {{_ "All_messages"}}</label>
<label><input type="radio" name="audioNotifications" value="mentions" checked="{{$eq audioNotifications 'mentions'}}" /> {{_ "Mentions"}}</label>
<br />
<label>
<select name="audioNotificationValue" class="audio">
<option value="none" selected="{{$eq audioNotificationValue 'none'}}">{{_ "None"}}</option>
<option value="" selected="{{$eq audioNotificationValue subValue 'audioNotifications'}}">{{_ "Use_account_preference"}} ({{_ "Default"}})</option>
<option value="chime" selected="{{$eq audioNotificationValue 'chime'}}">Chime</option>
{{#each audioAssets}}
<option value="{{_id}}" selected="{{$eq audioNotificationValue _id}}">{{name}}</option>
{{/each}}
</select>
</label>
<button type="button" class="button cancel">{{_ "Cancel"}}</button>
<button type="button" class="button primary save">{{_ "Save"}}</button>
{{else}}
<span class="current-setting">{{subValue 'audioNotifications'}} : {{audioNotificationValue}}<i class="icon-play-circled" data-play="{{audioNotificationValue}}"></i> <i class="icon-pencil" data-edit="audioNotifications"></i></span>
{{/if}}
</div>
</li>
<li class="desktop-notifications">
<label>{{_ "Desktop"}}</label>
<div>
{{#if editing 'desktopNotifications'}}
<label><input type="radio" name="desktopNotifications" value="default" checked="{{$eq desktopNotifications 'default'}}" /> {{_ "Default"}} ({{_ defaultDesktopNotification}})</label>
<label><input type="radio" name="desktopNotifications" value="all" checked="{{$eq desktopNotifications 'all'}}" /> {{_ "All_messages"}}</label>
<label><input type="radio" name="desktopNotifications" value="mentions" checked="{{$eq desktopNotifications 'mentions'}}" /> {{_ "Mentions"}}</label>
<label><input type="radio" name="desktopNotifications" value="nothing" checked="{{$eq desktopNotifications 'nothing'}}" /> {{_ "Nothing"}}</label>
<br />
{{#if desktopNotificationDuration}}
{{_ "Duration"}} {{desktopNotificationDuration}} {{_ "seconds"}}
<label>{{_ "Duration"}} ({{_ "seconds"}}) <input type="number" name="duration" min="0" value="{{desktopNotificationDuration}}" class="content-background-color"></label>
{{else}}
{{_ "Use_User_Preferences_or_Global_Settings"}}
<label>{{_ "Duration"}} ({{_ "seconds"}}) <input type="number" name="duration" min="0" value="" placeholder="{{_ "Use_User_Preferences_or_Global_Settings"}}"></label>
{{/if}}
{{> icon block="rc-user-info__config-content-icon" icon="arrow-down"}}
</div>
</div>
</div>
</div>
<div class="rc-user-info__row rc-user-info__row--separator">
<div class="rc-user-info__config">
<div class="rc-user-info__config-header">
{{> icon block="rc-user-info__config-icon" icon="mobile"}}
<span class="rc-user-info__config-label">Mobile</span>
</div>
<div class="rc-user-info__config-content">
<div class="rc-user-info__config-name">Alerts:</div>
<div class="rc-user-info__config-value">
{{defaultMobileNotification}}
{{> icon block="rc-user-info__config-content-icon" icon="arrow-down"}}
</div>
</div>
</div>
</div>
<div class="rc-user-info__row rc-user-info__row--separator">
<div class="rc-user-info__config">
<div class="rc-user-info__config-header">
{{> icon block="rc-user-info__config-icon" icon="mail"}}
<span class="rc-user-info__config-label">E-mail</span>
</div>
<div class="rc-user-info__config-content">
<div class="rc-user-info__config-name">Alerts:</div>
<div class="rc-user-info__config-value">
{{subValue 'emailNotifications'}}
{{> icon block="rc-user-info__config-content-icon" icon="arrow-down"}}
</div>
</div>
</div>
</div>
{{/if}}
</main>
<div class="rc-user-info__flex rc-user-info__row">
<button class="rc-button js-cancel rc-button--outline" title="{{_ 'Cancel'}}">{{_ 'Cancel'}}</button>
<button class="rc-button rc-button--primary js-save" title="{{_ 'Save'}}">{{_ 'Save'}}</button>
</div>
{{#if false}}
<form>
<ul class="list clearfix">
{{#if $eq disableNotifications false}}
<li class="audio-notifications">
<label>{{_ "Audio"}}</label>
<div>
{{#if editing 'audioNotifications'}}
<label><input type="radio" name="audioNotifications" value="default" checked="{{$eq audioNotifications 'default'}}" /> {{_ "Default"}} ({{_ defaultAudioNotification}})</label>
<label><input type="radio" name="audioNotifications" value="all" checked="{{$eq audioNotifications 'all'}}" /> {{_ "All_messages"}}</label>
<label><input type="radio" name="audioNotifications" value="mentions" checked="{{$eq audioNotifications 'mentions'}}" /> {{_ "Mentions"}}</label>
<br />
<label>
<select name="audioNotificationValue" class="rc-input rc-input--small audio">
<option value="none" selected="{{$eq audioNotificationValue 'none'}}">{{_ "None"}}</option>
<option value="" selected="{{$eq audioNotificationValue subValue 'audioNotifications'}}">{{_ "Use_account_preference"}} ({{_ "Default"}})</option>
<option value="chime" selected="{{$eq audioNotificationValue 'chime'}}">Chime</option>
{{#each audioAssets}}
<option value="{{_id}}" selected="{{$eq audioNotificationValue _id}}">{{name}}</option>
{{/each}}
</select>
</label>
<button type="button" class="rc-button rc-button--secondary cancel">{{_ "Cancel"}}</button>
<button type="button" class="rc-button rc-button--primary save">{{_ "Save"}}</button>
{{else}}
<span class="current-setting">{{subValue 'audioNotifications'}} : {{audioNotificationValue}}<i class="icon-play-circled" data-play="{{audioNotificationValue}}"></i> <i class="icon-pencil" data-edit="audioNotifications"></i></span>
{{/if}}
</div>
</li>
<li class="desktop-notifications">
<label>{{_ "Desktop"}}</label>
<div>
{{#if editing 'desktopNotifications'}}
<label><input type="radio" name="desktopNotifications" value="default" checked="{{$eq desktopNotifications 'default'}}" /> {{_ "Default"}} ({{_ defaultDesktopNotification}})</label>
<label><input type="radio" name="desktopNotifications" value="all" checked="{{$eq desktopNotifications 'all'}}" /> {{_ "All_messages"}}</label>
<label><input type="radio" name="desktopNotifications" value="mentions" checked="{{$eq desktopNotifications 'mentions'}}" /> {{_ "Mentions"}}</label>
<label><input type="radio" name="desktopNotifications" value="nothing" checked="{{$eq desktopNotifications 'nothing'}}" /> {{_ "Nothing"}}</label>
<br />
{{#if desktopNotificationDuration}}
<div class="rc-input">
<label class="rc-input__label">
{{_ "Duration"}} ({{_ "seconds"}})
<div class="rc-input__wrapper">
<input type="number" class="rc-input__element" name="duration" min="0" value="{{desktopNotificationDuration}}">
</div>
</label>
</div>
<button type="button" class="button cancel">{{_ "Cancel"}}</button>
<button type="button" class="button primary save">{{_ "Save"}}</button>
{{else}}
<div class="rc-input">
<label class="rc-input__label">
{{_ "Duration"}} ({{_ "seconds"}})
<div class="rc-input__wrapper">
<input type="number" class="rc-input__element" name="duration" min="0" value="" placeholder="{{_ "Use_User_Preferences_or_Global_Settings"}}">
</div>
</label>
</div>
<span class="current-setting">{{subValue 'desktopNotifications'}} <i class="icon-pencil" data-edit="desktopNotifications"></i></span>
{{/if}}
<button type="button" class="rc-button rc-button--secondary cancel">{{_ "Cancel"}}</button>
<button type="button" class="rc-button rc-button--primary save">{{_ "Save"}}</button>
{{else}}
<span class="current-setting">{{subValue 'desktopNotifications'}} <i class="icon-pencil" data-edit="desktopNotifications"></i></span>
{{/if}}
</div>
</li>
{{#unless editing 'desktopNotifications'}}
<li class="desktop-notifications-duration">
<label>{{_ "Desktop_Notifications_Duration"}}</label>
<div>
<span class="current-setting">{{#if desktopNotificationDuration}}{{desktopNotificationDuration}} {{_"seconds"}}{{else}}{{_ "Use_User_Preferences_or_Global_Settings"}}{{/if}}</span>
</div>
</li>
{{/unless}}
<li class="mobile-notifications">
<label>{{_ "Mobile"}}</label>
<div>
{{#if editing 'mobilePushNotifications'}}
<label><input type="radio" name="mobilePushNotifications" value="default" checked="{{$eq mobilePushNotifications 'default'}}" /> {{_ "Default"}} ({{_ defaultMobileNotification}})</label>
<label><input type="radio" name="mobilePushNotifications" value="all" checked="{{$eq mobilePushNotifications 'all'}}" /> {{_ "All_messages"}}</label>
<label><input type="radio" name="mobilePushNotifications" value="mentions" checked="{{$eq mobilePushNotifications 'mentions'}}" /> {{_ "Mentions"}}</label>
<label><input type="radio" name="mobilePushNotifications" value="nothing" checked="{{$eq mobilePushNotifications 'nothing'}}" /> {{_ "Nothing"}}</label>
<button type="button" class="rc-button rc-button--secondary cancel">{{_ "Cancel"}}</button>
<button type="button" class="rc-button rc-button--primary save">{{_ "Save"}}</button>
{{else}}
<span class="current-setting">{{subValue 'mobilePushNotifications'}} <i class="icon-pencil" data-edit="mobilePushNotifications"></i></span>
{{/if}}
</div>
</li>
{{#unless editing 'desktopNotifications'}}
<li class="desktop-notifications-duration">
<label>{{_ "Desktop_Notifications_Duration"}}</label>
<div>
<span class="current-setting">{{#if desktopNotificationDuration}}{{desktopNotificationDuration}} {{_"seconds"}}{{else}}{{_ "Use_User_Preferences_or_Global_Settings"}}{{/if}}</span>
</div>
</li>
{{/unless}}
<li class="mobile-notifications">
<label>{{_ "Mobile"}}</label>
<div>
{{#if editing 'mobilePushNotifications'}}
<label><input type="radio" name="mobilePushNotifications" value="default" checked="{{$eq mobilePushNotifications 'default'}}" /> {{_ "Default"}} ({{_ defaultMobileNotification}})</label>
<label><input type="radio" name="mobilePushNotifications" value="all" checked="{{$eq mobilePushNotifications 'all'}}" /> {{_ "All_messages"}}</label>
<label><input type="radio" name="mobilePushNotifications" value="mentions" checked="{{$eq mobilePushNotifications 'mentions'}}" /> {{_ "Mentions"}}</label>
<label><input type="radio" name="mobilePushNotifications" value="nothing" checked="{{$eq mobilePushNotifications 'nothing'}}" /> {{_ "Nothing"}}</label>
<button type="button" class="button cancel">{{_ "Cancel"}}</button>
<button type="button" class="button primary save">{{_ "Save"}}</button>
{{else}}
<span class="current-setting">{{subValue 'mobilePushNotifications'}} <i class="icon-pencil" data-edit="mobilePushNotifications"></i></span>
{{/if}}
</div>
</li>
<li class="email-notifications">
<label>{{_ "Email"}}</label>
<div>
{{#if editing 'emailNotifications'}}
<label><input type="radio" name="emailNotifications" value="all" checked="{{$eq emailNotifications 'all'}}" /> {{_ "All_messages"}}</label>
{{#if showEmailMentions}}
<label><input type="radio" name="emailNotifications" value="mentions" checked="{{$eq emailNotifications 'mentions'}}" /> {{_ "Mentions"}}</label>
{{/if}}
<label><input type="radio" name="emailNotifications" value="nothing" checked="{{$eq emailNotifications 'nothing'}}" /> {{_ "Nothing"}}</label>
<label><input type="radio" name="emailNotifications" value="default" checked="{{$eq emailNotifications 'default'}}" /> {{_ "Use_account_preference"}}</label>
<button type="button" class="button cancel">{{_ "Cancel"}}</button>
<button type="button" class="button primary save">{{_ "Save"}}</button>
{{else}}
<span class="current-setting">{{subValue 'emailNotifications'}} <i class="icon-pencil" data-edit="emailNotifications"></i></span>
{{/if}}
</div>
</li>
{{#unless emailVerified}}
<li class="email-alerts">
<div class="alert alert-warning pending-background pending-border">
{{_ "You_wont_receive_email_notifications_because_you_have_not_verified_your_email"}}
</div>
</li>
{{/unless}}
{{/if}}
<li class="unread-room-status">
<label>{{_ "Hide_Unread_Room_Status"}}</label>
<div class="input checkbox toggle">
<input type="checkbox" id="hideUnreadStatus" name="hideUnreadStatus" value="1" checked="{{$eq hideUnreadStatus true}}" />
<label for="hideUnreadStatus"></label>
</div>
</li>
<li class="email-notifications">
<label>{{_ "Email"}}</label>
<li class="unread-alerts">
<label>{{_ "Unread_Tray_Icon_Alert"}}</label>
<div>
{{#if editing 'emailNotifications'}}
<label><input type="radio" name="emailNotifications" value="all" checked="{{$eq emailNotifications 'all'}}" /> {{_ "All_messages"}}</label>
{{#if showEmailMentions}}
<label><input type="radio" name="emailNotifications" value="mentions" checked="{{$eq emailNotifications 'mentions'}}" /> {{_ "Mentions"}}</label>
{{/if}}
<label><input type="radio" name="emailNotifications" value="nothing" checked="{{$eq emailNotifications 'nothing'}}" /> {{_ "Nothing"}}</label>
<label><input type="radio" name="emailNotifications" value="default" checked="{{$eq emailNotifications 'default'}}" /> {{_ "Use_account_preference"}}</label>
<button type="button" class="rc-button rc-button--secondary cancel">{{_ "Cancel"}}</button>
<button type="button" class="rc-button rc-button--primary save">{{_ "Save"}}</button>
{{#if editing 'unreadAlert'}}
<label><input type="radio" name="unreadAlert" value="all" checked="{{$eq unreadAlert 'all'}}" /> {{_ "On"}}</label>
<label><input type="radio" name="unreadAlert" value="nothing" checked="{{$eq unreadAlert 'nothing'}}" /> {{_ "Off"}}</label>
<label><input type="radio" name="unreadAlert" value="default" checked="{{$eq unreadAlert 'default'}}" /> {{_ "Use_account_preference"}}</label>
<button type="button" class="button cancel">{{_ "Cancel"}}</button>
<button type="button" class="button primary save">{{_ "Save"}}</button>
{{else}}
<span class="current-setting">{{subValue 'emailNotifications'}} <i class="icon-pencil" data-edit="emailNotifications"></i></span>
<span class="current-setting">{{unreadAlertText}} <i class="icon-pencil" data-edit="unreadAlert"></i></span>
{{/if}}
</div>
</li>
{{#unless emailVerified}}
<li class="email-alerts">
<div class="alert alert-warning pending-background pending-border">
{{_ "You_wont_receive_email_notifications_because_you_have_not_verified_your_email"}}
</div>
</li>
{{/unless}}
{{/if}}
<li class="unread-alerts">
<label>{{_ "Unread_Tray_Icon_Alert"}}</label>
<div>
{{#if editing 'unreadAlert'}}
<label><input type="radio" name="unreadAlert" value="all" checked="{{$eq unreadAlert 'all'}}" /> {{_ "On"}}</label>
<label><input type="radio" name="unreadAlert" value="nothing" checked="{{$eq unreadAlert 'nothing'}}" /> {{_ "Off"}}</label>
<label><input type="radio" name="unreadAlert" value="default" checked="{{$eq unreadAlert 'default'}}" /> {{_ "Use_account_preference"}}</label>
<button type="button" class="rc-button rc-button--secondary cancel">{{_ "Cancel"}}</button>
<button type="button" class="rc-button rc-button--primary save">{{_ "Save"}}</button>
{{else}}
<span class="current-setting">{{unreadAlertText}} <i class="icon-pencil" data-edit="unreadAlert"></i></span>
{{/if}}
</div>
</li>
</ul>
</form>
{{/if}}
</template>
<template name="pushNotificationsPopover">
{{#each options}}
<div class="rc-popover__item">
<input type="radio" class="rc-popover__item-radio" id="{{id}}" name="{{name}}" value="{{value}}" />
<label for="{{id}}" class="rc-popover__item-radio-label">{{_ label}}</label>
</div>
{{/each}}
<!-- <div class="rc-popover__item">
<input type="radio" class="rc-popover__item-radio" id="desktopNotificationsDefault" name="desktopNotifications" value="default" />
<label for="desktopNotificationsDefault" class="rc-popover__item-radio-label">{{_ "Default"}} ({{_ defaultDesktopNotification}})</label>
</div>
<div class="rc-popover__item">
<input type="radio" class="rc-popover__item-radio" id="desktopNotificationsAll" name="desktopNotifications" value="all" />
<label for="desktopNotificationsAll" class="rc-popover__item-radio-label">{{_ "All_messages"}}</label>
</div>
<div class="rc-popover__item">
<input type="radio" class="rc-popover__item-radio" id="desktopNotificationsMentions" name="desktopNotifications" value="mentions" />
<label for="desktopNotificationsMentions" class="rc-popover__item-radio-label">{{_ "Mentions"}}</label>
</ul>
</form>
</div>
<div class="rc-popover__item">
<input type="radio" class="rc-popover__item-radio" id="desktopNotificationsNothing" name="desktopNotifications" value="nothing" />
<label for="desktopNotificationsNothing" class="rc-popover__item-radio-label">{{_ "Nothing"}}</label>
</div> -->
</template>

@ -1,5 +1,5 @@
import toastr from 'toastr';
/* globals ChatSubscription popover */
/* globals ChatSubscription */
const notificationLabels = {
all: 'All_messages',
@ -19,7 +19,7 @@ Template.pushNotificationsFlexTab.helpers({
disableNotifications: 1
}
});
return sub && sub.disableNotifications;
return sub ? sub.disableNotifications || false : false;
},
hideUnreadStatus() {
const sub = ChatSubscription.findOne({
@ -210,13 +210,13 @@ Template.pushNotificationsFlexTab.onCreated(function() {
}
};
this.saveSetting = (field) => {
field = field || this.editing.get();
this.saveSetting = () => {
const field = this.editing.get();
let value;
switch (field) {
case 'hideUnreadStatus':
case 'disableNotifications':
value = this.$(`input[name=${ field }]`)[0].checked ? '1' : '0';
value = this.$(`input[name=${ field }]:checked`).val() ? '1' : '0';
break;
default:
value = this.$(`input[name=${ field }]:checked`).val();
@ -315,72 +315,6 @@ Template.pushNotificationsFlexTab.events({
'change input[type=checkbox]'(e, instance) {
e.preventDefault();
instance.editing.set($(e.currentTarget).attr('name'));
instance.saveSetting($(e.currentTarget).attr('name'));
},
'click .rc-user-info__config-value'(e) {
const config = {
popoverClass: 'notifications-preferences',
template: 'pushNotificationsPopover',
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().left,
y: e.currentTarget.getBoundingClientRect().bottom + 50
}),
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: `${ e.currentTarget.getBoundingClientRect().left - 10 }px`
}),
data: {
value: 'default',
options : [{
id: 'desktopNotificationsDefault',
name: 'desktopNotifications',
label: 'Default',
value: 'default'
},
{
id: 'desktopNotificationsAll_messages',
name: 'desktopNotifications',
label: 'All_messages',
value: 'all'
},
{
id: 'desktopNotificationsMentions',
name: 'desktopNotifications',
label: 'Mentions',
value: 'mentions'
},
{
id: 'desktopNotificationsNothing',
name: 'desktopNotifications',
label: 'Nothing',
value: 'nothing'
}]
}
};
popover.open(config);
}
});
Template.pushNotificationsPopover.onRendered(function() {
this.find(`[value=${ this.data.value }]`).checked = true;
});
Template.pushNotificationsPopover.helpers({
options() {
return Template.instance().data.options;
},
defaultDesktopNotification() {
let preference = RocketChat.getUserPreference(Meteor.user(), 'desktopNotifications');
if (preference === 'default') {
preference = RocketChat.settings.get('Accounts_Default_User_Preferences_desktopNotifications');
}
return notificationLabels[preference];
}
});
Template.pushNotificationsPopover.events({
'change input'(e, instance) {
instance.change && instance.change(e.target.value);
instance.saveSetting();
}
});

Loading…
Cancel
Save