diff --git a/package-lock.json b/package-lock.json index 4eb85940339..172fd819be4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" } diff --git a/packages/rocketchat-push-notifications/client/stylesheets/pushNotifications.css b/packages/rocketchat-push-notifications/client/stylesheets/pushNotifications.css index 484e1be06ae..ed86a59507a 100644 --- a/packages/rocketchat-push-notifications/client/stylesheets/pushNotifications.css +++ b/packages/rocketchat-push-notifications/client/stylesheets/pushNotifications.css @@ -1,5 +1,9 @@ .flex-tab { & .push-notifications { + & .input.checkbox.toggle { + width: 40px; + } + & ul { & li { margin-bottom: 20px; diff --git a/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.html b/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.html index 6ba3364ac0b..62ecc4d0602 100644 --- a/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.html +++ b/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.html @@ -1,304 +1,136 @@ - - diff --git a/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js b/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js index 05094d62cd7..19ab56debed 100644 --- a/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js +++ b/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js @@ -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(); } });