From 2a56c84e94463671199ae56e6e14b38016eddbec Mon Sep 17 00:00:00 2001 From: konrad Date: Wed, 7 Apr 2021 19:31:14 +0000 Subject: [PATCH] Add settings for user search (#458) Co-authored-by: kolaente Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/458 Co-authored-by: konrad Co-committed-by: konrad --- cypress/integration/list/list.spec.js | 2 +- src/models/user.js | 7 +++++++ src/models/userSettings.js | 2 ++ src/store/modules/auth.js | 15 ++++++++++----- src/views/user/Settings.vue | 17 +++++++++++++---- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/cypress/integration/list/list.spec.js b/cypress/integration/list/list.spec.js index a5abf7d72..4befee509 100644 --- a/cypress/integration/list/list.spec.js +++ b/cypress/integration/list/list.spec.js @@ -410,7 +410,7 @@ describe('Lists', () => { .should('contain', `/tasks/${tasks[0].id}`) }) - it.only('Should remove a task from the kanban board when moving it to another list', () => { + it('Should remove a task from the kanban board when moving it to another list', () => { const lists = ListFactory.create(2) BucketFactory.create(2, { list_id: '{increment}', diff --git a/src/models/user.js b/src/models/user.js index fc7f3dfdc..ef6a48ef2 100644 --- a/src/models/user.js +++ b/src/models/user.js @@ -1,8 +1,14 @@ import AbstractModel from './abstractModel' +import UserSettingsModel from '@/models/userSettings' export default class UserModel extends AbstractModel { constructor(data) { super(data) + + if (this.settings !== null) { + this.settings = new UserSettingsModel(this.settings) + } + this.created = new Date(this.created) this.updated = new Date(this.updated) } @@ -15,6 +21,7 @@ export default class UserModel extends AbstractModel { name: '', created: null, updated: null, + settings: null, } } diff --git a/src/models/userSettings.js b/src/models/userSettings.js index 2a11061f3..d6fe1dfac 100644 --- a/src/models/userSettings.js +++ b/src/models/userSettings.js @@ -6,6 +6,8 @@ export default class UserSettingsModel extends AbstractModel { return { name: '', emailRemindersEnabled: true, + discoverableByName: false, + discoverableByEmail: false, } } } \ No newline at end of file diff --git a/src/store/modules/auth.js b/src/store/modules/auth.js index 2b6673653..91c38d639 100644 --- a/src/store/modules/auth.js +++ b/src/store/modules/auth.js @@ -11,6 +11,7 @@ export default { needsTotpPasscode: false, avatarUrl: '', lastUserInfoRefresh: null, + settings: {}, }), mutations: { info(state, info) { @@ -18,10 +19,15 @@ export default { if (info !== null) { state.avatarUrl = info.getAvatarUrl() } + if (info.settings) { + state.settings = info.settings + } }, - setUserSettings(state, {name, emailRemindersEnabled}) { - state.info.name = name - state.info.emailRemindersEnabled = emailRemindersEnabled + setUserSettings(state, settings) { + state.settings = settings + const info = state.info !== null ? state.info : {} + info.name = settings.name + state.info = info }, authenticated(state, authenticated) { state.authenticated = authenticated @@ -176,7 +182,7 @@ export default { authenticated = info.exp >= ts ctx.commit('info', info) - if (authenticated ) { + if (authenticated) { const HTTP = HTTPFactory() // We're not returning the promise here to prevent blocking the initial ui render if the user is // accessing the site with a token in local storage @@ -190,7 +196,6 @@ export default { info.type = ctx.state.info.type info.email = ctx.state.info.email info.exp = ctx.state.info.exp - info.emailRemindersEnabled = ctx.state.info.emailRemindersEnabled ctx.commit('info', info) ctx.commit('authenticated', authenticated) diff --git a/src/views/user/Settings.vue b/src/views/user/Settings.vue index f9f2463b1..9608890e6 100644 --- a/src/views/user/Settings.vue +++ b/src/views/user/Settings.vue @@ -108,6 +108,18 @@ Send me Reminders for tasks via Email +
+ +
+
+ +