fix: use vue3 v-model bindings

see: https://v3.vuejs.org/guide/migration/v-model.html
This commit is contained in:
Dominik Pschenitschni 2021-08-23 21:18:12 +02:00
parent 2ef2bb7700
commit 51a740f53c
No known key found for this signature in database
GPG Key ID: B257AC0149F43A77
29 changed files with 114 additions and 96 deletions

View File

@ -84,8 +84,8 @@
--> -->
<draggable <draggable
v-bind="dragOptions" v-bind="dragOptions"
:value="activeLists[nk]" :modelValue="activeLists[nk]"
@input="(lists) => updateActiveLists(n, lists)" @update:modelValue="(lists) => updateActiveLists(n, lists)"
:group="`namespace-${n.id}-lists`" :group="`namespace-${n.id}-lists`"
@start="() => drag = true" @start="() => drag = true"
@end="e => saveListPosition(e, nk)" @end="e => saveListPosition(e, nk)"

View File

@ -52,6 +52,7 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['click'],
computed: { computed: {
showIconOnly() { showIconOnly() {
return this.icon !== '' && typeof this.$slots.default === 'undefined' return this.icon !== '' && typeof this.$slots.default === 'undefined'

View File

@ -53,7 +53,7 @@ export default {
} }
}, },
props: { props: {
value: { modelValue: {
required: true, required: true,
}, },
menuPosition: { menuPosition: {
@ -61,10 +61,11 @@ export default {
default: 'top', default: 'top',
}, },
}, },
emits: ['update:modelValue', 'change'],
watch: { watch: {
value: { modelValue: {
handler(value) { handler(modelValue) {
this.color = value this.color = modelValue
}, },
immediate: true, immediate: true,
}, },
@ -89,7 +90,7 @@ export default {
} }
this.lastChangeTimeout = setTimeout(() => { this.lastChangeTimeout = setTimeout(() => {
this.$emit('input', this.color) this.$emit('update:modelValue', this.color)
this.$emit('change') this.$emit('change')
}, 500) }, 500)
}, },

View File

@ -136,7 +136,7 @@ export default {
flatPickr, flatPickr,
}, },
props: { props: {
value: { modelValue: {
validator: prop => prop instanceof Date || prop === null || typeof prop === 'string', validator: prop => prop instanceof Date || prop === null || typeof prop === 'string',
}, },
chooseDateLabel: { chooseDateLabel: {
@ -150,6 +150,7 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change', 'close', 'close-on-change'],
mounted() { mounted() {
document.addEventListener('click', this.hideDatePopup) document.addEventListener('click', this.hideDatePopup)
}, },
@ -157,7 +158,7 @@ export default {
document.removeEventListener('click', this.hideDatePopup) document.removeEventListener('click', this.hideDatePopup)
}, },
watch: { watch: {
value: { modelValue: {
handler: 'setDateValue', handler: 'setDateValue',
immediate: true, immediate: true,
}, },
@ -191,7 +192,7 @@ export default {
}, },
updateData() { updateData() {
this.changed = true this.changed = true
this.$emit('input', this.date) this.$emit('update:modelValue', this.date)
this.$emit('change', this.date) this.$emit('change', this.date)
}, },
toggleDatePopup() { toggleDatePopup() {

View File

@ -5,7 +5,7 @@
<vue-easymde <vue-easymde
:configs="config" :configs="config"
@change="bubble" @change="bubble"
@input="handleInput" @update:modelValue="handleInput"
class="content" class="content"
v-if="isEditActive" v-if="isEditActive"
v-model="text"/> v-model="text"/>
@ -61,7 +61,7 @@ export default {
VueEasymde, VueEasymde,
}, },
props: { props: {
value: { modelValue: {
type: String, type: String,
default: '', default: '',
}, },
@ -101,6 +101,7 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change'],
computed: { computed: {
showPreviewText() { showPreviewText() {
return this.isPreviewActive && this.text === '' && this.emptyText !== '' return this.isPreviewActive && this.text === '' && this.emptyText !== ''
@ -249,21 +250,21 @@ export default {
} }
}, },
watch: { watch: {
value(newVal) { modelValue(modelValue) {
this.text = newVal this.text = modelValue
this.$nextTick(this.renderPreview) this.$nextTick(this.renderPreview)
}, },
text(newVal, oldVal) { text(newVal, oldVal) {
// Only bubble the new value if it actually changed, but not if the component just got mounted and the text changed from the outside. // Only bubble the new value if it actually changed, but not if the component just got mounted and the text changed from the outside.
if (oldVal === '' && this.text === this.value) { if (oldVal === '' && this.text === this.modelValue) {
return return
} }
this.bubble() this.bubble()
}, },
}, },
mounted() { mounted() {
if (this.value !== '') { if (this.modelValue !== '') {
this.text = this.value this.text = this.modelValue
} }
if (this.previewIsDefault && this.hasPreview) { if (this.previewIsDefault && this.hasPreview) {
@ -296,7 +297,7 @@ export default {
} }
this.changeTimeout = setTimeout(() => { this.changeTimeout = setTimeout(() => {
this.$emit('input', this.text) this.$emit('update:modelValue',this.text)
this.$emit('change', this.text) this.$emit('change', this.text)
}, timeout) }, timeout)
}, },

View File

@ -30,7 +30,7 @@ export default {
} }
}, },
props: { props: {
value: { modelValue: {
required: false, required: false,
}, },
disabled: { disabled: {
@ -39,10 +39,11 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change'],
watch: { watch: {
value: { modelValue: {
handler(value) { handler(modelValue) {
this.checked = value this.checked = modelValue
}, },
immediate: true, immediate: true,
@ -51,7 +52,7 @@ export default {
methods: { methods: {
updateData(checked) { updateData(checked) {
this.checked = checked this.checked = checked
this.$emit('input', checked) this.$emit('update:modelValue', checked)
this.$emit('change', checked) this.$emit('change', checked)
}, },
}, },

View File

@ -83,14 +83,6 @@
<script> <script>
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside' import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
/**
* Available events:
* @search: Triggered every time the search query input changes
* @select: Triggered every time an option from the search results is selected. Also triggers a change in v-model.
* @create: If nothing or no exact match was found and `creatable` is true, this event is triggered with the current value of the search query.
* @remove: If `multiple` is enabled, this will be fired every time an item is removed from the array of selected items.
*/
export default { export default {
name: 'multiselect', name: 'multiselect',
data() { data() {
@ -133,7 +125,7 @@ export default {
}, },
}, },
// The object with the value, updated every time an entry is selected. // The object with the value, updated every time an entry is selected.
value: { modelValue: {
default() { default() {
return null return null
}, },
@ -188,6 +180,16 @@ export default {
}, },
}, },
}, },
/**
* Available events:
* @search: Triggered every time the search query input changes
* @select: Triggered every time an option from the search results is selected. Also triggers a change in v-model.
* @create: If nothing or no exact match was found and `creatable` is true, this event is triggered with the current value of the search query.
* @remove: If `multiple` is enabled, this will be fired every time an item is removed from the array of selected items.
*/
emits: ['update:modelValue', 'search', 'select', 'create', 'remove'],
mounted() { mounted() {
document.addEventListener('click', this.hideSearchResultsHandler) document.addEventListener('click', this.hideSearchResultsHandler)
}, },
@ -195,7 +197,7 @@ export default {
document.removeEventListener('click', this.hideSearchResultsHandler) document.removeEventListener('click', this.hideSearchResultsHandler)
}, },
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.setSelectedObject(value) this.setSelectedObject(value)
}, },
@ -278,7 +280,7 @@ export default {
this.internalValue = object this.internalValue = object
} }
this.$emit('input', this.internalValue) this.$emit('update:modelValue', this.internalValue)
this.$emit('select', object) this.$emit('select', object)
this.setSelectedObject(object) this.setSelectedObject(object)
this.closeSearchResults() this.closeSearchResults()
@ -352,7 +354,7 @@ export default {
} }
} }
this.$emit('input', this.internalValue) this.$emit('update:modelValue', this.internalValue)
this.$emit('remove', item) this.$emit('remove', item)
}, },
focus() { focus() {

View File

@ -15,6 +15,7 @@ import Filters from '../../../components/list/partials/filters'
export default { export default {
name: 'filter-popup', name: 'filter-popup',
emits: ['update:modelValue', 'change'],
data() { data() {
return { return {
params: null, params: null,
@ -31,7 +32,7 @@ export default {
document.removeEventListener('click', this.hidePopup) document.removeEventListener('click', this.hidePopup)
}, },
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.params = value this.params = value
}, },
@ -42,7 +43,7 @@ export default {
}, },
}, },
props: { props: {
value: { modelValue: {
required: true, required: true,
}, },
visible: { visible: {
@ -53,7 +54,7 @@ export default {
methods: { methods: {
change() { change() {
this.$emit('change', this.params) this.$emit('change', this.params)
this.$emit('input', this.params) this.$emit('update:modelValue', this.params)
}, },
hidePopup(e) { hidePopup(e) {
if (this.visibleInternal) { if (this.visibleInternal) {

View File

@ -254,12 +254,13 @@ export default {
this.filters.requireAllFilters = this.params.filter_concat === 'and' this.filters.requireAllFilters = this.params.filter_concat === 'and'
}, },
props: { props: {
value: { modelValue: {
required: true, required: true,
}, },
}, },
emits: ['update:modelValue', 'change'],
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.params = value this.params = value
this.prepareFilters() this.prepareFilters()
@ -293,7 +294,7 @@ export default {
}, },
methods: { methods: {
change() { change() {
this.$emit('input', this.params) this.$emit('update:modelValue', this.params)
this.$emit('change', this.params) this.$emit('change', this.params)
}, },
prepareFilters() { prepareFilters() {

View File

@ -60,6 +60,7 @@ export default {
successMsg: '', successMsg: '',
} }
}, },
emits: ['foundApi'],
created() { created() {
if (this.apiUrl === '') { if (this.apiUrl === '') {
this.configureApi = true this.configureApi = true

View File

@ -51,5 +51,6 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['close'],
} }
</script> </script>

View File

@ -77,6 +77,7 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['create', 'primary', 'tertary'],
methods: { methods: {
primary() { primary() {
this.$emit('create') this.$emit('create')

View File

@ -37,6 +37,7 @@ export default {
default: 'ellipsis-h', default: 'ellipsis-h',
}, },
}, },
emits: ['close'],
methods: { methods: {
hide(e) { hide(e) {
if (this.open) { if (this.open) {

View File

@ -49,6 +49,7 @@ export default {
default: true, default: true,
}, },
}, },
emits: ['change'],
computed: { computed: {
tooltipText() { tooltipText() {
if (this.disabled) { if (this.disabled) {

View File

@ -102,6 +102,7 @@ export default {
validator: validValue(VARIANTS), validator: validValue(VARIANTS),
}, },
}, },
emits: ['close', 'submit'],
} }
</script> </script>

View File

@ -14,6 +14,7 @@ import Multiselect from '@/components/input/multiselect.vue'
export default { export default {
name: 'namespace-search', name: 'namespace-search',
emits: ['selected'],
data() { data() {
return { return {
query: '', query: '',

View File

@ -49,6 +49,7 @@ const cleanupTitle = title => {
export default { export default {
name: 'add-task', name: 'add-task',
emits: ['taskAdded'],
data() { data() {
return { return {
newTaskTitle: '', newTaskTitle: '',

View File

@ -57,12 +57,14 @@ export default {
flatPickr, flatPickr,
}, },
props: { props: {
value: { modelValue: {
required: true, required: true,
}, },
}, },
emits: ['update:modelValue'],
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.task = value this.task = value
this.dueDate = value.dueDate this.dueDate = value.dueDate
@ -125,7 +127,7 @@ export default {
.then((r) => { .then((r) => {
this.lastValue = r.dueDate this.lastValue = r.dueDate
this.task = r this.task = r
this.$emit('input', r) this.$emit('update:modelValue', r)
}) })
.catch((e) => { .catch((e) => {
this.$message.error(e) this.$message.error(e)

View File

@ -57,7 +57,7 @@ export default {
loading: LOADING, loading: LOADING,
}), }),
props: { props: {
value: { modelValue: {
required: true, required: true,
}, },
attachmentUpload: { attachmentUpload: {
@ -67,8 +67,9 @@ export default {
required: true, required: true,
}, },
}, },
emits: ['update:modelValue'],
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.task = value this.task = value
}, },
@ -82,7 +83,7 @@ export default {
this.$store.dispatch('tasks/update', this.task) this.$store.dispatch('tasks/update', this.task)
.then(t => { .then(t => {
this.task = t this.task = t
this.$emit('input', t) this.$emit('update:modelValue', t)
this.saved = true this.saved = true
setTimeout(() => { setTimeout(() => {
this.saved = false this.saved = false

View File

@ -55,10 +55,11 @@ export default {
disabled: { disabled: {
default: false, default: false,
}, },
value: { modelValue: {
type: Array, type: Array,
}, },
}, },
emits: ['update:modelValue'],
data() { data() {
return { return {
newAssignee: new UserModel(), newAssignee: new UserModel(),
@ -69,7 +70,7 @@ export default {
} }
}, },
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.assignees = value this.assignees = value
}, },
@ -80,7 +81,7 @@ export default {
addAssignee(user) { addAssignee(user) {
this.$store.dispatch('tasks/addAssignee', {user: user, taskId: this.taskId}) this.$store.dispatch('tasks/addAssignee', {user: user, taskId: this.taskId})
.then(() => { .then(() => {
this.$emit('input', this.assignees) this.$emit('update:modelValue', this.assignees)
this.$message.success({message: this.$t('task.assignee.assignSuccess')}) this.$message.success({message: this.$t('task.assignee.assignSuccess')})
}) })
.catch(e => { .catch(e => {

View File

@ -49,7 +49,7 @@ import {LOADING, LOADING_MODULE} from '@/store/mutation-types'
export default { export default {
name: 'edit-labels', name: 'edit-labels',
props: { props: {
value: { modelValue: {
default: () => [], default: () => [],
type: Array, type: Array,
}, },
@ -62,6 +62,7 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change'],
data() { data() {
return { return {
labelTaskService: new LabelTaskService(), labelTaskService: new LabelTaskService(),
@ -74,7 +75,7 @@ export default {
Multiselect, Multiselect,
}, },
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.labels = value this.labels = value
}, },
@ -101,7 +102,7 @@ export default {
}, },
addLabel(label, showNotification = true) { addLabel(label, showNotification = true) {
const bubble = () => { const bubble = () => {
this.$emit('input', this.labels) this.$emit('update:modelValue', this.labels)
this.$emit('change', this.labels) this.$emit('change', this.labels)
} }
@ -128,7 +129,7 @@ export default {
this.labels.splice(l, 1) this.labels.splice(l, 1)
} }
} }
this.$emit('input', this.labels) this.$emit('update:modelValue', this.labels)
this.$emit('change', this.labels) this.$emit('change', this.labels)
} }

View File

@ -39,14 +39,14 @@ export default {
computed: { computed: {
...mapState(['loading']), ...mapState(['loading']),
task() { task() {
return this.value return this.modelValue
}, },
textIdentifier() { textIdentifier() {
return this.task?.getTextIdentifier() || '' return this.task?.getTextIdentifier() || ''
}, },
}, },
props: { props: {
value: { modelValue: {
required: true, required: true,
}, },
canWrite: { canWrite: {
@ -54,6 +54,9 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue'],
methods: { methods: {
save(title) { save(title) {
// We only want to save if the title was actually changed. // We only want to save if the title was actually changed.
@ -73,7 +76,7 @@ export default {
this.$store.dispatch('tasks/update', newTask) this.$store.dispatch('tasks/update', newTask)
.then((task) => { .then((task) => {
this.$emit('input', task) this.$emit('update:modelValue', task)
this.showSavedMessage = true this.showSavedMessage = true
setTimeout(() => { setTimeout(() => {
this.showSavedMessage = false this.showSavedMessage = false

View File

@ -32,15 +32,16 @@ export default {
} }
}, },
props: { props: {
value: { modelValue: {
required: false, required: false,
}, },
}, },
emits: ['update:modelValue', 'selected'],
components: { components: {
Multiselect, Multiselect,
}, },
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.list = value this.list = value
}, },
@ -68,7 +69,7 @@ export default {
select(list) { select(list) {
this.list = list this.list = list
this.$emit('selected', list) this.$emit('selected', list)
this.$emit('input', list) this.$emit('update:modelValue', list)
}, },
namespace(namespaceId) { namespace(namespaceId) {
const namespace = this.$store.getters['namespaces/getNamespaceById'](namespaceId) const namespace = this.$store.getters['namespaces/getNamespaceById'](namespaceId)

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="select"> <div class="select">
<select :disabled="disabled || null" @change="updateData" v-model.number="percentDone"> <select :disabled="disabled || null" v-model.number="percentDone">
<option value="0">0%</option> <option value="0">0%</option>
<option value="0.1">10%</option> <option value="0.1">10%</option>
<option value="0.2">20%</option> <option value="0.2">20%</option>
@ -19,13 +19,8 @@
<script> <script>
export default { export default {
name: 'percentDoneSelect', name: 'percentDoneSelect',
data() {
return {
percentDone: 0,
}
},
props: { props: {
value: { modelValue: {
default: 0, default: 0,
type: Number, type: Number,
}, },
@ -33,19 +28,16 @@ export default {
default: false, default: false,
}, },
}, },
watch: { emits: ['update:modelValue', 'change'],
// Set the priority to the :value every time it changes from the outside computed: {
value(newVal) { percentDone: {
this.percentDone = newVal get() {
}, return this.modelValue
}, },
mounted() { set(percentDone) {
this.percentDone = this.value this.$emit('update:modelValue', percentDone)
}, this.$emit('change')
methods: { },
updateData() {
this.$emit('input', this.percentDone)
this.$emit('change')
}, },
}, },
} }

View File

@ -23,7 +23,7 @@ export default {
} }
}, },
props: { props: {
value: { modelValue: {
default: 0, default: 0,
type: Number, type: Number,
}, },
@ -31,9 +31,10 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change'],
watch: { watch: {
// Set the priority to the :value every time it changes from the outside // Set the priority to the :value every time it changes from the outside
value: { modelValue: {
handler(value) { handler(value) {
this.priority = value this.priority = value
}, },
@ -42,7 +43,7 @@ export default {
}, },
methods: { methods: {
updateData() { updateData() {
this.$emit('input', this.priority) this.$emit('update:modelValue', this.priority)
this.$emit('change') this.$emit('change')
}, },
}, },

View File

@ -37,7 +37,7 @@ export default {
} }
}, },
props: { props: {
value: { modelValue: {
default: () => [], default: () => [],
validator: prop => { validator: prop => {
// This allows arrays of Dates and strings // This allows arrays of Dates and strings
@ -61,14 +61,15 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change'],
components: { components: {
datepicker, datepicker,
}, },
mounted() { mounted() {
this.reminders = this.value this.reminders = this.modelValue
}, },
watch: { watch: {
value(newVal) { modelValue(newVal) {
for (const i in newVal) { for (const i in newVal) {
if (typeof newVal[i] === 'string') { if (typeof newVal[i] === 'string') {
newVal[i] = new Date(newVal[i]) newVal[i] = new Date(newVal[i])
@ -79,7 +80,7 @@ export default {
}, },
methods: { methods: {
updateData() { updateData() {
this.$emit('input', this.reminders) this.$emit('update:modelValue', this.reminders)
this.$emit('change') this.$emit('change')
}, },
addReminderDate(index = null) { addReminderDate(index = null) {

View File

@ -66,7 +66,7 @@ export default {
} }
}, },
props: { props: {
value: { modelValue: {
default: () => {}, default: () => {},
required: true, required: true,
}, },
@ -74,8 +74,9 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change'],
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.task = value this.task = value
if (typeof value.repeatAfter !== 'undefined') { if (typeof value.repeatAfter !== 'undefined') {
@ -92,7 +93,7 @@ export default {
} }
this.task.repeatAfter = this.repeatAfter this.task.repeatAfter = this.repeatAfter
this.$emit('input', this.task) this.$emit('update:modelValue', this.task)
this.$emit('change') this.$emit('change')
}, },
setRepeatAfter(amount, type) { setRepeatAfter(amount, type) {

View File

@ -140,6 +140,7 @@ export default {
default: true, default: true,
}, },
}, },
emits: ['task-updated'],
watch: { watch: {
theTask(newVal) { theTask(newVal) {
this.task = newVal this.task = newVal

View File

@ -1,5 +1,5 @@
<template> <template>
<a @click="click"> <a @click="$emit('click')">
<icon icon="sort-up" v-if="order === 'asc'"/> <icon icon="sort-up" v-if="order === 'asc'"/>
<icon icon="sort-up" rotation="180" v-else-if="order === 'desc'"/> <icon icon="sort-up" rotation="180" v-else-if="order === 'desc'"/>
<icon icon="sort" v-else/> <icon icon="sort" v-else/>
@ -15,10 +15,6 @@ export default {
default: 'none', default: 'none',
}, },
}, },
methods: { emits: ['click'],
click() {
this.$emit('click')
},
},
} }
</script> </script>