From 4a9dfc652081ddb7acc2c4b4ab2ef1671dd123ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Glasn=C3=A1k?= Date: Tue, 11 Apr 2023 14:22:56 +0200 Subject: [PATCH] [Mastertask] Added v-autocomplete --- app/src/plugins/lib@search/search/search.vue | 7 ++ .../master-task/_mixins/selects.mixin.ts | 36 +++++----- .../master-task/z-master-task-modal.vue | 67 ++++++++++++------- .../plugins/tm@modal/team/z-team-modal.vue | 63 ++++++----------- 4 files changed, 87 insertions(+), 86 deletions(-) diff --git a/app/src/plugins/lib@search/search/search.vue b/app/src/plugins/lib@search/search/search.vue index b079f1f..25bd4b8 100644 --- a/app/src/plugins/lib@search/search/search.vue +++ b/app/src/plugins/lib@search/search/search.vue @@ -58,6 +58,13 @@ export default { this.onSearch(this.search, false) }) }, + + unmounted() { + this.$events.off('on-subtask-edited') + this.$events.off('on-subtask-deleted') + this.$events.off('on-mastertask-edited') + this.$events.off('on-mastertask-deleted') + }, methods: { onSearch: debounce(async function (search, reset = true) { diff --git a/app/src/plugins/tm@modal/master-task/_mixins/selects.mixin.ts b/app/src/plugins/tm@modal/master-task/_mixins/selects.mixin.ts index 2ebf323..bfadb0b 100644 --- a/app/src/plugins/tm@modal/master-task/_mixins/selects.mixin.ts +++ b/app/src/plugins/tm@modal/master-task/_mixins/selects.mixin.ts @@ -3,34 +3,28 @@ export default { employeesOptions() { const selectedEmployees = [...this.mastertask.employees].map(employee => employee.id) - const employees = this.enrichedEmployees.filter( + return this.enrichedEmployees.filter( (employee) => !selectedEmployees.includes(employee.id) ) || [] + }, - return employees.map((employee) => { - return { - key: employee.id, - value: `${employee.name} ${employee.surname}`, - } - }) + projectsOptions() { + // Added to "paginate" projects, because v-autocomplete was unable to handle so many projects at once + + const projects = this.projects.filter(project => project.code.includes(this.projectCodeSearch)) + return projects?.length ? projects.slice(0, 10) : this.projects.slice(0, 10) } }, methods: { - onProjectSelected({ key }) { - const project = this.projects.find(project => project.id == key) - this.mastertask.project_code = project.code - this.mastertask.project_id = project.id - }, + // onProjectSelected(id) { + // const project = this.projects.find(project => project.id == id) + // this.mastertask.project_code = project.code + // this.mastertask.project_id = project.id + // }, - onMasterTaskSelected({ key }) { - const mastertask = this.mastertasks.find(mastertask => mastertask.id == key) - this.subtask.master_task = mastertask - this.subtask.project_code = mastertask.project_code - }, - - onEmployeeSelected({ key }) { - const employee = this.enrichedEmployees.find(employee => employee.id == key) + onEmployeeSelected(id) { + const employee = this.enrichedEmployees.find(employee => employee.id == id) this.mastertask.employees.push(employee) this.showAddEmployeeInput = false }, @@ -60,6 +54,6 @@ export default { this.mastertask.team = this.teams.find(team => team.id == value) this.mastertask.employees = this.mastertask.team.employees - } + }, } } \ No newline at end of file diff --git a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue index d5b3d80..045a086 100644 --- a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue +++ b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue @@ -8,7 +8,7 @@ - + @@ -16,17 +16,26 @@ - + -