[tm@store] Added store

This commit is contained in:
Matej Glasnák committed 2023-02-15 15:56:24 +01:00
1 parent a1a410c54d
commit 774ca7b607
44 files changed
+989 -720

No files matched your search

@@ -1,14 +1,15 @@
<template>
<v-row class="px-10 py-8 subheader">
<v-select
v-model="selectedEmployee"
v-model="selectedEmployeeId"
class="subheader-input"
variant="outlined"
label="Zamestanec"
:items="[null, ...allEmployees]"
item-title="fullName"
:items="[null, ...enrichedEmployees]"
item-title="_fullName"
item-value="id"
></v-select>
<v-text-field
v-model="searchQuery"
class="subheader-input"
@@ -22,47 +23,37 @@
</template>
<script>
import { mapGetters } from 'vuex'
export default {
emits: ['seach', 'employee-selected'],
data() {
return {
selectedEmployee: null,
employees: [],
selectedEmployeeId: null,
searchQuery: ''
}
},
computed: {
allEmployees() {
const employees = this.employees.map((employee) => {
return `${employee.name} ${employee.surname}`
})
return employees
}
mounted() {
this.selectedEmployeeId = this.$store.getters['auth/user'].id
},
async created() {
try {
this.employees = await this.$axios.get_auth_data('v1/employees')
this.employees.filter((employee) => {
employee.fullName = `${employee.name} ${employee.surname}`
})
} catch (error) {
this.$toast.error(error)
}
computed: {
...mapGetters('tm', ['enrichedEmployees']),
},
methods: {
onInput() {
this.$emit('queryChange', this.searchQuery)
this.$emit('query-changed', this.searchQuery)
}
},
// watch: {
// selectedEmployee() {
// this.search()
// }
// }
watch: {
selectedEmployeeId() {
this.$emit('employee-selected', this.selectedEmployeeId)
}
}
}
</script>
@@ -13,9 +13,9 @@
<tbody>
<tr class="cursor-pointer" v-for="task in tasks" :key="task.id" @click.stop="editTask(task, false)">
<td>{{ task.project_code }}</td>
<td>{{ task.title }}</td>
<td>{{ task.duration / 1000 / 60 / 60 }} h</td>
<td>{{ (task.remaining_time / 1000 / 60 / 60).toFixed(2) }} h</td>
<td>{{ task.master_task }}</td>
<td>{{ task.duration }} h</td>
<td>{{ task.duration - task.spent_time }} h</td>
<td class="task-action">
<div class="d-flex justify-start">
<img class="pencil-icon" :src="require('@/plugins/tm@overview/_img/pencil-icon.svg')" alt="pencil-icon" @click.stop="editTask(task, true)" />
@@ -1,7 +1,7 @@
<template>
<div>
<Z-tasks-search @queryChange="onSearch" />
<Z-tasks-search @seach="onSearch" @employee-selected="onEmployeeSelected" />
<W-loadable :content="filteredOngoingTasks" :emptyMessage="searchQuery.length ? 'Neboli nájdené žiadne úlohy' : 'Nenašli sa žiadne záznamy'">
<A-ongoing-table :tasks="filteredOngoingTasks" />
@@ -12,6 +12,7 @@
<script>
import ZTasksSearch from '@/plugins/tm@overview/_components/z-tasks-search.vue'
import { mapGetters } from 'vuex'
import AOngoingTable from './_components/a-ongoing-table.vue'
export default {
@@ -22,47 +23,36 @@ export default {
data() {
return {
searchQuery: '',
ongoingTasks: null
searchQuery: ''
}
},
ionViewWillEnter() {
this.$store.dispatch('tm/loadOngoingSubtasks')
},
computed: {
...mapGetters('tm', ['ongoingSubtasks']),
filteredOngoingTasks() {
if (!this.ongoingTasks)
if (!this.ongoingSubtasks)
return null
if (!this.searchQuery)
return this.ongoingTasks
return this.ongoingTasks.filter((task) => {
return this.filterParams(this.searchQuery, task.title) || this.filterParams(this.searchQuery, task.project_code)
return this.ongoingSubtasks.filter(subtask => {
return this.filterParams(this.searchQuery, subtask.master_task) || this.filterParams(this.searchQuery, subtask.project_code)
})
}
},
async created() {
await this._loadData()
},
mounted() {
this.$events.on('on-task-deleted', () => this._loadData())
},
methods: {
async _loadData() {
this.ongoingTasks = null
try {
this.ongoingTasks = await this.$axios.get_auth_data('v1/overview/ongoing-tasks')
} catch (error) {
this.ongoingTasks = {error}
}
},
onSearch(searchQuery) {
this.searchQuery = searchQuery
},
onEmployeeSelected(id) {
this.$store.dispatch('tm/loadOngoingSubtasks', id)
},
filterParams(searchQuery, row) {
return row.toLowerCase().includes(searchQuery.toLowerCase())
}
@@ -11,9 +11,10 @@
<tbody>
<tr class="cursor-pointer" v-for="task in tasks" :key="task.id" @click.stop="editTask(task, false)">
<td>{{ task.project_code }}</td>
<td>{{ task.title }}</td>
<td>{{ (task.duration / 1000 / 60 / 60).toFixed(2) }} h</td>
<td>{{ task.master_task }}</td>
<td>{{ task.spent_time }} h</td>
<td class="task-action">
<div class="d-flex justify-start">
<img class="pencil-icon" :src="require('@/plugins/tm@overview/_img/pencil-icon.svg')" alt="pencil-icon" @click.stop="editTask(task, true)">
@@ -1,7 +1,7 @@
<template>
<div>
<Z-tasks-search @queryChange="onSearch" />
<Z-tasks-search @seach="onSearch" @employee-selected="onEmployeeSelected" />
<W-loadable :content="filteredUnscheduledTasks" :emptyMessage="searchQuery.length ? 'Neboli nájdené žiadne úlohy' : 'Nenašli sa žiadne záznamy'">
<A-unscheduled-table :tasks="filteredUnscheduledTasks" />
@@ -12,6 +12,7 @@
<script>
import ZTasksSearch from '@/plugins/tm@overview/_components/z-tasks-search.vue'
import { mapGetters } from 'vuex'
import AUnscheduledTable from './_components/a-unscheduled-table.vue'
export default {
components: {
@@ -21,46 +22,35 @@ export default {
data() {
return {
searchQuery: '',
unscheduledTasks: null
searchQuery: ''
}
},
ionViewWillEnter() {
this.$store.dispatch('tm/loadUnscheduledSubtasks')
},
computed: {
...mapGetters('tm', ['unscheduledSubtasks']),
filteredUnscheduledTasks() {
if (!this.unscheduledTasks)
if (!this.unscheduledSubtasks)
return null
if (!this.searchQuery)
return this.unscheduledTasks
return this.unscheduledTasks.filter((task) => {
return this.filterParams(this.searchQuery, task.title) || this.filterParams(this.searchQuery, task.project_code)
return this.unscheduledSubtasks.filter(subtask => {
return this.filterParams(this.searchQuery, subtask.master_task) || this.filterParams(this.searchQuery, subtask.project_code)
})
}
},
async created() {
await this._loadData()
},
mounted() {
this.$events.on('on-task-deleted', () => this._loadData())
},
methods: {
async _loadData() {
this.unscheduledTasks = null
try {
this.unscheduledTasks = await this.$axios.get_auth_data('v1/overview/unscheduled-tasks')
} catch (error) {
this.unscheduledTasks = {error}
}
},
onSearch(searchQuery) {
this.searchQuery = searchQuery
},
},
onEmployeeSelected(id) {
this.$store.dispatch('tm/loadUnscheduledSubtasks', id)
},
filterParams(searchQuery, row) {
return row.toLowerCase().includes(searchQuery.toLowerCase())
+4 -25
View File
@@ -1,10 +1,11 @@
<template>
<W-loadable :content="teams">
<A-teams-table :teams="teams" @reloadData="_loadData" />
<A-teams-table :teams="teams" />
</W-loadable>
</template>
<script>
import { mapGetters } from 'vuex';
import ATeamsTable from './_components/a-teams-table.vue'
export default {
@@ -12,30 +13,8 @@ export default {
ATeamsTable
},
data() {
return {
teams: null
}
},
async created() {
await this._loadData()
},
mounted() {
this.$events.on('on-team-update', () => this._loadData())
},
methods: {
async _loadData() {
this.teams = null
try {
this.teams = await this.$axios.get_auth_data('v1/teams')
} catch (error) {
this.teams = {error}
}
}
computed: {
...mapGetters('tm', ['teams'])
}
}
</script>