forked from vikunja/frontend
Add settings lookup to add-task
Enable specification of List ID for list-search Add default list to user settings Add default setting Update settings UI for default list
This commit is contained in:
parent
b005d023c9
commit
a9728f774d
|
@ -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: {
|
||||
|
|
|
@ -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', [])
|
||||
},
|
||||
|
|
|
@ -9,6 +9,7 @@ export default class UserSettingsModel extends AbstractModel {
|
|||
discoverableByName: false,
|
||||
discoverableByEmail: false,
|
||||
overdueTasksRemindersEnabled: true,
|
||||
defaultListID: 1,
|
||||
weekStart: 0,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -132,6 +132,16 @@
|
|||
Play a sound when marking tasks as done
|
||||
</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="is-flex is-align-items-center">
|
||||
<span>
|
||||
Default list for new tasks is
|
||||
</span>
|
||||
<div class="ml-2">
|
||||
<list-search @selected="changeList" :listId="settings.defaultListID" ref="defaultList"/>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="is-flex is-align-items-center">
|
||||
<span>
|
||||
|
@ -262,6 +272,7 @@ import TotpModel from '../../models/totp'
|
|||
import TotpService from '../../services/totp'
|
||||
import UserSettingsService from '../../services/userSettings'
|
||||
import UserSettingsModel from '../../models/userSettings'
|
||||
import ListSearch from '../../components/tasks/partials/listSearch'
|
||||
import {playSoundWhenDoneKey} from '@/helpers/playPop'
|
||||
|
||||
import {mapState} from 'vuex'
|
||||
|
@ -295,6 +306,7 @@ export default {
|
|||
},
|
||||
components: {
|
||||
AvatarSettings,
|
||||
ListSearch,
|
||||
},
|
||||
created() {
|
||||
this.passwordUpdateService = new PasswordUpdateService()
|
||||
|
@ -420,6 +432,9 @@ export default {
|
|||
copy(text) {
|
||||
copy(text)
|
||||
},
|
||||
changeList(list) {
|
||||
this.settings.defaultListID = list.id
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue