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:
Sytone 2021-06-07 15:12:32 -07:00
parent b005d023c9
commit a9728f774d
5 changed files with 54 additions and 13 deletions

View File

@ -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: {

View File

@ -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', [])
},

View File

@ -9,6 +9,7 @@ export default class UserSettingsModel extends AbstractModel {
discoverableByName: false,
discoverableByEmail: false,
overdueTasksRemindersEnabled: true,
defaultListID: 1,
weekStart: 0,
}
}

View File

@ -3,6 +3,9 @@ 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
}

View File

@ -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>