1
0

fix: directly set arrays, objects and delete directly

Not needed since vue3 uses proxies
This commit is contained in:
Dominik Pschenitschni
2021-08-19 21:35:38 +02:00
parent 2b20f328cb
commit db49b9b532
33 changed files with 104 additions and 113 deletions

View File

@ -187,7 +187,7 @@ export default {
.then(namespaces => {
namespaces.forEach(n => {
if (typeof this.listsVisible[n.id] === 'undefined') {
this.$set(this.listsVisible, n.id, true)
this.listsVisible[n.id] = true
}
})
})
@ -217,7 +217,7 @@ export default {
}
},
toggleLists(namespaceId) {
this.$set(this.listsVisible, namespaceId, !this.listsVisible[namespaceId] ?? false)
this.listsVisible[namespaceId] = !this.listsVisible[namespaceId] ?? false
},
updateActiveLists(namespace, activeLists) {
// this is a bit hacky: since we do have to filter out the archived items from the list
@ -242,7 +242,7 @@ export default {
const list = listsActive[e.newIndex]
const listBefore = listsActive[e.newIndex - 1] ?? null
const listAfter = listsActive[e.newIndex + 1] ?? null
this.$set(this.listUpdating, list.id, true)
this.listUpdating[list.id] = true
const position = calculateItemPosition(listBefore !== null ? listBefore.position : null, listAfter !== null ? listAfter.position : null)
@ -255,7 +255,7 @@ export default {
this.$message.error(e)
})
.finally(() => {
this.$set(this.listUpdating, list.id, false)
this.listUpdating[list.id] = false
})
},
},

View File

@ -284,7 +284,7 @@ export default {
this.closeSearchResults()
},
setSelectedObject(object, resetOnly = false) {
this.$set(this, 'internalValue', object)
this.internalValue = object
// We assume we're getting an array when multiple is enabled and can therefore leave the query
// value etc as it is

View File

@ -344,11 +344,11 @@ export default {
this.params.filter_by.forEach((f, i) => {
if (f === filterName && this.params.filter_comparator[i] === 'greater_equals') {
foundStart = true
this.$set(this.params.filter_value, i, formatISO(new Date(parts[0])))
this.params.filter_value[i] = formatISO(new Date(parts[0]))
}
if (f === filterName && this.params.filter_comparator[i] === 'less_equals') {
foundEnd = true
this.$set(this.params.filter_value, i, formatISO(new Date(parts[1])))
this.params.filter_value[i] = formatISO(new Date(parts[1]))
}
})
@ -406,7 +406,7 @@ export default {
this.params.filter_by.forEach((f, i) => {
if (f === filterName) {
found = true
this.$set(this.params.filter_value, i, this.filters[variableName])
this.params.filter_value[i] = this.filters[variableName]
}
})
@ -466,7 +466,7 @@ export default {
}
})
if (foundDone === false) {
this.$set(this.filters, 'done', true)
this.filters.done = true
}
},
prepareRelatedObjectFilter(kind, filterName = null, servicePrefix = null) {
@ -482,7 +482,7 @@ export default {
if (typeof this.filters[filterName] !== 'undefined' && this.filters[filterName] !== '') {
this[`${servicePrefix}Service`].getAll({}, {s: this.filters[filterName]})
.then(r => {
this.$set(this, kind, r)
this[kind] = r
})
.catch(e => this.$message.error(e))
}
@ -523,7 +523,7 @@ export default {
this.setDateFilter('reminders')
},
clear(kind) {
this.$set(this, `found${kind}`, [])
this[`found${kind}`] = []
},
find(kind, query) {
@ -534,9 +534,9 @@ export default {
this[`${kind}Service`].getAll({}, {s: query})
.then(response => {
// Filter the results to not include users who are already assigneid
this.$set(this, `found${kind}`, differenceWith(response, this[kind], (first, second) => {
this[`found${kind}`] = differenceWith(response, this[kind], (first, second) => {
return first.id === second.id
}))
})
})
.catch(e => {
this.$message.error(e)
@ -564,7 +564,7 @@ export default {
ids.push(u.id)
})
this.$set(this.filters, filterName, ids.join(','))
this.filters[filterName] = ids.join(',')
this.setSingleValueFilter(filterName, filterName, '', 'in')
},
findLabels(query) {
@ -599,7 +599,7 @@ export default {
labelIDs.push(u.id)
})
this.$set(this.filters, 'labels', labelIDs.join(','))
this.filters.labels = labelIDs.join(',')
this.setSingleValueFilter('labels', 'labels', '', 'in')
},
},

View File

@ -66,7 +66,7 @@ export default {
const listService = new ListService()
listService.background(this.list)
.then(b => {
this.$set(this, 'background', b)
this.background = b
})
.catch(e => {
this.$message.error(e)

View File

@ -96,7 +96,7 @@ export default {
loadNotifications() {
this.notificationService.getAll()
.then(r => {
this.$set(this, 'allNotifications', r)
this.allNotifications = r
})
.catch(e => {
this.$message.error(e)
@ -135,7 +135,7 @@ export default {
n.read = true
this.notificationService.update(n)
.then(r => {
this.$set(this.allNotifications, index, r)
this.allNotifications[index] = r
})
.catch(e => this.$message.error(e))
}

View File

@ -298,7 +298,7 @@ export default {
return t
})
this.$set(this, 'foundTasks', r)
this.foundTasks = r
})
}, 150)
},
@ -329,7 +329,7 @@ export default {
t.title = t.name
return t
})
this.$set(this, 'foundTeams', r)
this.foundTeams = r
})
}, 150)
},

