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
Signed by untrusted user: konrad
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,16 +40,14 @@ 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) {
this.checked = checked this.checked = 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,9 +259,12 @@ export default {
}, },
}, },
watch: { watch: {
value(newVal) { value: {
this.$set(this, 'params', newVal) handler(value) {
this.prepareFilters() this.params = value
this.prepareFilters()
},
immediate: true,
}, },
}, },
computed: { computed: {

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,18 +113,14 @@ export default {
}, },
}, },
watch: { watch: {
task() { task: {
this.taskEditTask = this.task handler() {
this.initTaskFields() this.taskEditTask = this.task
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() {
this.taskEditTask.dueDate = this.taskEditTask.dueDate =

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: {
this.loadComments() handler(taskId) {
this.newComment.taskId = this.taskId this.loadComments()
this.commentEdit.taskId = this.taskId this.newComment.taskId = taskId
this.commentToDelete.taskId = this.taskId this.commentEdit.taskId = 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,13 +68,13 @@ 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() {
this.saving = true this.saving = true

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,14 +74,13 @@ 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() {
const labels = (Object.values(this.$store.state.labels.labels).filter(l => { const labels = (Object.values(this.$store.state.labels.labels).filter(l => {

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,18 +39,14 @@ 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) {
if (query === '') { if (query === '') {

View File

@ -33,13 +33,13 @@ 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() {
this.$emit('input', this.priority) this.$emit('input', this.priority)

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,19 +171,14 @@ 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() {
return Object.keys(this.relatedTasks).length === 0 || this.showNewRelationForm return Object.keys(this.relatedTasks).length === 0 || this.showNewRelationForm

View File

@ -75,19 +75,16 @@ 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() {
if (this.task.repeatMode !== repeatModes.REPEAT_MODE_DEFAULT && this.repeatAfter.amount === 0) { if (this.task.repeatMode !== repeatModes.REPEAT_MODE_DEFAULT && this.repeatAfter.amount === 0) {

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',
created() { deep: true,
this.taskService = new TaskService() immediate: true,
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