Add a v-model prop to listSearch

This commit is contained in:
kolaente 2021-07-17 22:14:24 +02:00
parent 8a3fe5daa2
commit a0f1913645
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 19 additions and 11 deletions

View File

@ -32,6 +32,11 @@ export default {
foundLists: [],
}
},
props: {
value: {
required: false,
},
},
components: {
Multiselect,
},
@ -39,6 +44,14 @@ export default {
this.listSerivce = new ListService()
this.list = new ListModel()
},
watch: {
value(newVal) {
this.list = newVal
},
},
mounted() {
this.list = this.value
},
methods: {
findLists(query) {
if (query === '') {
@ -58,7 +71,9 @@ export default {
this.$set(this, 'foundLists', [])
},
select(list) {
this.list = list
this.$emit('selected', list)
this.$emit('input', list)
},
namespace(namespaceId) {
const namespace = this.$store.getters['namespaces/getNamespaceById'](namespaceId)

View File

@ -20,7 +20,7 @@
<label class="label">
{{ $t('user.settings.general.defaultList') }}
</label>
<list-search @selected="changeList"/>
<list-search v-model="defaultList"/>
</div>
<div class="field">
<label class="checkbox">
@ -281,7 +281,6 @@ import TotpModel from '../../models/totp'
import TotpService from '../../services/totp'
import UserSettingsService from '../../services/userSettings'
import UserSettingsModel from '../../models/userSettings'
import ListModel from '../../models/list'
import {playSoundWhenDoneKey} from '@/helpers/playPop'
import {availableLanguages, saveLanguage, getCurrentLanguage} from '@/i18n/setup'
@ -315,7 +314,7 @@ export default {
settings: UserSettingsModel,
userSettingsService: UserSettingsService,
defaultList: ListModel,
defaultList: null,
}
},
components: {
@ -337,10 +336,9 @@ export default {
this.playSoundWhenDone = localStorage.getItem(playSoundWhenDoneKey) === 'true' || localStorage.getItem(playSoundWhenDoneKey) === null
this.defaultList = null
this.defaultList = this.$store.getters['lists/getListById'](this.settings.defaultListId)
this.totpStatus()
this.getListById()
},
mounted() {
this.setTitle(this.$t('user.settings.title'))
@ -442,6 +440,7 @@ export default {
updateSettings() {
localStorage.setItem(playSoundWhenDoneKey, this.playSoundWhenDone)
saveLanguage(this.language)
this.settings.defaultListId = this.defaultList.id
this.userSettingsService.update(this.settings)
.then(() => {
@ -453,12 +452,6 @@ export default {
copy(text) {
copy(text)
},
changeList(list) {
this.settings.defaultListId = list.id
},
getListById() {
this.defaultList = this.$store.getters['lists/getListById'](this.settings.defaultListId)
},
},
}
</script>