[Search] Fixed search refresh after action

This commit is contained in:
Matej Glasnák committed 2023-04-11 11:51:31 +02:00
1 parent 66e6b84bd9
commit 750f3dd59a
6 files changed
+54 -26

No files matched your search

@@ -7,8 +7,9 @@
<td>{{ mastertask.name }}</td> <td>{{ mastertask.name }}</td>
<td class="task-action"> <td class="task-action">
<div class="d-flex justify-start"> <div class="d-flex justify-start">
<img class="pencil-icon" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="openEditMasterTaskModal(mastertask)"> <img class="pencil-icon" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="openEditMasterTaskModal(mastertask, true)">
<img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteMasterTaskModal(mastertask)"> <img class="pencil-icon ml-2" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="eye-icon" @click.stop="openEditMasterTaskModal(mastertask, false)">
<img class="trash-icon ml-2" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteMasterTaskModal(mastertask)">
</div> </div>
</td> </td>
</tr> </tr>
@@ -36,8 +37,8 @@ export default {
this.$events.emit('show-delete-master-task-modal', { mastertask }) this.$events.emit('show-delete-master-task-modal', { mastertask })
}, },
openEditMasterTaskModal(mastertask) { openEditMasterTaskModal(mastertask, editMode) {
this.$events.emit('show-mastertask-modal', { mastertask, editMode: false }) this.$events.emit('show-mastertask-modal', { mastertask, editMode })
}, },
} }
} }
@@ -15,8 +15,9 @@
<div class="d-flex justify-start"> <div class="d-flex justify-start">
<img v-if="subtask.is_finished" class="pencil-icon is-finished" :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(subtask)"> <img v-if="subtask.is_finished" class="pencil-icon is-finished" :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(subtask)">
<img v-if="!subtask.is_finished" class="pencil-icon" :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(subtask)"> <img v-if="!subtask.is_finished" class="pencil-icon" :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(subtask)">
<img class="pencil-icon ml-2" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="openTaskModal(subtask)"> <img class="pencil-icon ml-2" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="openTaskModal(subtask, true)">
<img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(subtask)"> <img class="pencil-icon ml-2" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="eye-icon" @click.stop="openTaskModal(subtask, false)">
<img class="trash-icon ml-2" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(subtask)">
</div> </div>
</td> </td>
</tr> </tr>
@@ -61,8 +62,8 @@ export default {
this.$events.emit('show-delete-task-modal', { subtask }) this.$events.emit('show-delete-task-modal', { subtask })
}, },
openTaskModal(subtask) { openTaskModal(subtask, editMode) {
this.$events.emit('show-subtask-modal', { subtask, editMode: false }) this.$events.emit('show-subtask-modal', { subtask, editMode })
}, },
async clickCompleteTask(subtask) { async clickCompleteTask(subtask) {
+37 -13
View File
@@ -1,9 +1,14 @@
<template> <template>
<form> <div>
<A-search-result-mastertasks v-if="searchResults?.mastertasks" :mastertasks="searchResults.mastertasks"/> <p v-if="!this.searchResults" class="px-3 py-3">{{ this.search?.length ? $t('Searching...') : $t('Type something') }}</p>
<A-search-result-subtasks v-if="searchResults?.subtasks" :subtasks="searchResults.subtasks" /> <p v-else-if="this.searchResults.error" class="px-3">{{ this.searchResults.error }}</p>
<A-search-result-team v-if="searchResults?.teams" :teams="searchResults.teams" />
</form> <div v-else>
<A-search-result-mastertasks :mastertasks="searchResults.mastertasks"/>
<A-search-result-subtasks :subtasks="searchResults.subtasks" />
<A-search-result-team :teams="searchResults.teams" />
</div>
</div>
</template> </template>
<script> <script>
@@ -21,33 +26,52 @@ export default {
data() { data() {
return { return {
searchResults: {}, searchResults: null,
search: '' search: ''
} }
}, },
created() { created() {
this.$events.on('onSearch', (search) => { this.$events.on('onSearch', (search) => {
if (!search?.length)
return
this.search = search this.search = search
this.onSearch(search)
}) })
}, },
watch: { mounted() {
search(newVal) { this.$events.on('on-subtask-edited', () => {
this.updateSearchResults(newVal) this.onSearch(this.search, false)
} })
this.$events.on('on-subtask-deleted', () => {
this.onSearch(this.search, false)
})
this.$events.on('on-mastertask-edited', () => {
this.onSearch(this.search, false)
})
this.$events.on('on-mastertask-deleted', () => {
this.onSearch(this.search, false)
})
}, },
methods: { methods: {
updateSearchResults: debounce(async function (search) { onSearch: debounce(async function (search, reset = true) {
try { try {
if (reset)
this.searchResults = null
const { mastertasks, subtasks, teams} = await this.$axios.get_auth(`v1/search?q=${search}`) const { mastertasks, subtasks, teams} = await this.$axios.get_auth(`v1/search?q=${search}`)
this.searchResults = {mastertasks: mastertasks.data, subtasks: subtasks.data, teams: teams.data} this.searchResults = {mastertasks: mastertasks.data, subtasks: subtasks.data, teams: teams.data}
console.log(this.searchResults)
} catch (error) { } catch (error) {
this.$toast.error(error) this.$toast.error(error)
this.searchResults = {error}
} }
}, 500) }, 300)
} }
} }
</script> </script>
@@ -117,6 +117,8 @@ export default {
}) })
} }
console.log(events)
return events return events
}, },
+1 -1
View File
@@ -121,7 +121,7 @@ export default {
try { try {
const { subtasks, blockers } = await this.$axios.get_auth(`v1/subtasks?${queryParameters}`) const { subtasks, blockers } = await this.$axios.get_auth(`v1/subtasks?${queryParameters}`)
this.config.scrollHour = this.filter?.employee.work_start - 1 this.config.scrollHour = (this.filter?.employee.work_start / 60) - 1
this.config.date = this.filter.start this.config.date = this.filter.start
this.subtasks = [...subtasks, ...blockers.map(blocker => ({...blocker, type: 'blocker'}))] this.subtasks = [...subtasks, ...blockers.map(blocker => ({...blocker, type: 'blocker'}))]
} catch (error) { } catch (error) {
@@ -43,14 +43,14 @@ export default {
_generateNonWorking() { _generateNonWorking() {
const nonWorkingHours = [] const nonWorkingHours = []
const date = new Date(this.filter.start) const date = new Date(this.filter.start)
let earliestStartHour = null let earliestStartMinutes = null
this.calendarConfig.date = date this.calendarConfig.date = date
const { start: dayStart, end: dayEnd } = this._getDayStartEnd() const { start: dayStart, end: dayEnd } = this._getDayStartEnd()
this.filter.team.employees.forEach((employee, index) => { this.filter.team.employees.forEach((employee, index) => {
if (!earliestStartHour || employee.work_start < earliestStartHour) if (!earliestStartMinutes || (employee.work_start) < earliestStartMinutes)
earliestStartHour = employee.work_start earliestStartMinutes = employee.work_start
nonWorkingHours.push({ nonWorkingHours.push({
@@ -72,7 +72,7 @@ export default {
}) })
}) })
this.calendarConfig.scrollHour = earliestStartHour - 1 this.calendarConfig.scrollHour = (earliestStartMinutes) - 1
return nonWorkingHours return nonWorkingHours
}, },