View File

@ -276,9 +276,9 @@ export default {
this.stuffService
.getAll(this.stuffModel)
.then((r) => {
this.$set(this, 'sharables', r)
this.sharables = r
r.forEach((s) =>
this.$set(this.selectedRight, s.id, s.right),
this.selectedRight[s.id] = s.right,
)
})
.catch((e) => {
@ -362,7 +362,7 @@ export default {
(this.sharables[i].id === this.stuffModel.teamId &&
this.shareType === 'team')
) {
this.$set(this.sharables[i], 'right', r.right)
this.sharables[i].right = r.right
}
}
this.$message.success({message: this.$t('list.share.userTeam.updatedSuccess', {type: this.shareTypeName})})
@ -373,21 +373,21 @@ export default {
},
find(query) {
if (query === '') {
this.$set(this, 'found', [])
this.clearAll()
return
}
this.searchService
.getAll({}, {s: query})
.then((response) => {
this.$set(this, 'found', response)
this.found = response
})
.catch((e) => {
this.$message.error(e)
})
},
clearAll() {
this.$set(this, 'found', [])
this.found = []
},
},
}

View File

@ -143,7 +143,7 @@ export default {
this.taskService
.update(this.taskEditTask)
.then((r) => {
this.$set(this, 'taskEditTask', r)
this.taskEditTask = r
this.initTaskFields()
this.$message.success({message: this.$t('task.detail.updateSuccess')})
})

View File

@ -299,15 +299,15 @@ export default {
this.fullWidth += this.dayWidth
}
console.debug('prepareGanttDays; years:', years)
this.$set(this, 'days', years)
this.days = years
},
parseTasks() {
this.setDates()
this.loadTasks()
},
loadTasks() {
this.$set(this, 'theTasks', [])
this.$set(this, 'tasksWithoutDates', [])
this.theTasks = []
this.tasksWithoutDates = []
const getAllTasks = (page = 1) => {
return this.taskCollectionService
@ -392,7 +392,7 @@ export default {
// prevent it from containing outdated Data in the first place.
for (const tt in this.theTasks) {
if (this.theTasks[tt].id === this.taskDragged.id) {
this.$set(this, 'taskDragged', this.theTasks[tt])
this.taskDragged = this.theTasks[tt]
break
}
}
@ -422,11 +422,7 @@ export default {
} else {
for (const tt in this.theTasks) {
if (this.theTasks[tt].id === r.id) {
this.$set(
this.theTasks,
tt,
this.addGantAttributes(r),
)
this.theTasks[tt] = this.addGantAttributes(r)
break
}
}

View File

@ -229,7 +229,7 @@ export default {
this.taskCommentService
.getAll({taskId: this.taskId})
.then(r => {
this.$set(this, 'comments', r)
this.comments = r
this.makeActions()
})
.catch((e) => {
@ -286,7 +286,7 @@ export default {
.then((r) => {
for (const c in this.comments) {
if (this.comments[c].id === this.commentEdit.id) {
this.$set(this.comments, c, r)
this.comments[c] = r
}
}
this.saved = this.commentEdit.id
@ -322,12 +322,12 @@ export default {
makeActions() {
if (this.canWrite) {
this.comments.forEach((c) => {
this.$set(this.actions, c.id, [
this.actions[c.id] = [
{
action: () => this.toggleDelete(c.id),
title: this.$t('misc.delete'),
},
])
]
})
}
},

View File

@ -111,16 +111,16 @@ export default {
this.listUserService.getAll({listId: this.listId}, {s: query})
.then(response => {
// Filter the results to not include users who are already assigned
this.$set(this, 'foundUsers', differenceWith(response, this.assignees, (first, second) => {
this.foundUsers = differenceWith(response, this.assignees, (first, second) => {
return first.id === second.id
}))
})
})
.catch(e => {
this.$message.error(e)
})
},
clearAllFoundUsers() {
this.$set(this, 'foundUsers', [])
this.foundUsers = []
},
focus() {
this.$refs.multiselect.focus()

View File

@ -56,14 +56,14 @@ export default {
this.listSerivce.getAll({}, {s: query})
.then(response => {
this.$set(this, 'foundLists', response)
this.foundLists = response
})
.catch(e => {
this.$message.error(e)
})
},
clearAll() {
this.$set(this, 'foundLists', [])
this.foundLists = []
},
select(list) {
this.list = list

View File

@ -188,7 +188,7 @@ export default {
findTasks(query) {
this.taskService.getAll({}, {s: query})
.then(response => {
this.$set(this, 'foundTasks', response)
this.foundTasks = response
})
.catch(e => {
this.$message.error(e)
@ -203,7 +203,7 @@ export default {
this.taskRelationService.create(rel)
.then(() => {
if (!this.relatedTasks[this.newTaskRelationKind]) {
this.$set(this.relatedTasks, this.newTaskRelationKind, [])
this.relatedTasks[this.newTaskRelationKind] = []
}
this.relatedTasks[this.newTaskRelationKind].push(this.newTaskRelationTask)
this.newTaskRelationTask = null