From 08c7ca1833d6849d1074fa0050f354baeb43b294 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Thu, 25 Jun 2015 20:49:38 -0500 Subject: [PATCH] Refactor email notifications --- website/views/options/settings.jade | 68 ++++------------------------- 1 file changed, 9 insertions(+), 59 deletions(-) diff --git a/website/views/options/settings.jade b/website/views/options/settings.jade index 9fb52a0a80..5fd030669c 100644 --- a/website/views/options/settings.jade +++ b/website/views/options/settings.jade @@ -272,66 +272,16 @@ script(id='partials/options.settings.notifications.html', type="text/ng-template =env.t('emailNotifications') .panel-body - .checkbox - label - input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.newPM', ng-checked='user.preferences.emailNotifications.unsubscribeFromAll === false && user.preferences.emailNotifications.newPM === true', ng-change='set({"preferences.emailNotifications.newPM": user.preferences.emailNotifications.newPM ? true: false})') - span=env.t('newPM') + each notification in ['newPM', 'wonChallenge', 'giftedGems', 'giftedSubscription', 'invitedParty', 'invitedGuild', 'kickedGroup', 'questStarted', 'invitedQuest', 'inactivityEmails', 'weeklyRecaps'] + -var preference = 'user.preferences.emailNotifications.' + notification + -var unsubscribeFromAll = 'user.preferences.emailNotifications.unsubscribeFromAll' - .checkbox - label - input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.wonChallenge', ng-checked='user.preferences.emailNotifications.unsubscribeFromAll === false && user.preferences.emailNotifications.newPM === true', ng-change='set({"preferences.emailNotifications.wonChallenge": user.preferences.emailNotifications.wonChallenge ? true: false})') - span=env.t('wonChallenge') - - .checkbox - label - input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.giftedGems', ng-checked='user.preferences.emailNotifications.unsubscribeFromAll === false && user.preferences.emailNotifications.giftedGems === true', ng-change='set({"preferences.emailNotifications.giftedGems": user.preferences.emailNotifications.giftedGems ? true: false})') - span=env.t('giftedGems') - - .checkbox - label - input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.giftedSubscription', ng-checked='user.preferences.emailNotifications.unsubscribeFromAll === false && user.preferences.emailNotifications.giftedSubscription === true', ng-change='set({"preferences.emailNotifications.giftedSubscription": user.preferences.emailNotifications.giftedSubscription ? true: false})') - span=env.t('giftedSubscription') - - .checkbox - label - input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.invitedParty', ng-checked='user.preferences.emailNotifications.unsubscribeFromAll === false && user.preferences.emailNotifications.invitedParty === true', ng-change='set({"preferences.emailNotifications.invitedParty": user.preferences.emailNotifications.invitedParty ? true: false})') - span=env.t('invitedParty') - - .checkbox - label - input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.invitedGuild', ng-checked='user.preferences.emailNotifications.unsubscribeFromAll === false && user.preferences.emailNotifications.invitedGuild === true', ng-change='set({"preferences.emailNotifications.invitedGuild": user.preferences.emailNotifications.invitedGuild ? true: false})') - span=env.t('invitedGuild') - - .checkbox - label - input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.kickedGroup', ng-checked='user.preferences.emailNotifications.unsubscribeFromAll === false && user.preferences.emailNotifications.kickedGroup === true', ng-change='set({"preferences.emailNotifications.kickedGroup": user.preferences.emailNotifications.kickedGroup ? true: false})') - span=env.t('kickedGroup') - - .checkbox - label - input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.questStarted', ng-checked='user.preferences.emailNotifications.unsubscribeFromAll === false && user.preferences.emailNotifications.questStarted === true', ng-change='set({"preferences.emailNotifications.questStarted": user.preferences.emailNotifications.questStarted ? true: false})') - span=env.t('questStarted') - - .checkbox - label - input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.invitedQuest', ng-checked='user.preferences.emailNotifications.unsubscribeFromAll === false && user.preferences.emailNotifications.invitedQuest === true', ng-change='set({"preferences.emailNotifications.invitedQuest": user.preferences.emailNotifications.invitedQuest ? true: false})') - span=env.t('invitedQuest') - - //.checkbox - label - input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.remindersToLogin', ng-checked='user.preferences.emailNotifications.unsubscribeFromAll === false && user.preferences.emailNotifications.remindersToLogin === true', ng-change='set({"preferences.emailNotifications.remindersToLogin": user.preferences.emailNotifications.remindersToLogin ? true: false})') - span=env.t('remindersToLogin') - - // These are the recapture emails, important announcements was the previous name used for them - .checkbox - label - input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.importantAnnouncements', ng-checked='user.preferences.emailNotifications.unsubscribeFromAll === false && user.preferences.emailNotifications.importantAnnouncements === true', ng-change='set({"preferences.emailNotifications.importantAnnouncements": user.preferences.emailNotifications.importantAnnouncements ? true: false})') - span=env.t('inactivityEmails') - - .checkbox - label - input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.weeklyRecaps', ng-checked='user.preferences.emailNotifications.unsubscribeFromAll === false && user.preferences.emailNotifications.weeklyRecaps === true', ng-change='set({"preferences.emailNotifications.weeklyRecaps": user.preferences.emailNotifications.weeklyRecaps ? true: false})') - span=env.t('weeklyRecaps') + .checkbox: label + input(type='checkbox', ng-model='#{preference}', + ng-disabled='#{unsubscribeFromAll} === true', + ng-checked='#{unsubscribeFromAll} === false && #{preference} === true', + ng-change='set({"preferences.emailNotifications.#{notification}": #{preference} ? true: false})') + span=env.t(notification) hr