From 4a02a1b496e22028b6beebcf866c140663c8602c Mon Sep 17 00:00:00 2001 From: konrad Date: Sat, 19 Dec 2020 00:12:30 +0000 Subject: [PATCH] Add setting for sending reminder emails (#343) Fix the "Import your data button" in the settings Add setting for sending reminder emails Co-authored-by: kolaente Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/343 Co-Authored-By: konrad Co-Committed-By: konrad --- src/models/userName.js | 10 ------ src/models/userSettings.js | 11 +++++++ src/services/userName.js | 10 ------ src/services/userSettings.js | 10 ++++++ src/store/modules/auth.js | 3 +- src/views/user/Settings.vue | 59 ++++++++++++++++++++---------------- 6 files changed, 56 insertions(+), 47 deletions(-) delete mode 100644 src/models/userName.js create mode 100644 src/models/userSettings.js delete mode 100644 src/services/userName.js create mode 100644 src/services/userSettings.js diff --git a/src/models/userName.js b/src/models/userName.js deleted file mode 100644 index 1e1cc5d4..00000000 --- a/src/models/userName.js +++ /dev/null @@ -1,10 +0,0 @@ - -import AbstractModel from './abstractModel' - -export default class UserNameModel extends AbstractModel { - defaults() { - return { - name: '', - } - } -} \ No newline at end of file diff --git a/src/models/userSettings.js b/src/models/userSettings.js new file mode 100644 index 00000000..2a11061f --- /dev/null +++ b/src/models/userSettings.js @@ -0,0 +1,11 @@ + +import AbstractModel from './abstractModel' + +export default class UserSettingsModel extends AbstractModel { + defaults() { + return { + name: '', + emailRemindersEnabled: true, + } + } +} \ No newline at end of file diff --git a/src/services/userName.js b/src/services/userName.js deleted file mode 100644 index 83a09cd7..00000000 --- a/src/services/userName.js +++ /dev/null @@ -1,10 +0,0 @@ - -import AbstractService from './abstractService' - -export default class UserNameService extends AbstractService { - constructor() { - super({ - update: '/user/settings/name', - }) - } -} \ No newline at end of file diff --git a/src/services/userSettings.js b/src/services/userSettings.js new file mode 100644 index 00000000..eb7aebf2 --- /dev/null +++ b/src/services/userSettings.js @@ -0,0 +1,10 @@ + +import AbstractService from './abstractService' + +export default class UserSettingsService extends AbstractService { + constructor() { + super({ + update: '/user/settings/general', + }) + } +} \ No newline at end of file diff --git a/src/store/modules/auth.js b/src/store/modules/auth.js index b431d53e..6dd48623 100644 --- a/src/store/modules/auth.js +++ b/src/store/modules/auth.js @@ -16,8 +16,9 @@ export default { state.info = info state.avatarUrl = info.getAvatarUrl() }, - setUserName(state, name) { + setUserSettings(state, {name, emailRemindersEnabled}) { state.info.name = name + state.info.emailRemindersEnabled = emailRemindersEnabled }, authenticated(state, authenticated) { state.authenticated = authenticated diff --git a/src/views/user/Settings.vue b/src/views/user/Settings.vue index 5fabdd95..aa49f4b4 100644 --- a/src/views/user/Settings.vue +++ b/src/views/user/Settings.vue @@ -106,30 +106,36 @@ - +

- Update your name + General Settings

-
- -
- -
+
+ +
+
+
+
+ +
- @@ -217,7 +223,7 @@
Import your data into Vikunja @@ -266,8 +272,8 @@ import EmailUpdateService from '../../services/emailUpdate' import EmailUpdateModel from '../../models/emailUpdate' import TotpModel from '../../models/totp' import TotpService from '../../services/totp' -import UserNameService from '../../services/userName' -import UserNameModel from '../../models/userName' +import UserSettingsService from '../../services/userSettings' +import UserSettingsModel from '../../models/userSettings' import {mapState} from 'vuex' @@ -295,8 +301,8 @@ export default { caldavUrl: '', - name: '', - userNameService: UserNameService, + settings: UserSettingsModel, + userSettingsService: UserSettingsService, } }, components: { @@ -312,8 +318,11 @@ export default { this.totpService = new TotpService() this.totp = new TotpModel() - this.userNameService = new UserNameService() - this.name = this.$store.state.auth.info.name + this.userSettingsService = new UserSettingsService() + this.settings = new UserSettingsModel({ + name: this.$store.state.auth.info.name, + emailRemindersEnabled: this.$store.state.auth.info.emailRemindersEnabled ?? false, + }) this.totpStatus() this.buildCaldavUrl() @@ -399,12 +408,10 @@ export default { }) .catch(e => this.error(e, this)) }, - updateName() { - const name = new UserNameModel({name: this.name}) - - this.userNameService.update(name) + updateSettings() { + this.userSettingsService.update(this.settings) .then(() => { - this.$store.commit('auth/setUserName', this.name) + this.$store.commit('auth/setUserSettings', this.settings) this.success({message: 'The name was successfully changed.'}, this) }) .catch(e => this.error(e, this))