feat: move from life cycle to data or watcher

- remove from created / mounted
- initialize component services in data
- use immediate watcher where appropriate
- deep watch for route changes
This commit is contained in:
Dominik Pschenitschni 2021-09-08 11:59:38 +02:00 committed by kolaente
parent ebeca48be4
commit f51371bbe0
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
59 changed files with 246 additions and 376 deletions

View file

@ -49,7 +49,10 @@ export default {
name: 'contentAuth', name: 'contentAuth',
components: {QuickActions, Navigation}, components: {QuickActions, Navigation},
watch: { watch: {
'$route': 'doStuffAfterRoute', '$route': {
handler: 'doStuffAfterRoute',
deep: true,
},
}, },
created() { created() {
this.renewTokenOnFocus() this.renewTokenOnFocus()

View file

@ -48,16 +48,16 @@ export default {
}, },
}, },
watch: { watch: {
value(newVal) { value: {
this.color = newVal handler(value) {
this.color = value
},
immediate: true,
}, },
color() { color() {
this.update() this.update()
}, },
}, },
mounted() {
this.color = this.value
},
computed: { computed: {
empty() { empty() {
return this.color === '#000000' || this.color === '' return this.color === '#000000' || this.color === ''

View file

@ -151,15 +151,15 @@ export default {
}, },
}, },
mounted() { mounted() {
this.setDateValue(this.value)
document.addEventListener('click', this.hideDatePopup) document.addEventListener('click', this.hideDatePopup)
}, },
beforeDestroy() { beforeDestroy() {
document.removeEventListener('click', this.hideDatePopup) document.removeEventListener('click', this.hideDatePopup)
}, },
watch: { watch: {
value(newVal) { value: {
this.setDateValue(newVal) handler: 'setDateValue',
immediate: true,
}, },
flatPickrDate(newVal) { flatPickrDate(newVal) {
this.date = createDateFromString(newVal) this.date = createDateFromString(newVal)

View file

@ -26,7 +26,7 @@ export default {
data() { data() {
return { return {
checked: false, checked: false,
checkBoxId: '', checkBoxId: 'fancycheckbox' + Math.random(),
} }
}, },
props: { props: {
@ -40,15 +40,13 @@ export default {
}, },
}, },
watch: { watch: {
value(newVal) { value: {
this.checked = newVal handler(value) {
this.checked = value
}, },
immediate: true,
}, },
mounted() {
this.checked = this.value
},
created() {
this.checkBoxId = 'fancycheckbox' + Math.random()
}, },
methods: { methods: {
updateData(checked) { updateData(checked) {

View file

@ -190,14 +190,16 @@ export default {
}, },
mounted() { mounted() {
document.addEventListener('click', this.hideSearchResultsHandler) document.addEventListener('click', this.hideSearchResultsHandler)
this.setSelectedObject(this.value)
}, },
beforeDestroy() { beforeDestroy() {
document.removeEventListener('click', this.hideSearchResultsHandler) document.removeEventListener('click', this.hideSearchResultsHandler)
}, },
watch: { watch: {
value(newVal) { value: {
this.setSelectedObject(newVal) handler(value) {
this.setSelectedObject(value)
},
immediate: true,
}, },
}, },
computed: { computed: {

View file

@ -25,15 +25,17 @@ export default {
Filters, Filters,
}, },
mounted() { mounted() {
this.params = this.value
document.addEventListener('click', this.hidePopup) document.addEventListener('click', this.hidePopup)
}, },
beforeDestroy() { beforeDestroy() {
document.removeEventListener('click', this.hidePopup) document.removeEventListener('click', this.hidePopup)
}, },
watch: { watch: {
value(newVal) { value: {
this.$set(this, 'params', newVal) handler(value) {
this.params = value
},
immediate: true,
}, },
visible() { visible() {
this.visibleInternal = !this.visibleInternal this.visibleInternal = !this.visibleInternal

View file

@ -234,31 +234,24 @@ export default {
params: DEFAULT_PARAMS, params: DEFAULT_PARAMS,
filters: DEFAULT_FILTERS, filters: DEFAULT_FILTERS,
usersService: UserService, usersService: new UserService(),
foundusers: [], foundusers: [],
users: [], users: [],
labelQuery: '', labelQuery: '',
labels: [], labels: [],
listsService: ListService, listsService: new ListService(),
foundlists: [], foundlists: [],
lists: [], lists: [],
namespaceService: NamespaceService, namespaceService: new NamespaceService(),
foundnamespace: [], foundnamespace: [],
namespace: [], namespace: [],
} }
}, },
created() {
this.usersService = new UserService()
this.listsService = new ListService()
this.namespaceService = new NamespaceService()
},
mounted() { mounted() {
this.params = this.value
this.filters.requireAllFilters = this.params.filter_concat === 'and' this.filters.requireAllFilters = this.params.filter_concat === 'and'
this.prepareFilters()
}, },
props: { props: {
value: { value: {
@ -266,10 +259,13 @@ export default {
}, },
}, },
watch: { watch: {
value(newVal) { value: {
this.$set(this, 'params', newVal) handler(value) {
this.params = value
this.prepareFilters() this.prepareFilters()
}, },
immediate: true,
},
}, },
computed: { computed: {
foundLabels() { foundLabels() {

View file

@ -50,13 +50,11 @@ export default {
}, },
}, },
watch: { watch: {
list() { list: {
this.loadBackground() handler: 'loadBackground',
immediate: true,
}, },
}, },
created() {
this.loadBackground()
},
methods: { methods: {
loadBackground() { loadBackground() {
if (this.list === null || !this.list.backgroundInformation || this.backgroundLoading) { if (this.list === null || !this.list.backgroundInformation || this.backgroundLoading) {

View file

@ -30,7 +30,7 @@ export default {
name: 'task-subscription', name: 'task-subscription',
data() { data() {
return { return {
subscriptionService: SubscriptionService, subscriptionService: new SubscriptionService(),
} }
}, },
props: { props: {
@ -49,9 +49,6 @@ export default {
default: true, default: true,
}, },
}, },
created() {
this.subscriptionService = new SubscriptionService()
},
computed: { computed: {
tooltipText() { tooltipText() {
if (this.disabled) { if (this.disabled) {

View file

@ -61,15 +61,12 @@ export default {
components: {User}, components: {User},
data() { data() {
return { return {
notificationService: NotificationService, notificationService: new NotificationService(),
allNotifications: [], allNotifications: [],
showNotifications: false, showNotifications: false,
interval: null, interval: null,
} }
}, },
created() {
this.notificationService = new NotificationService()
},
mounted() { mounted() {
this.loadNotifications() this.loadNotifications()
document.addEventListener('click', this.hidePopup) document.addEventListener('click', this.hidePopup)

View file

@ -90,11 +90,11 @@ export default {
foundTasks: [], foundTasks: [],
taskSearchTimeout: null, taskSearchTimeout: null,
taskService: null, taskService: new TaskService(),
foundTeams: [], foundTeams: [],
teamSearchTimeout: null, teamSearchTimeout: null,
teamService: null, teamService: new TeamService(),
} }
}, },
mixins: [ mixins: [
@ -261,10 +261,6 @@ export default {
return this.selectedCmd !== null && this.selectedCmd.action === CMD_NEW_TASK return this.selectedCmd !== null && this.selectedCmd.action === CMD_NEW_TASK
}, },
}, },
created() {
this.taskService = new TaskService()
this.teamService = new TeamService()
},
methods: { methods: {
search() { search() {
this.searchTasks() this.searchTasks()

View file

@ -195,7 +195,7 @@ export default {
data() { data() {
return { return {
linkShares: [], linkShares: [],
linkShareService: LinkShareService, linkShareService: new LinkShareService(),
rights: rights, rights: rights,
selectedRight: rights.READ, selectedRight: rights.READ,
name: '', name: '',
@ -205,17 +205,10 @@ export default {
showNewForm: false, showNewForm: false,
} }
}, },
beforeMount() {
this.linkShareService = new LinkShareService()
},
created() {
this.linkShareService = new LinkShareService()
this.load()
},
watch: { watch: {
listId() { listId: {
// watch it handler: 'load',
this.load() immediate: true,
}, },
}, },
computed: mapState({ computed: mapState({

View file

@ -45,7 +45,7 @@ export default {
data() { data() {
return { return {
newTaskTitle: '', newTaskTitle: '',
taskService: TaskService, taskService: new TaskService(),
errorMessage: '', errorMessage: '',
} }
}, },
@ -55,9 +55,6 @@ export default {
components: { components: {
QuickAddMagic, QuickAddMagic,
}, },
created() {
this.taskService = new TaskService()
},
props: { props: {
defaultPosition: { defaultPosition: {
type: Number, type: Number,

View file

@ -84,13 +84,13 @@ export default {
data() { data() {
return { return {
listId: this.$route.params.id, listId: this.$route.params.id,
listService: ListService, listService: new ListService(),
taskService: TaskService, taskService: new TaskService(),
priorities: priorities, priorities: priorities,
list: {}, list: {},
editorActive: false, editorActive: false,
newTask: TaskModel, newTask: new TaskModel(),
isTaskEdit: false, isTaskEdit: false,
taskEditTask: TaskModel, taskEditTask: TaskModel,
} }
@ -113,17 +113,13 @@ export default {
}, },
}, },
watch: { watch: {
task() { task: {
handler() {
this.taskEditTask = this.task this.taskEditTask = this.task
this.initTaskFields() this.initTaskFields()
}, },
immediate: true,
}, },
created() {
this.listService = new ListService()
this.taskService = new TaskService()
this.newTask = new TaskModel()
this.taskEditTask = this.task
this.initTaskFields()
}, },
methods: { methods: {
initTaskFields() { initTaskFields() {

View file

@ -232,17 +232,17 @@ export default {
endDate: null, endDate: null,
theTasks: [], // Pretty much a copy of the prop, since we cant mutate the prop directly theTasks: [], // Pretty much a copy of the prop, since we cant mutate the prop directly
tasksWithoutDates: [], tasksWithoutDates: [],
taskService: TaskService, taskService: new TaskService(),
taskDragged: null, // Saves to currently dragged task to be able to update it taskDragged: null, // Saves to currently dragged task to be able to update it
fullWidth: 0, fullWidth: 0,
now: null, now: new Date(),
dayOffsetUntilToday: 0, dayOffsetUntilToday: 0,
isTaskEdit: false, isTaskEdit: false,
taskToEdit: null, taskToEdit: null,
newTaskTitle: '', newTaskTitle: '',
newTaskFieldActive: false, newTaskFieldActive: false,
priorities: {}, priorities: priorities,
taskCollectionService: TaskCollectionService, taskCollectionService: new TaskCollectionService(),
showTaskFilter: false, showTaskFilter: false,
params: { params: {
@ -260,12 +260,6 @@ export default {
dateTo: 'buildTheGanttChart', dateTo: 'buildTheGanttChart',
listId: 'parseTasks', listId: 'parseTasks',
}, },
created() {
this.now = new Date()
this.taskCollectionService = new TaskCollectionService()
this.taskService = new TaskService()
this.priorities = priorities
},
mounted() { mounted() {
this.buildTheGanttChart() this.buildTheGanttChart()
}, },

View file

@ -151,7 +151,7 @@ export default {
}, },
data() { data() {
return { return {
attachmentService: AttachmentService, attachmentService: new AttachmentService(),
showDropzone: false, showDropzone: false,
showDeleteModal: false, showDeleteModal: false,
@ -173,9 +173,6 @@ export default {
default: true, default: true,
}, },
}, },
created() {
this.attachmentService = new AttachmentService()
},
computed: mapState({ computed: mapState({
attachments: (state) => state.attachments.attachments, attachments: (state) => state.attachments.attachments,
}), }),

View file

@ -180,13 +180,13 @@ export default {
comments: [], comments: [],
showDeleteModal: false, showDeleteModal: false,
commentToDelete: TaskCommentModel, commentToDelete: new TaskCommentModel(),
isCommentEdit: false, isCommentEdit: false,
commentEdit: TaskCommentModel, commentEdit: new TaskCommentModel(),
taskCommentService: TaskCommentService, taskCommentService: new TaskCommentService(),
newComment: TaskCommentModel, newComment: new TaskCommentModel(),
editorActive: true, editorActive: true,
actions: {}, actions: {},
@ -195,22 +195,15 @@ export default {
creating: false, creating: false,
} }
}, },
created() {
this.taskCommentService = new TaskCommentService()
this.newComment = new TaskCommentModel({taskId: this.taskId})
this.commentEdit = new TaskCommentModel({taskId: this.taskId})
this.commentToDelete = new TaskCommentModel({taskId: this.taskId})
this.comments = []
},
mounted() {
this.loadComments()
},
watch: { watch: {
taskId() { taskId: {
handler(taskId) {
this.loadComments() this.loadComments()
this.newComment.taskId = this.taskId this.newComment.taskId = taskId
this.commentEdit.taskId = this.taskId this.commentEdit.taskId = taskId
this.commentToDelete.taskId = this.taskId this.commentToDelete.taskId = taskId
},
immediate: true,
}, },
canWrite() { canWrite() {
this.makeActions() this.makeActions()

View file

@ -45,7 +45,7 @@ export default {
name: 'defer-task', name: 'defer-task',
data() { data() {
return { return {
taskService: TaskService, taskService: new TaskService(),
task: null, task: null,
// We're saving the due date seperately to prevent null errors in very short periods where the task is null. // We're saving the due date seperately to prevent null errors in very short periods where the task is null.
dueDate: null, dueDate: null,
@ -61,14 +61,17 @@ export default {
required: true, required: true,
}, },
}, },
created() { watch: {
this.taskService = new TaskService() value: {
handler(value) {
this.task = value
this.dueDate = value.dueDate
this.lastValue = value.dueDate
},
immediate: true,
},
}, },
mounted() { mounted() {
this.task = this.value
this.dueDate = this.task.dueDate
this.lastValue = this.dueDate
// Because we don't really have other ways of handling change since if we let flatpickr // Because we don't really have other ways of handling change since if we let flatpickr
// change events trigger updates, it would trigger a flatpickr change event which would trigger // change events trigger updates, it would trigger a flatpickr change event which would trigger
// an update which would trigger a change event and so on... // an update which would trigger a change event and so on...
@ -86,13 +89,6 @@ export default {
} }
this.updateDueDate() this.updateDueDate()
}, },
watch: {
value(newVal) {
this.task = newVal
this.dueDate = this.task.dueDate
this.lastValue = this.dueDate
},
},
computed: { computed: {
flatPickerConfig() { flatPickerConfig() {
return { return {

View file

@ -68,12 +68,12 @@ export default {
}, },
}, },
watch: { watch: {
value(newVal) { value: {
this.task = newVal handler(value) {
this.task = value
}, },
immediate: true,
}, },
mounted() {
this.task = this.value
}, },
methods: { methods: {
save() { save() {

View file

@ -61,22 +61,19 @@ export default {
}, },
data() { data() {
return { return {
newAssignee: UserModel, newAssignee: new UserModel(),
listUserService: ListUserService, listUserService: new ListUserService(),
foundUsers: [], foundUsers: [],
assignees: [], assignees: [],
taskAssigneeService: TaskAssigneeService, taskAssigneeService: new TaskAssigneeService(),
} }
}, },
created() {
this.assignees = this.value
this.listUserService = new ListUserService()
this.newAssignee = new UserModel()
this.taskAssigneeService = new TaskAssigneeService()
},
watch: { watch: {
value(newVal) { value: {
this.assignees = newVal handler(value) {
this.assignees = value
},
immediate: true,
}, },
}, },
methods: { methods: {

View file

@ -64,7 +64,7 @@ export default {
}, },
data() { data() {
return { return {
labelTaskService: LabelTaskService, labelTaskService: new LabelTaskService(),
labelTimeout: null, labelTimeout: null,
labels: [], labels: [],
query: '', query: '',
@ -74,13 +74,12 @@ export default {
Multiselect, Multiselect,
}, },
watch: { watch: {
value(newLabels) { value: {
this.labels = newLabels handler(value) {
this.labels = value
}, },
immediate: true,
}, },
created() {
this.labelTaskService = new LabelTaskService()
this.labels = this.value
}, },
computed: { computed: {
foundLabels() { foundLabels() {

View file

@ -9,7 +9,6 @@
@keydown.enter.prevent.stop="$event.target.blur()" @keydown.enter.prevent.stop="$event.target.blur()"
:contenteditable="canWrite ? 'true' : 'false'" :contenteditable="canWrite ? 'true' : 'false'"
spellcheck="false" spellcheck="false"
ref="taskTitle"
> >
{{ task.title.trim() }} {{ task.title.trim() }}
</h1> </h1>

View file

@ -26,8 +26,8 @@ export default {
name: 'listSearch', name: 'listSearch',
data() { data() {
return { return {
listSerivce: ListService, listSerivce: new ListService(),
list: ListModel, list: new ListModel(),
foundLists: [], foundLists: [],
} }
}, },
@ -39,17 +39,13 @@ export default {
components: { components: {
Multiselect, Multiselect,
}, },
beforeMount() {
this.listSerivce = new ListService()
this.list = new ListModel()
},
watch: { watch: {
value(newVal) { value: {
this.list = newVal handler(value) {
this.list = value
}, },
immeditate: true,
}, },
mounted() {
this.list = this.value
}, },
methods: { methods: {
findLists(query) { findLists(query) {

View file

@ -33,12 +33,12 @@ export default {
}, },
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(newVal) { value: {
this.priority = newVal handler(value) {
this.priority = value
}, },
immediate: true,
}, },
mounted() {
this.priority = this.value
}, },
methods: { methods: {
updateData() { updateData() {

View file

@ -134,12 +134,12 @@ export default {
data() { data() {
return { return {
relatedTasks: {}, relatedTasks: {},
taskService: TaskService, taskService: new TaskService(),
foundTasks: [], foundTasks: [],
relationKinds: relationKinds, relationKinds: relationKinds,
newTaskRelationTask: TaskModel, newTaskRelationTask: new TaskModel(),
newTaskRelationKind: 'related', newTaskRelationKind: 'related',
taskRelationService: TaskRelationService, taskRelationService: new TaskRelationService(),
showDeleteModal: false, showDeleteModal: false,
relationToDelete: {}, relationToDelete: {},
saved: false, saved: false,
@ -171,18 +171,13 @@ export default {
default: true, default: true,
}, },
}, },
created() {
this.taskService = new TaskService()
this.taskRelationService = new TaskRelationService()
this.newTaskRelationTask = new TaskModel()
},
watch: { watch: {
initialRelatedTasks(newVal) { initialRelatedTasks: {
this.relatedTasks = newVal handler(value) {
this.relatedTasks = value
}, },
immediate: true,
}, },
mounted() {
this.relatedTasks = this.initialRelatedTasks
}, },
computed: { computed: {
showCreate() { showCreate() {

View file

@ -75,18 +75,15 @@ export default {
}, },
}, },
watch: { watch: {
value(newVal) { value: {
this.task = newVal handler(value) {
if (typeof newVal.repeatAfter !== 'undefined') { this.task = value
this.repeatAfter = newVal.repeatAfter if (typeof value.repeatAfter !== 'undefined') {
this.repeatAfter = value.repeatAfter
} }
}, },
immediate: true,
}, },
mounted() {
this.task = this.value
if (typeof this.value.repeatAfter !== 'undefined') {
this.repeatAfter = this.value.repeatAfter
}
}, },
methods: { methods: {
updateData() { updateData() {

View file

@ -99,8 +99,8 @@ export default {
name: 'singleTaskInList', name: 'singleTaskInList',
data() { data() {
return { return {
taskService: TaskService, taskService: new TaskService(),
task: TaskModel, task: new TaskModel(),
showDefer: false, showDefer: false,
} }
}, },
@ -146,10 +146,6 @@ export default {
this.task = this.theTask this.task = this.theTask
document.addEventListener('click', this.hideDeferDueDatePopup) document.addEventListener('click', this.hideDeferDueDatePopup)
}, },
created() {
this.task = new TaskModel()
this.taskService = new TaskService()
},
beforeDestroy() { beforeDestroy() {
document.removeEventListener('click', this.hideDeferDueDatePopup) document.removeEventListener('click', this.hideDeferDueDatePopup)
}, },

View file

@ -74,14 +74,13 @@ export default {
data() { data() {
return { return {
avatarProvider: '', avatarProvider: '',
avatarService: AvatarService, avatarService: new AvatarService(),
isCropAvatar: false, isCropAvatar: false,
avatarToCrop: null, avatarToCrop: null,
loading: false, // Seperate variable because some things we're doing in browser take a bit loading: false, // Seperate variable because some things we're doing in browser take a bit
} }
}, },
created() { created() {
this.avatarService = new AvatarService()
this.avatarStatus() this.avatarStatus()
}, },
components: { components: {

View file

@ -91,14 +91,11 @@ export default {
name: 'user-settings-deletion', name: 'user-settings-deletion',
data() { data() {
return { return {
accountDeleteService: AccountDeleteService, accountDeleteService: new AccountDeleteService(),
password: '', password: '',
errPasswordRequired: false, errPasswordRequired: false,
} }
}, },
created() {
this.accountDeleteService = new AccountDeleteService()
},
computed: mapState({ computed: mapState({
userDeletionEnabled: state => state.config.userDeletionEnabled, userDeletionEnabled: state => state.config.userDeletionEnabled,
deletionScheduledAt: state => parseDateOrNull(state.auth.info.deletionScheduledAt), deletionScheduledAt: state => parseDateOrNull(state.auth.info.deletionScheduledAt),

View file

@ -80,8 +80,8 @@ export default {
filter_concat: 'and', filter_concat: 'and',
filter_include_nulls: true, filter_include_nulls: true,
}, },
savedFilterService: SavedFilterService, savedFilterService: new SavedFilterService(),
savedFilter: SavedFilterModel, savedFilter: new SavedFilterModel(),
} }
}, },
components: { components: {
@ -96,9 +96,6 @@ export default {
created() { created() {
this.editorActive = false this.editorActive = false
this.$nextTick(() => this.editorActive = true) this.$nextTick(() => this.editorActive = true)
this.savedFilterService = new SavedFilterService()
this.savedFilter = new SavedFilterModel()
}, },
methods: { methods: {
create() { create() {

View file

@ -20,12 +20,9 @@ export default {
name: 'filter-settings-delete', name: 'filter-settings-delete',
data() { data() {
return { return {
filterService: SavedFilterService, filterService: new SavedFilterService(),
} }
}, },
created() {
this.filterService = new SavedFilterService()
},
methods: { methods: {
deleteSavedFilter() { deleteSavedFilter() {
// We assume the listId in the route is the pseudolist // We assume the listId in the route is the pseudolist

View file

@ -67,7 +67,7 @@ export default {
data() { data() {
return { return {
filter: SavedFilterModel, filter: SavedFilterModel,
filterService: SavedFilterService, filterService: new SavedFilterService(),
filters: { filters: {
sort_by: ['done', 'id'], sort_by: ['done', 'id'],
order_by: ['asc', 'desc'], order_by: ['asc', 'desc'],
@ -91,13 +91,13 @@ export default {
timeout: 60000, timeout: 60000,
}), }),
}, },
created() {
this.filterService = new SavedFilterService()
this.loadSavedFilter()
},
watch: { watch: {
// call again the method if the route changes // call again the method if the route changes
'$route': 'loadSavedFilter', '$route': {
handler: 'loadSavedFilter',
deep: true,
immediate: true,
},
}, },
methods: { methods: {
loadSavedFilter() { loadSavedFilter() {

View file

@ -118,13 +118,12 @@ export default {
}, },
data() { data() {
return { return {
labelEditLabel: LabelModel, labelEditLabel: new LabelModel(),
isLabelEdit: false, isLabelEdit: false,
editorActive: false, editorActive: false,
} }
}, },
created() { created() {
this.labelEditLabel = new LabelModel()
this.loadLabels() this.loadLabels()
}, },
mounted() { mounted() {

View file

@ -35,7 +35,6 @@
</template> </template>
<script> <script>
import labelModel from '../../models/label'
import LabelModel from '../../models/label' import LabelModel from '../../models/label'
import CreateEdit from '@/components/misc/create-edit.vue' import CreateEdit from '@/components/misc/create-edit.vue'
import ColorPicker from '../../components/input/colorPicker' import ColorPicker from '../../components/input/colorPicker'
@ -46,7 +45,7 @@ export default {
name: 'NewLabel', name: 'NewLabel',
data() { data() {
return { return {
label: labelModel, label: new LabelModel(),
showError: false, showError: false,
} }
}, },
@ -54,9 +53,6 @@ export default {
CreateEdit, CreateEdit,
ColorPicker, ColorPicker,
}, },
created() {
this.label = new LabelModel()
},
mounted() { mounted() {
this.setTitle(this.$t('label.create.title')) this.setTitle(this.$t('label.create.title'))
}, },

View file

@ -42,18 +42,14 @@ export default {
data() { data() {
return { return {
showError: false, showError: false,
list: ListModel, list: new ListModel(),
listService: ListService, listService: new ListService(),
} }
}, },
components: { components: {
CreateEdit, CreateEdit,
ColorPicker, ColorPicker,
}, },
created() {
this.list = new ListModel()
this.listService = new ListService()
},
mounted() { mounted() {
this.setTitle(this.$t('list.create.header')) this.setTitle(this.$t('list.create.header'))
}, },

View file

@ -47,21 +47,20 @@ import {saveListToHistory} from '../../modules/listHistory'
export default { export default {
data() { data() {
return { return {
listService: ListService, listService: new ListService(),
list: ListModel, list: new ListModel(),
listLoaded: 0, listLoaded: 0,
} }
}, },
created() {
this.listService = new ListService()
this.list = new ListModel()
},
mounted() { mounted() {
this.loadList() this.loadList()
}, },
watch: { watch: {
// call again the method if the route changes // call again the method if the route changes
'$route.path': 'loadList', '$route.path': {
handler: 'loadList',
immediate: true,
},
}, },
computed: { computed: {
// Computed property to let "listId" always have a value // Computed property to let "listId" always have a value

View file

@ -18,21 +18,25 @@ export default {
name: 'list-setting-archive', name: 'list-setting-archive',
data() { data() {
return { return {
listService: ListService, listService: new ListService(),
list: null,
} }
}, },
created() { created() {
this.listService = new ListService()
this.list = this.$store.getters['lists/getListById'](this.$route.params.listId)
this.setTitle(this.$t('list.archive.title', {list: this.list.title})) this.setTitle(this.$t('list.archive.title', {list: this.list.title}))
}, },
computed: {
list() {
return this.$store.getters['lists/getListById'](this.$route.params.listId)
},
},
methods: { methods: {
archiveList() { archiveList() {
const newList = {
...this.list,
isArchived: !this.list.isArchived,
}
this.list.isArchived = !this.list.isArchived this.listService.update(newList)
this.listService.update(this.list)
.then(r => { .then(r => {
this.$store.commit('currentList', r) this.$store.commit('currentList', r)
this.$store.commit('namespaces/setListInNamespaceById', r) this.$store.commit('namespaces/setListInNamespaceById', r)

View file

@ -78,13 +78,13 @@ export default {
return { return {
backgroundSearchTerm: '', backgroundSearchTerm: '',
backgroundSearchResult: [], backgroundSearchResult: [],
backgroundService: null, backgroundService: new BackgroundUnsplashService(),
backgroundThumbs: {}, backgroundThumbs: {},
currentPage: 1, currentPage: 1,
backgroundSearchTimeout: null, backgroundSearchTimeout: null,
backgroundUploadService: null, backgroundUploadService: new BackgroundUploadService(),
listService: null, listService: new ListService(),
} }
}, },
computed: mapState({ computed: mapState({
@ -94,9 +94,6 @@ export default {
hasBackground: state => state.background !== null, hasBackground: state => state.background !== null,
}), }),
created() { created() {
this.backgroundService = new BackgroundUnsplashService()
this.backgroundUploadService = new BackgroundUploadService()
this.listService = new ListService()
this.setTitle(this.$t('list.background.title')) this.setTitle(this.$t('list.background.title'))
// Show the default collection of backgrounds // Show the default collection of backgrounds
this.newBackgroundSearch() this.newBackgroundSearch()

View file

@ -16,14 +16,16 @@
export default { export default {
name: 'list-setting-delete', name: 'list-setting-delete',
created() { created() {
const list = this.$store.getters['lists/getListById'](this.$route.params.listId) this.setTitle(this.$t('list.delete.title', {list: this.list.title}))
this.setTitle(this.$t('list.delete.title', {list: list.title})) },
computed: {
list() {
return this.$store.getters['lists/getListById'](this.$route.params.listId)
},
}, },
methods: { methods: {
deleteList() { deleteList() {
const list = this.$store.getters['lists/getListById'](this.$route.params.listId) this.$store.dispatch('lists/deleteList', this.list)
this.$store.dispatch('lists/deleteList', list)
.then(() => { .then(() => {
this.$message.success({message: this.$t('list.delete.success')}) this.$message.success({message: this.$t('list.delete.success')})
this.$router.push({name: 'home'}) this.$router.push({name: 'home'})

View file

@ -23,7 +23,7 @@ export default {
name: 'list-setting-duplicate', name: 'list-setting-duplicate',
data() { data() {
return { return {
listDuplicateService: ListDuplicateService, listDuplicateService: new ListDuplicateService(),
selectedNamespace: null, selectedNamespace: null,
} }
}, },
@ -32,7 +32,6 @@ export default {
NamespaceSearch, NamespaceSearch,
}, },
created() { created() {
this.listDuplicateService = new ListDuplicateService()
this.setTitle(this.$t('list.duplicate.title')) this.setTitle(this.$t('list.duplicate.title'))
}, },
methods: { methods: {

View file

@ -80,7 +80,8 @@ export default {
data() { data() {
return { return {
list: ListModel, list: ListModel,
listService: ListService, listService: new ListService(),
listDuplicateService: new ListDuplicateService(),
} }
}, },
components: { components: {
@ -93,10 +94,11 @@ export default {
timeout: 60000, timeout: 60000,
}), }),
}, },
created() { watch: {
this.listService = new ListService() '$route.params.listId': {
this.listDuplicateService = new ListDuplicateService() handler: 'loadList',
this.loadList() immediate: true,
},
}, },
methods: { methods: {
loadList() { loadList() {

View file

@ -34,7 +34,7 @@ export default {
data() { data() {
return { return {
list: ListModel, list: ListModel,
listService: ListService, listService: new ListService(),
manageUsersComponent: '', manageUsersComponent: '',
manageTeamsComponent: '', manageTeamsComponent: '',
} }
@ -53,7 +53,6 @@ export default {
}, },
}, },
created() { created() {
this.listService = new ListService()
this.loadList() this.loadList()
}, },
methods: { methods: {

View file

@ -83,8 +83,8 @@ export default {
return { return {
showTaskswithoutDates: false, showTaskswithoutDates: false,
dayWidth: 35, dayWidth: 35,
dateFrom: null, dateFrom: new Date((new Date()).setDate((new Date()).getDate() - 15)),
dateTo: null, dateTo: new Date((new Date()).setDate((new Date()).getDate() + 30)),
} }
}, },
computed: { computed: {
@ -100,9 +100,5 @@ export default {
} }
}, },
}, },
beforeMount() {
this.dateFrom = new Date((new Date()).setDate((new Date()).getDate() - 15))
this.dateTo = new Date((new Date()).setDate((new Date()).getDate() + 30))
},
} }
</script> </script>

View file

@ -158,7 +158,7 @@ export default {
name: 'List', name: 'List',
data() { data() {
return { return {
taskService: TaskService, taskService: new TaskService(),
isTaskEdit: false, isTaskEdit: false,
taskEditTask: TaskModel, taskEditTask: TaskModel,
ctaVisible: false, ctaVisible: false,
@ -184,8 +184,6 @@ export default {
Pagination, Pagination,
}, },
created() { created() {
this.taskService = new TaskService()
// Save the current list view to local storage // Save the current list view to local storage
// We use local storage and not vuex here to make it persistent across reloads. // We use local storage and not vuex here to make it persistent across reloads.
saveListView(this.$route.params.listId, this.$route.name) saveListView(this.$route.params.listId, this.$route.name)

View file

@ -78,12 +78,9 @@ export default {
}, },
data() { data() {
return { return {
showArchived: false, showArchived: JSON.parse(localStorage.getItem('showArchived')) ?? false,
} }
}, },
created() {
this.showArchived = JSON.parse(localStorage.getItem('showArchived')) ?? false
},
mounted() { mounted() {
this.setTitle(this.$t('namespace.title')) this.setTitle(this.$t('namespace.title'))
}, },

View file

@ -51,18 +51,14 @@ export default {
data() { data() {
return { return {
showError: false, showError: false,
namespace: NamespaceModel, namespace: new NamespaceModel(),
namespaceService: NamespaceService, namespaceService: new NamespaceService(),
} }
}, },
components: { components: {
ColorPicker, ColorPicker,
CreateEdit, CreateEdit,
}, },
created() {
this.namespace = new NamespaceModel()
this.namespaceService = new NamespaceService()
},
mounted() { mounted() {
this.setTitle(this.$t('namespace.create.title')) this.setTitle(this.$t('namespace.create.title'))
}, },

View file

@ -18,13 +18,12 @@ export default {
name: 'namespace-setting-archive', name: 'namespace-setting-archive',
data() { data() {
return { return {
namespaceService: NamespaceService, namespaceService: new NamespaceService(),
namespace: null, namespace: null,
title: '', title: '',
} }
}, },
created() { created() {
this.namespaceService = new NamespaceService()
this.namespace = this.$store.getters['namespaces/getNamespaceById'](this.$route.params.id) this.namespace = this.$store.getters['namespaces/getNamespaceById'](this.$route.params.id)
this.title = this.namespace.isArchived ? this.title = this.namespace.isArchived ?
this.$t('namespace.archive.titleUnarchive', { namespace: this.namespace.title }) : this.$t('namespace.archive.titleUnarchive', { namespace: this.namespace.title }) :

View file

@ -19,13 +19,11 @@ export default {
name: 'namespace-setting-delete', name: 'namespace-setting-delete',
data() { data() {
return { return {
namespaceService: NamespaceService, namespaceService: new NamespaceService(),
title: '', title: '',
} }
}, },
created() { created() {
this.namespaceService = new NamespaceService()
const namespace = this.$store.getters['namespaces/getNamespaceById'](this.$route.params.id) const namespace = this.$store.getters['namespaces/getNamespaceById'](this.$route.params.id)
this.title = this.$t('namespace.delete.title', {namespace: namespace.title}) this.title = this.$t('namespace.delete.title', {namespace: namespace.title})
this.setTitle(this.title) this.setTitle(this.title)

View file

@ -69,8 +69,8 @@ export default {
name: 'namespace-setting-edit', name: 'namespace-setting-edit',
data() { data() {
return { return {
namespaceService: NamespaceService, namespaceService: new NamespaceService(),
namespace: NamespaceModel, namespace: new NamespaceModel(),
editorActive: false, editorActive: false,
title: '', title: '',
} }
@ -89,14 +89,13 @@ export default {
beforeMount() { beforeMount() {
this.namespace.id = this.$route.params.id this.namespace.id = this.$route.params.id
}, },
created() {
this.namespaceService = new NamespaceService()
this.namespace = new NamespaceModel()
this.loadNamespace()
},
watch: { watch: {
// call again the method if the route changes // call again the method if the route changes
'$route': 'loadNamespace', '$route': {
handler: 'loadNamespace',
deep: true,
immediate: true,
},
}, },
methods: { methods: {
loadNamespace() { loadNamespace() {

View file

@ -29,8 +29,8 @@ export default {
name: 'namespace-setting-share', name: 'namespace-setting-share',
data() { data() {
return { return {
namespaceService: NamespaceService, namespaceService: new NamespaceService(),
namespace: NamespaceModel, namespace: new NamespaceModel(),
manageUsersComponent: '', manageUsersComponent: '',
manageTeamsComponent: '', manageTeamsComponent: '',
title: '', title: '',
@ -43,14 +43,13 @@ export default {
beforeMount() { beforeMount() {
this.namespace.id = this.$route.params.id this.namespace.id = this.$route.params.id
}, },
created() {
this.namespaceService = new NamespaceService()
this.namespace = new NamespaceModel()
this.loadNamespace()
},
watch: { watch: {
// call again the method if the route changes // call again the method if the route changes
'$route': 'loadNamespace', '$route': {
handler: 'loadNamespace',
deep: true,
immediate: true,
},
}, },
computed: { computed: {
userIsAdmin() { userIsAdmin() {

View file

@ -97,7 +97,10 @@ export default {
setTimeout(() => this.showNothingToDo = true, 100) setTimeout(() => this.showNothingToDo = true, 100)
}, },
watch: { watch: {
'$route': 'loadPendingTasks', '$route': {
handler: 'loadPendingTasks',
deep: true,
},
startDate(newVal) { startDate(newVal) {
this.cStartDate = newVal this.cStartDate = newVal
}, },

View file

@ -10,6 +10,10 @@
<script> <script>
import ShowTasks from './ShowTasks' import ShowTasks from './ShowTasks'
function getNextWeekDate() {
return new Date((new Date()).getTime() + 7 * 24 * 60 * 60 * 1000)
}
export default { export default {
name: 'ShowTasksInRange', name: 'ShowTasksInRange',
components: { components: {
@ -17,18 +21,9 @@ export default {
}, },
data() { data() {
return { return {
startDate: null, startDate: new Date(),
endDate: null, endDate: getNextWeekDate(),
} }
}, },
created() {
this.setDatesToNextWeek()
},
methods: {
setDatesToNextWeek() {
this.startDate = new Date()
this.endDate = new Date((new Date()).getTime() + 7 * 24 * 60 * 60 * 1000)
},
},
} }
</script> </script>

View file

@ -468,8 +468,8 @@ export default {
data() { data() {
return { return {
taskId: Number(this.$route.params.id), taskId: Number(this.$route.params.id),
taskService: TaskService, taskService: new TaskService(),
task: TaskModel, task: new TaskModel(),
relationKinds: relationKinds, relationKinds: relationKinds,
// We doubled the task color property here because verte does not have a real change property, leading // We doubled the task color property here because verte does not have a real change property, leading
// to the color property change being triggered when the # is removed from it, leading to an update, // to the color property change being triggered when the # is removed from it, leading to an update,
@ -503,14 +503,11 @@ export default {
} }
}, },
watch: { watch: {
'$route': 'loadTask', '$route': {
handler: 'loadTask',
deep: true,
immediate: true,
}, },
created() {
this.taskService = new TaskService()
this.task = new TaskModel()
},
mounted() {
this.loadTask()
}, },
computed: { computed: {
currentList() { currentList() {

View file

@ -180,8 +180,8 @@ export default {
name: 'EditTeam', name: 'EditTeam',
data() { data() {
return { return {
teamService: TeamService, teamService: new TeamService(),
teamMemberService: TeamMemberService, teamMemberService: new TeamMemberService(),
team: TeamModel, team: TeamModel,
teamId: this.$route.params.id, teamId: this.$route.params.id,
member: TeamMemberModel, member: TeamMemberModel,
@ -191,7 +191,7 @@ export default {
newMember: UserModel, newMember: UserModel,
foundUsers: [], foundUsers: [],
userService: UserService, userService: new UserService(),
showError: false, showError: false,
title: '', title: '',
@ -206,15 +206,13 @@ export default {
timeout: 60000, timeout: 60000,
}), }),
}, },
created() {
this.teamService = new TeamService()
this.teamMemberService = new TeamMemberService()
this.userService = new UserService()
this.loadTeam()
},
watch: { watch: {
// call again the method if the route changes // call again the method if the route changes
$route: 'loadTeam', '$route': {
handler: 'loadTeam',
deep: true,
immediate: true,
},
}, },
computed: { computed: {
userIsAdmin() { userIsAdmin() {

View file

@ -32,12 +32,11 @@ export default {
name: 'ListTeams', name: 'ListTeams',
data() { data() {
return { return {
teamService: TeamService, teamService: new TeamService(),
teams: [], teams: [],
} }
}, },
created() { created() {
this.teamService = new TeamService()
this.loadTeams() this.loadTeams()
}, },
mounted() { mounted() {

View file

@ -37,18 +37,14 @@ export default {
name: 'NewTeam', name: 'NewTeam',
data() { data() {
return { return {
teamService: TeamService, teamService: new TeamService(),
team: TeamModel, team: new TeamModel(),
showError: false, showError: false,
} }
}, },
components: { components: {
CreateEdit, CreateEdit,
}, },
created() {
this.teamService = new TeamService()
this.team = new TeamModel()
},
mounted() { mounted() {
this.setTitle(this.$t('team.create.title')) this.setTitle(this.$t('team.create.title'))
}, },

View file

@ -76,7 +76,7 @@ export default {
}, },
data() { data() {
return { return {
passwordResetService: PasswordResetService, passwordResetService: new PasswordResetService(),
credentials: { credentials: {
password: '', password: '',
password2: '', password2: '',
@ -85,9 +85,6 @@ export default {
successMessage: '', successMessage: '',
} }
}, },
created() {
this.passwordResetService = new PasswordResetService()
},
mounted() { mounted() {
this.setTitle(this.$t('user.auth.resetPassword')) this.setTitle(this.$t('user.auth.resetPassword'))
}, },

View file

@ -59,16 +59,12 @@ export default {
}, },
data() { data() {
return { return {
passwordResetService: PasswordResetService, passwordResetService: new PasswordResetService(),
passwordReset: PasswordResetModel, passwordReset: new PasswordResetModel(),
errorMsg: '', errorMsg: '',
isSuccess: false, isSuccess: false,
} }
}, },
created() {
this.passwordResetService = new PasswordResetService()
this.passwordReset = new PasswordResetModel()
},
mounted() { mounted() {
this.setTitle(this.$t('user.auth.resetPassword')) this.setTitle(this.$t('user.auth.resetPassword'))
}, },

View file

@ -302,15 +302,15 @@ export default {
name: 'Settings', name: 'Settings',
data() { data() {
return { return {
passwordUpdateService: PasswordUpdateService, passwordUpdateService: new PasswordUpdateService(),
passwordUpdate: PasswordUpdateModel, passwordUpdate: new PasswordUpdateModel(),
passwordConfirm: '', passwordConfirm: '',
emailUpdateService: EmailUpdateService, emailUpdateService: new EmailUpdateService(),
emailUpdate: EmailUpdateModel, emailUpdate: new EmailUpdateModel(),
totpService: TotpService, totpService: new TotpService(),
totp: TotpModel, totp: new TotpModel(),
totpQR: '', totpQR: '',
totpEnrolled: false, totpEnrolled: false,
totpConfirmPasscode: '', totpConfirmPasscode: '',
@ -320,7 +320,7 @@ export default {
language: getCurrentLanguage(), language: getCurrentLanguage(),
settings: UserSettingsModel, settings: UserSettingsModel,
userSettingsService: UserSettingsService, userSettingsService: new UserSettingsService(),
defaultList: null, defaultList: null,
} }
@ -332,16 +332,6 @@ export default {
DataExport, DataExport,
}, },
created() { created() {
this.passwordUpdateService = new PasswordUpdateService()
this.passwordUpdate = new PasswordUpdateModel()
this.emailUpdateService = new EmailUpdateService()
this.emailUpdate = new EmailUpdateModel()
this.totpService = new TotpService()
this.totp = new TotpModel()
this.userSettingsService = new UserSettingsService()
this.settings = this.$store.state.auth.settings this.settings = this.$store.state.auth.settings
this.playSoundWhenDone = localStorage.getItem(playSoundWhenDoneKey) === 'true' || localStorage.getItem(playSoundWhenDoneKey) === null this.playSoundWhenDone = localStorage.getItem(playSoundWhenDoneKey) === 'true' || localStorage.getItem(playSoundWhenDoneKey) === null