diff --git a/src/components/tasks/add-task.vue b/src/components/tasks/add-task.vue index 5a4db5504..8607574b1 100644 --- a/src/components/tasks/add-task.vue +++ b/src/components/tasks/add-task.vue @@ -73,10 +73,14 @@ export default { this.labelTaskService = new LabelTaskService() }, beforeMount() { - console.log(this.listId) + // If the parent provides the ID alway use that be falling back to the one + // stored in settings. If neither are avliable then hide the component. if (this.listId !== undefined) { this.listIdForNewTask = this.listId this.validListIdAvailable = true + } else if(this.$store.state.auth.settings.defaultListID !== undefined) { + this.listIdForNewTask = this.$store.state.auth.settings.defaultListID + this.validListIdAvailable = true } }, methods: { diff --git a/src/components/tasks/partials/listSearch.vue b/src/components/tasks/partials/listSearch.vue index 9d1582f25..06c14f3a3 100644 --- a/src/components/tasks/partials/listSearch.vue +++ b/src/components/tasks/partials/listSearch.vue @@ -35,9 +35,18 @@ export default { components: { Multiselect, }, + props: { + listId: { + type: Number, + required: false, + }, + }, beforeMount() { this.listSerivce = new ListService() this.list = new ListModel() + if (this.listId !== undefined) { + this.getListById() + } }, methods: { findLists(query) { @@ -54,6 +63,15 @@ export default { this.error(e, this) }) }, + getListById() { + this.listService.get({id: this.listId}) + .then(response => { + this.$set(this, 'foundLists', response) + }) + .catch(e => { + this.error(e, this) + }) + }, clearAll() { this.$set(this, 'foundLists', []) }, diff --git a/src/models/userSettings.js b/src/models/userSettings.js index 71166534c..5d3973be2 100644 --- a/src/models/userSettings.js +++ b/src/models/userSettings.js @@ -9,6 +9,7 @@ export default class UserSettingsModel extends AbstractModel { discoverableByName: false, discoverableByEmail: false, overdueTasksRemindersEnabled: true, + defaultListID: 1, weekStart: 0, } } diff --git a/src/store/modules/auth.js b/src/store/modules/auth.js index 1f9aea6b6..78aa3e831 100644 --- a/src/store/modules/auth.js +++ b/src/store/modules/auth.js @@ -1,8 +1,11 @@ -import {HTTPFactory} from '@/http-common' -import {ERROR_MESSAGE, LOADING} from '../mutation-types' +import { HTTPFactory } from '@/http-common' +import { ERROR_MESSAGE, LOADING } from '../mutation-types' import UserModel from '../../models/user' const defaultSettings = settings => { + if (typeof settings.defaultListID === 'undefined' || settings.defaultListID === '') { + settings.defaultListID = 1 + } if (typeof settings.weekStart === 'undefined' || settings.weekStart === '') { settings.weekStart = 0 } @@ -57,7 +60,7 @@ export default { // Logs a user in with a set of credentials. login(ctx, credentials) { const HTTP = HTTPFactory() - ctx.commit(LOADING, true, {root: true}) + ctx.commit(LOADING, true, { root: true }) // Delete an eventually preexisting old token localStorage.removeItem('token') @@ -92,13 +95,13 @@ export default { if (e.response.status === 401) { errorMsg = 'Wrong username or password.' } - ctx.commit(ERROR_MESSAGE, errorMsg, {root: true}) + ctx.commit(ERROR_MESSAGE, errorMsg, { root: true }) } return Promise.reject() }) .finally(() => { - ctx.commit(LOADING, false, {root: true}) + ctx.commit(LOADING, false, { root: true }) }) }, // Registers a new user and logs them in. @@ -115,18 +118,18 @@ export default { }) .catch(e => { if (e.response && e.response.data && e.response.data.message) { - ctx.commit(ERROR_MESSAGE, e.response.data.message, {root: true}) + ctx.commit(ERROR_MESSAGE, e.response.data.message, { root: true }) } return Promise.reject(e) }) .finally(() => { - ctx.commit(LOADING, false, {root: true}) + ctx.commit(LOADING, false, { root: true }) }) }, - openIdAuth(ctx, {provider, code}) { + openIdAuth(ctx, { provider, code }) { const HTTP = HTTPFactory() - ctx.commit(LOADING, true, {root: true}) + ctx.commit(LOADING, true, { root: true }) const data = { code: code, @@ -150,15 +153,15 @@ export default { if (e.response.status === 401) { errorMsg = 'Wrong username or password.' } - ctx.commit(ERROR_MESSAGE, errorMsg, {root: true}) + ctx.commit(ERROR_MESSAGE, errorMsg, { root: true }) } return Promise.reject() }) .finally(() => { - ctx.commit(LOADING, false, {root: true}) + ctx.commit(LOADING, false, { root: true }) }) }, - linkShareAuth(ctx, {hash, password}) { + linkShareAuth(ctx, { hash, password }) { const HTTP = HTTPFactory() return HTTP.post('/shares/' + hash + '/auth', { password: password, diff --git a/src/views/user/Settings.vue b/src/views/user/Settings.vue index 47152d80e..b7941dbb2 100644 --- a/src/views/user/Settings.vue +++ b/src/views/user/Settings.vue @@ -132,6 +132,16 @@ Play a sound when marking tasks as done +
+ +