Merge branch 'main' of bitbucket.org:studiotem/jandl-taskmanager-app

This commit is contained in:
StudioTem committed 2023-03-03 14:22:46 +01:00
commit 2e8dd25ab8
27 files changed
+235 -206

No files matched your search

+30 -23
View File
@@ -9,7 +9,7 @@
<Z-delete-team-modal ref="z-delete-team-modal" @update="onTeamUpdate" />
<Z-task-modal ref="z-task-modal" @on-subtask-edited="onTaskEdited" />
<Z-delete-task-modal ref="z-delete-task-modal" @on-task-deleted="onTaskDeleted" />
<Z-delete-task-modal ref="z-delete-task-modal" @on-subtask-deleted="onTaskDeleted" />
<Z-delete-master-task-modal ref="z-delete-master-task-modal" @on-mastertask-deleted="onMasterTaskDeleted" />
<Z-complete-task-modal ref="z-complete-task-modal" @on-subtask-edited="onTaskEdited" />
<Z-task-add-time-modal ref="z-task-add-time-modal" />
@@ -44,35 +44,35 @@ export default {
mounted() {
this.$events.on('show-delete-team-modal', ({team}) => {
this.$refs['z-delete-team-modal'].showModal(team)
this.$refs['z-delete-team-modal'].showModal({ team })
})
this.$events.on('show-team-modal', ({team}) => {
this.$refs['z-team-modal'].showModal(team)
this.$events.on('show-team-modal', ({ team }) => {
this.$refs['z-team-modal'].showModal({ team })
})
this.$events.on('show-delete-task-modal', ({task}) => {
this.$refs['z-delete-task-modal'].showModal(task)
this.$events.on('show-delete-task-modal', ({subtask}) => {
this.$refs['z-delete-task-modal'].showModal({subtask})
})
this.$events.on('show-delete-master-task-modal', ({mastertask}) => {
this.$refs['z-delete-master-task-modal'].showModal(mastertask)
this.$refs['z-delete-master-task-modal'].showModal({mastertask})
})
this.$events.on('show-task-modal', ({task, editMode, mastertask}) => {
if(task && task.id) {
const id = task.id
this.$router.push({ query: { 'task': id }})
this.$events.on('show-subtask-modal', ({subtask, editMode, mastertask}) => {
if(subtask && subtask.id) {
const id = subtask.id
this.$router.push({ query: { 'subtask': id }})
}
this.$refs['z-task-modal'].showModal(task, editMode, mastertask)
this.$refs['z-task-modal'].showModal({subtask, editMode, mastertask})
})
this.$events.on('show-master-task-modal', ({ mastertask, editMode }) => {
this.$events.on('show-mastertask-modal', ({ mastertask, editMode }) => {
if (mastertask && mastertask.id) {
const id = mastertask.id
this.$router.push({ query: { 'master-task': id } })
this.$router.push({ query: { 'mastertask': id } })
}
this.$refs['z-master-task-modal'].showModal(mastertask, editMode)
this.$refs['z-master-task-modal'].showModal({mastertask, editMode})
})
this.$events.on('show-complete-task-modal', ({ subtask }) => {
@@ -98,6 +98,8 @@ export default {
this.$events.on('on-mastertask-deleted', () => {
this.$store.dispatch('tm/reloadMastertasks')
})
this._showModalsAfterInicialization()
},
methods: {
@@ -106,7 +108,7 @@ export default {
},
onTaskDeleted(task) {
this.$events.emit('on-task-deleted', task)
this.$events.emit('on-subtask-deleted', task)
},
onTaskEdited(task) {
@@ -119,14 +121,19 @@ export default {
onMasterTaskEdited(mastertask){
this.$events.emit('on-mastertask-edited', mastertask)
}
},
},
watch: {
'$route'() {
// if (this.$route.query['master-task']) {
// this.$events.emit('show-master-task-modal', { mastertask: { id: this.$route.query['master-task'] }, editMode: false })
// }
_showModalsAfterInicialization(repeat = 0) {
setTimeout(() => {
if (repeat > 50)
return this.$router.push({name: this.$route.name})
else if (!this.$store.getters['tm/isInitialized'])
return this._showModalsAfterInicialization(repeat + 1)
else if (this.$route.query['mastertask'])
return this.$events.emit('show-mastertask-modal', { mastertask: { id: this.$route.query['mastertask'] }, editMode: false })
else if (this.$route.query['subtask'])
return this.$events.emit('show-subtask-modal', { subtask: { id: this.$route.query['subtask'] }, editMode: false })
}, 300)
}
}
}
@@ -79,11 +79,11 @@ export default {
},
createMasterTask() {
this.$events.emit('show-master-task-modal', {})
this.$events.emit('show-mastertask-modal', {})
},
createTask() {
this.$events.emit('show-task-modal', {})
this.$events.emit('show-subtask-modal', {})
},
createTeam() {
@@ -24,7 +24,7 @@ export default {
v$: useVuelidate(),
form: {},
// form: {
// email: 'zachariah.vonrueden@jandl.sk',
// email: 'jan.fajnor@jandl.sk',
// password: 'testpassword'
// },
showPassword: false
@@ -3,13 +3,13 @@
<h1 class="px-3 py-3">Tasks</h1>
<v-table>
<tbody>
<tr v-for="task in tasks" :key="task.id">
<td>{{ task.project_code }}</td>
<td>{{ task.title }}</td>
<tr v-for="subtask in subtasks" :key="subtask.id">
<td>{{ subtask.project_code }}</td>
<td>{{ subtask.title }}</td>
<td>
<p>{{ task.user.name + task.user.surname }}</p>
<p>{{ subtask.user.name + subtask.user.surname }}</p>
<p class="employee-avatar d-flex justify-center align-center">
{{ task.user.name.charAt(0) }}
{{ subtask.user.name.charAt(0) }}
</p>
</td>
<td class="task-action">
@@ -29,7 +29,7 @@
export default {
props: {
tasks: {
subtasks: {
type: Array,
required: true
}
+1 -1
View File
@@ -1,7 +1,7 @@
<template>
<form>
<A-search-result-team v-if="searchResults?.teams" :teams="searchResults.teams" />
<A-search-result-tasks v-if="searchResults?.tasks" :tasks="searchResults.tasks" />
<A-search-result-tasks v-if="searchResults?.tasks" :subtasks="searchResults.tasks" />
</form>
</template>
@@ -195,10 +195,10 @@ export default {
return event.end.getTime() - event.start.getTime()
},
taskClicked(task) {
if (task.nonWorking) return
taskClicked(subtask) {
if (subtask.nonWorking) return
// console.log("task", task)
if (task.end.getTime() - task.start.getTime() <= 3600000) {
if (subtask.end.getTime() - subtask.start.getTime() <= 3600000) {
// console.log("ShortTask")
}
},
@@ -212,12 +212,12 @@ export default {
this.$events.emit('show-complete-task-modal', { subtask })
},
editTask(task, editMode) {
this.$events.emit('show-task-modal', {task, editMode})
editTask(subtask, editMode) {
this.$events.emit('show-subtask-modal', {subtask, editMode})
},
deleteTask(task) {
this.$events.emit('show-delete-task-modal', {task})
deleteTask(subtask) {
this.$events.emit('show-delete-task-modal', {subtask})
}
}
}
@@ -81,7 +81,7 @@ export default {
openMasterTaskModal(mastertaskId) {
const mastertask = this.mastertasks.find(mastertask => mastertask.id == mastertaskId)
this.$events.emit('show-master-task-modal', {mastertask, editMode: false})
this.$events.emit('show-mastertask-modal', {mastertask, editMode: false})
}
}
}
@@ -82,10 +82,15 @@ export default {
this.$events.on('on-subtask-edited', () => {
this.onFilterChanged(this.filter)
})
this.$events.on('on-subtask-deleted', () => {
this.onFilterChanged(this.filter)
})
},
unmounted() {
this.$events.off('on-subtask-edited')
this.$events.off('on-subtask-deleted')
},
methods: {
@@ -74,6 +74,21 @@ export default {
}
},
mounted() {
this.$events.on('on-subtask-edited', () => {
this.onFilterChanged(this.filter)
})
this.$events.on('on-subtask-deleted', () => {
this.onFilterChanged(this.filter)
})
},
unmounted() {
this.$events.off('on-subtask-edited')
this.$events.off('on-subtask-deleted')
},
methods: {
_generateTasks() {
const tasks = []
@@ -133,9 +133,10 @@ export default {
},
methods: {
async showModal(blocker = null) {
async showModal({ blocker }) {
this.visible = true
this.blocker = null
this.$nextTick(() => this.v$.$reset())
try {
const employees = await this.$axios.get_auth_data('v1/employees')
@@ -1,24 +1,24 @@
<template>
<v-table class="mt-7 mb-5">
<tbody class="px-5 py-5">
<tr v-for="task in enrichedtasks" :key="task.id">
<td class="w-25">{{ task.project_code }}</td>
<tr v-for="subtask in enrichedtasks" :key="subtask.id">
<td class="w-25">{{ subtask.project_code }}</td>
<td class="d-flex align-center">
<p class="employee-selected-avatar d-flex justify-center align-center">
{{ task._employeeInitials }}
{{ subtask._employeeInitials }}
</p>
<p class="ml-2">{{ task._employeeFullName }}</p>
<p class="ml-2">{{ subtask._employeeFullName }}</p>
</td>
<td>
<p class="text-light-green" v-if="task.is_finished">Ukončený</p>
<p v-if="!task.is_finished">Neukončený</p>
<p class="text-light-green" v-if="subtask.is_finished">Ukončený</p>
<p v-if="!subtask.is_finished">Neukončený</p>
</td>
<td class="task-action">
<div class="d-flex justify-start">
<img v-if="task.is_finished" class="pencil-icon is-finished" :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(task)">
<img v-if="!task.is_finished" class="pencil-icon" :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(task)">
<img class="pencil-icon ml-2" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="openTaskModal(task)">
<img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(task)">
<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 class="pencil-icon ml-2" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="openTaskModal(subtask)">
<img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(subtask)">
</div>
</td>
</tr>
@@ -27,40 +27,39 @@
</template>
<script>
import { mapGetters } from 'vuex'
export default {
props: {
tasks: {
subtasks: {
type: Array,
required: true
},
employees: {
type: Array,
required: true
}
},
computed: {
...mapGetters('tm', ['enrichedEmployees']),
enrichedtasks() {
return this.tasks.map(task => {
const employee = this.employees.find(employee => employee.id == task.employee_id)
return this.subtasks.map(subtask => {
const employee = this.enrichedEmployees.find(employee => employee.id == subtask.employee_id)
return {
...task,
_employeeInitials: employee.name.charAt(0) + employee.surname.charAt(0),
_employeeFullName: `${employee.name} ${employee.surname}`
...subtask,
_employeeInitials: employee._initials,
_employeeFullName: employee._fullName
}
})
}
},
methods: {
openDeleteTaskModal(task) {
this.$events.emit('show-delete-task-modal', { task })
openDeleteTaskModal(subtask) {
this.$events.emit('show-delete-task-modal', { subtask })
},
openTaskModal(task) {
this.$events.emit('show-task-modal', { task, editMode: false })
openTaskModal(subtask) {
this.$events.emit('show-subtask-modal', { subtask, editMode: false })
},
async clickCompleteTask(subtask) {
@@ -25,8 +25,8 @@ export default {
onMasterTaskSelected({ key }) {
const mastertask = this.mastertasks.find(mastertask => mastertask.id == key)
this.task.master_task = mastertask
this.task.project_code = mastertask.project_code
this.subtask.master_task = mastertask
this.subtask.project_code = mastertask.project_code
},
onEmployeeSelected({ key }) {
@@ -31,7 +31,7 @@ export default {
},
methods: {
async showModal(mastertask) {
async showModal({ mastertask }) {
this.mastertask = mastertask
this.visible = true
},
@@ -61,7 +61,7 @@
<v-btn class="button primary" @click="save()">Ukončiť mastertask</v-btn>
</div>
<A-tasks-table :tasks="mastertask.subtasks" :employees="enrichedEmployees" />
<A-tasks-table :subtasks="mastertask.subtasks" />
<div class="d-flex align-center ">
<v-btn class="subtask-btn w-100" @click="addTask()" ><v-icon class="mx-1" icon="mdi-plus" />Pridať task</v-btn>
@@ -125,8 +125,7 @@ export default {
computed: {
...mapGetters('tm', [
'teams',
'projects',
'enrichedEmployees'
'projects'
])
},
@@ -147,7 +146,7 @@ export default {
if (mastertask?.id == this.mastertask?.id) this.closeModal()
})
this.$events.on('on-task-deleted', (task) => {
this.$events.on('on-subtask-deleted', (task) => {
if (!this.mastertask) return
this.mastertask.subtasks = this.mastertask.subtasks.filter((subtask) => subtask.id != task.id)
})
@@ -165,15 +164,15 @@ export default {
beforeUnmount() {
this.$events.off('on-mastertask-deleted')
this.$events.off('on-task-deleted')
this.$events.off('on-subtask-deleted')
this.$events.off('on-subtask-edited')
},
methods: {
async showModal(mastertask, editMode = false) {
this.v$.$reset()
async showModal({mastertask, editMode = false}) {
this.visible = true
this.mastertask = null
this.$nextTick(() => this.v$.$reset())
try {
if (mastertask?.id) {
@@ -234,7 +233,7 @@ export default {
},
addTask() {
this.$events.emit('show-task-modal', { task: null, editMode: false, mastertask: this.mastertask })
this.$events.emit('show-subtask-modal', { subtask: null, editMode: false, mastertask: this.mastertask })
}
},
@@ -42,7 +42,7 @@ export default {
methods: {
openMastertask() {
this.$emit('close-modal')
this.$events.emit('show-master-task-modal', {mastertask: {id: this.id}, editMode: false})
this.$events.emit('show-mastertask-modal', {mastertask: {id: this.id}, editMode: false})
}
}
}
@@ -20,8 +20,8 @@
<p class="task-badge rounded-pill">Pridať záznam</p>
</div>
<template v-if="task.timesheets.length">
<div v-for="timesheet in task.timesheets" :key="timesheet.id" class="d-flex align-center mb-3">
<template v-if="subtask.timesheets.length">
<div v-for="timesheet in subtask.timesheets" :key="timesheet.id" class="d-flex align-center mb-3">
<v-icon @click.stop="deleteTimesheet(timesheet)" class="remove-date cursor-pointer mr-2" icon="mdi-minus" size="medium" />
<div class="d-flex align-center flex-start width-100">
@@ -61,7 +61,7 @@ export default {
required: true
},
task: {
subtask: {
type: Object,
required: true
}
@@ -91,22 +91,22 @@ export default {
if (!await this.v$.$validate())
return
const task = JSON.parse(JSON.stringify(this.task))
const subtask = JSON.parse(JSON.stringify(this.subtask))
task.timesheets.push({
subtask.timesheets.push({
id: null,
employee_id: task.employee_id,
employee_id: subtask.employee_id,
time: typeof this.form.hours == 'string' ? parseInt(this.form.hours) : this.form.hours
})
this._update(task)
this._update(subtask)
},
async deleteTimesheet({ id }) {
const task = JSON.parse(JSON.stringify(this.task))
task.timesheets = task.timesheets.filter(timesheet => timesheet.id != id)
const subtask = JSON.parse(JSON.stringify(this.subtask))
subtask.timesheets = subtask.timesheets.filter(timesheet => timesheet.id != id)
this._update(task)
this._update(subtask)
},
closeModal() {
@@ -118,9 +118,9 @@ export default {
this.$nextTick(() => this.v$.$reset())
},
async _update(task) {
async _update(data) {
try {
const { subtask } = await this.$axios.put_auth(`v1/subtasks/${task.id}`, task)
const { subtask } = await this.$axios.put_auth(`v1/subtasks/${data.id}`, data)
this.closeModal()
this.$events.emit('on-subtask-edited', subtask)
@@ -62,7 +62,7 @@ export default {
required: true
},
task: {
subtask: {
type: Object,
required: true
}
@@ -97,32 +97,32 @@ export default {
if (!await this.v$.$validate())
return
const task = JSON.parse(JSON.stringify(this.task))
const subtask = JSON.parse(JSON.stringify(this.subtask))
const splittedStartsAtTime = this.form.starts_at_time.split(':')
const splittedEndsAtTime = this.form.ends_at_time.split(':')
const start = moment(this.form.date).hours(parseInt(splittedStartsAtTime[0])).minutes(parseInt(splittedStartsAtTime[1])).toISOString()
const end = moment(this.form.date).hours(parseInt(splittedEndsAtTime[0])).minutes(parseInt(splittedEndsAtTime[1])).toISOString()
task.timeblocks.push({
subtask.timeblocks.push({
id: null,
start: tmUtils.formatDateTimeForBackend(start),
end: tmUtils.formatDateTimeForBackend(end)
})
this._update(task)
this._update(subtask)
},
async deleteTimeblock({ id }) {
const task = JSON.parse(JSON.stringify(this.task))
task.timeblocks = task.timeblocks.filter(timeblock => timeblock.id != id)
const subtask = JSON.parse(JSON.stringify(this.subtask))
subtask.timeblocks = subtask.timeblocks.filter(timeblock => timeblock.id != id)
this._update(task)
this._update(subtask)
},
async _update(task) {
async _update(data) {
try {
const { subtask } = await this.$axios.put_auth(`v1/subtasks/${task.id}`, task)
const { subtask } = await this.$axios.put_auth(`v1/subtasks/${data.id}`, data)
this.closeModal()
this.$events.emit('on-subtask-edited', subtask)
@@ -1,14 +1,14 @@
<template>
<A-mastertask-name :name="task.master_task?.name || task.master_task" :id="task.master_task.id" :color="task.master_task.color" @close-modal="$emit('close-modal')" />
<A-mastertask-status :status="task.is_finished" />
<A-task-timeblocks :timeblocks="task.timeblocks" :task="task" />
<Z-created-by :employee-id="task.created_by" />
<A-task-assigned-employee :employee="task.employee" />
<A-task-planned-time :hours="task.duration" />
<A-task-remaining-time :hours="task.duration - task.spent_time" />
<A-task-spent-time :hours="task.spent_time" :task="task" />
<A-task-description :description="task.description" :mastertask-description="task.master_task_description" />
<Z-files :files="task.files" />
<A-mastertask-name :name="subtask.master_task?.name || task.master_task" :id="subtask.master_task.id" :color="subtask.master_task.color" @close-modal="$emit('close-modal')" />
<A-mastertask-status :status="subtask.is_finished" />
<A-task-timeblocks :timeblocks="subtask.timeblocks" :subtask="subtask" />
<Z-created-by :employee-id="subtask.created_by" />
<A-task-assigned-employee :employee="subtask.employee" />
<A-task-planned-time :hours="subtask.duration" />
<A-task-remaining-time :hours="subtask.duration - subtask.spent_time" />
<A-task-spent-time :hours="subtask.spent_time" :subtask="subtask" />
<A-task-description :description="subtask.description" :mastertask-description="subtask.master_task_description" />
<Z-files :files="subtask.files" />
</template>
<script>
@@ -40,7 +40,7 @@ export default {
},
props: {
task: {
subtask: {
type: Object,
required: true
}
@@ -2,7 +2,7 @@
<v-dialog v-model="visible" max-width="750">
<v-card>
<div class="d-flex justify-space-between align-center">
<h1>Ste si istý, že chcete zmazať task z mastertasku <b>{{ task.project_code }}</b>?</h1>
<h1>Ste si istý, že chcete zmazať task z mastertasku <b>{{ subtask.project_code }}</b>?</h1>
<v-icon
@click.stop="closeModal()"
@@ -21,18 +21,18 @@
<script>
export default {
emits: ['on-task-deleted'],
emits: ['on-subtask-deleted'],
data() {
return {
visible: false,
task: null
subtask: null
}
},
methods: {
async showModal(task) {
this.task = task
async showModal({ subtask }) {
this.subtask = subtask
this.visible = true
},
@@ -42,10 +42,10 @@ export default {
async deleteTask() {
try {
await this.$axios.delete_auth(`v1/subtasks/${this.task.id}`)
await this.$axios.delete_auth(`v1/subtasks/${this.subtask.id}`)
this.$store.commit('tm/delete_subtask', this.task)
this.$emit('on-task-deleted', this.task)
this.$store.commit('tm/delete_subtask', this.subtask)
this.$emit('on-subtask-deleted', this.subtask)
this.closeModal()
} catch (error) {
this.$toast.error(error)
@@ -46,6 +46,7 @@ export default {
async showModal({ subtask }) {
this.subtask = subtask
this.visible = true
this.$nextTick(() => this.v$.$reset())
},
async submit() {
+59 -58
View File
@@ -1,50 +1,50 @@
<template>
<v-dialog v-model="visible" max-width="750" max-height="90%" height="700px">
<W-loadable :content="task" class="h-100">
<W-loadable :content="subtask" class="h-100">
<v-card v-if="editMode" height="100%" class="d-flex flex-column scrolling">
<div class="d-flex justify-space-between align-center modal-header">
<h1>{{ task.id ? "Upraviť task" : "Vytvoriť task" }}</h1>
<h1>{{ subtask.id ? "Upraviť task" : "Vytvoriť task" }}</h1>
<v-icon @click.stop="closeModal()" icon="mdi-close" size="large"></v-icon>
</div>
<v-card-actions class="d-flex flex-column modal-content">
<v-text-field v-model="task.project_code" label="Kód projektu" :value="task.project_code" @focus="onInputFocus" class="modal-input" variant="solo" disabled></v-text-field>
<v-text-field v-model="subtask.project_code" label="Kód projektu" :value="subtask.project_code" @focus="onInputFocus" class="modal-input" variant="solo" disabled></v-text-field>
<Z-autocomplete label="Master task" :options="mastertasks.map((mastertask) => ({ key: mastertask.id, value: mastertask.name }))" :validations="v$.task.master_task.id" :clear-on-submit="false" :value="task?.master_task?.name" :class="{ error: v$.task.master_task.id.$errors.length }" class="modal-input" @option-selected="onMasterTaskSelected" />
<Z-autocomplete label="Master task" :options="mastertasks.map((mastertask) => ({ key: mastertask.id, value: mastertask.name }))" :validations="v$.subtask.master_task.id" :clear-on-submit="false" :value="subtask?.master_task?.name" :class="{ error: v$.subtask.master_task.id.$errors.length }" class="modal-input" @option-selected="onMasterTaskSelected" />
<v-select v-model="task.employee_id" ref="employee-select" @focus="onInputFocus" class="modal-input border-select" label="Priradený" :class="{ error: v$.task.employee_id.$errors.length }" variant="solo" :items="filteredEmployees" item-value="id" item-title="_fullName"></v-select>
<v-select v-model="subtask.employee_id" ref="employee-select" @focus="onInputFocus" class="modal-input border-select" label="Priradený" :class="{ error: v$.subtask.employee_id.$errors.length }" variant="solo" :items="filteredEmployees" item-value="id" item-title="_fullName"></v-select>
<v-text-field v-model="task.duration" @focus="onInputFocus" class="modal-input" variant="solo" type="number" label="Časový odhad" :class="{ error: v$.task.duration.$errors.length }" :hint="v$.task.duration.$errors ? errorUtils.parseErrors(v$.task.duration.$errors) : null" append-inner-icon="mdi-clock-outline"></v-text-field>
<v-text-field v-model="subtask.duration" @focus="onInputFocus" class="modal-input" variant="solo" type="number" label="Časový odhad" :class="{ error: v$.subtask.duration.$errors.length }" :hint="v$.subtask.duration.$errors ? errorUtils.parseErrors(v$.subtask.duration.$errors) : null" append-inner-icon="mdi-clock-outline"></v-text-field>
<div class="w-100 modal-input">
<QuillEditor ref="description" v-model="task.description" placeholder="Popis" theme="snow" class="rich-text-editor" @input="task.description = $event.srcElement.innerHTML" />
<QuillEditor ref="description" v-model="subtask.description" placeholder="Popis" theme="snow" class="rich-text-editor" @input="subtask.description = $event.srcElement.innerHTML" />
</div>
<Z-files-upload class="mt-15 files" :files="task.files" @files-uploaded="filesUploaded" />
<Z-files-upload class="mt-15 files" :files="subtask.files" @files-uploaded="filesUploaded" />
</v-card-actions>
<v-btn class="button primary" @click="save()">{{ task.id ? "UPRAVIŤ" : "VYTVORIŤ" }}</v-btn>
<v-btn class="button primary" @click="save()">{{ subtask.id ? "UPRAVIŤ" : "VYTVORIŤ" }}</v-btn>
</v-card>
<v-card v-else height="100%" class="d-flex flex-column scrolling">
<div class="d-flex justify-space-between align-center">
<p>{{ task.project_code }}</p>
<p>{{ subtask.project_code }}</p>
<v-icon @click.stop="closeModal()" icon="mdi-close" size="large" class="pb-5"></v-icon>
</div>
<div class="d-flex justify-space-between align-center modal-header border-bottom pb-4">
<h1>{{ task.title }}</h1>
<h1>{{ subtask.title }}</h1>
<div class="d-flex justify-start">
<img class="icon" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="editMode = !editMode" />
<img class="icon trash" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(task)" />
<img class="icon trash" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(subtask)" />
</div>
</div>
<v-card-actions class="d-flex flex-column modal-content">
<div class="w-100">
<Z-task-readonly-info :task="task" @close-modal="closeModal" />
<Z-task-readonly-info :subtask="subtask" @close-modal="closeModal" />
<div class="d-flex justify-start align-center mt-8">
<v-btn class="done-btn" v-if="!task.is_finished" @click.stop="showCompleteTaskModal()">Dokončiť</v-btn>
<v-btn class="done-btn" v-if="!subtask.is_finished" @click.stop="showCompleteTaskModal()">Dokončiť</v-btn>
<v-btn class="button secondary" v-else @click.stop="showCompleteTaskModal()">Znovu otvoriť</v-btn>
<v-btn class="button secondary" @click="save()">Uložiť zmeny</v-btn>
</div>
@@ -88,7 +88,7 @@ export default {
tmUtils,
editMode: false,
visible: false,
task: null,
subtask: null,
errorUtils,
v$: useVuelidate(),
preventInputFocus: false,
@@ -105,16 +105,16 @@ export default {
]),
filteredEmployees() {
if (!this.enrichedEmployees || !this.task?.master_task) return []
if (!this.enrichedEmployees || !this.subtask?.master_task) return []
const selectedEmployees = this.task.master_task.employees?.map((employee) => employee.id) || []
const selectedEmployees = this.subtask.master_task.employees?.map((employee) => employee.id) || []
return this.enrichedEmployees.filter((employee) => !selectedEmployees.includes(employee.id))
}
},
validations() {
return {
task: {
subtask: {
master_task: {
id: { required }
},
@@ -125,35 +125,35 @@ export default {
},
mounted() {
this.$events.on("on-subtask-edited", (task) => {
if (task?.id == this.task?.id)
this.task = this._enrichTask(task)
this.$events.on("on-subtask-edited", (subtask) => {
if (subtask?.id == this.subtask?.id)
this.subtask = this._enrichTask(subtask)
// TODO: Remove? riesil som neodstranovanie jedineho zanamu v trvani a odpracovanom case
this.$forceUpdate()
})
this.$events.on('on-task-deleted', (task) => {
if (task?.id == this.task?.id) this.closeModal()
this.$events.on('on-subtask-deleted', (subtask) => {
if (subtask?.id == this.subtask?.id) this.closeModal()
})
},
methods: {
async showModal(task, editMode = false, mastertask = {}) {
this.task = null
async showModal({subtask, editMode = false, mastertask = {}}) {
this.subtask = null
this.visible = true
this.$nextTick(() => this.v$.$reset())
try {
if (task?.id) {
const subtask = await this.$axios.get_auth_data(`v1/subtasks/${task.id}`)
this.task = this._enrichTask(subtask)
if (subtask?.id) {
const data = await this.$axios.get_auth_data(`v1/subtasks/${subtask.id}`)
this.subtask = this._enrichTask(data)
} else {
this.task = { master_task: mastertask, timeblocks: [{start: tmUtils.formatDateTimeForBackend(moment()), end: tmUtils.formatDateTimeForBackend(moment())}] }
this.subtask = { master_task: mastertask, timeblocks: [{start: tmUtils.formatDateTimeForBackend(moment()), end: tmUtils.formatDateTimeForBackend(moment())}] }
this.mastertaskIdSelect = mastertask.id
}
this.editMode = editMode || !this.task.id
this.editMode = editMode || !this.subtask.id
} catch (error) {
this.$toast.error(error)
}
@@ -161,25 +161,26 @@ export default {
closeModal() {
this.visible = false
this.$router.replace({name: this.$route.name})
},
async save() {
if (!(await this.v$.$validate()))
return
this.task.description = this.$refs["description"].getHTML()
this.subtask.description = this.$refs["description"].getHTML()
try {
if (this.task?.id) {
const { subtask } = await this.$axios.put_auth(`v1/subtasks/${this.task.id}`, this.task)
if (this.subtask?.id) {
const { subtask } = await this.$axios.put_auth(`v1/subtasks/${this.subtask.id}`, this.subtask)
this.$store.commit('tm/update_subtask', subtask)
} else {
const { subtask } = await this.$axios.post_auth(`v1/mastertasks/${this.task.master_task.id}/subtasks`, this.task)
this.task.id = subtask.id
const { subtask } = await this.$axios.post_auth(`v1/mastertasks/${this.subtask.master_task.id}/subtasks`, this.subtask)
this.subtask.id = subtask.id
this.$store.commit('tm/update_subtask', subtask)
}
this.$events.emit("on-subtask-edited", this.task)
this.$events.emit("on-subtask-edited", this.subtask)
this.closeModal()
} catch (error) {
this.$toast.error(error)
@@ -188,7 +189,7 @@ export default {
async addNewDate() {
if (this.selectedNewDate) {
this.task.timeblocks.push({
this.subtask.timeblocks.push({
start: this.selectedNewDate[0],
end: this.selectedNewDate[1]
})
@@ -199,7 +200,7 @@ export default {
async downloadFile(id) {
try {
const file = await this.$axios.get_auth_data(`v1/subtasks/${this.task.id}`, { responseType: "arraybuffer" })
const file = await this.$axios.get_auth_data(`v1/subtasks/${this.subtask.id}`, { responseType: "arraybuffer" })
FileSaver.saveAs(file.files[id].path, file.files[id].name)
} catch (error) {
this.$toast.error(error)
@@ -207,55 +208,55 @@ export default {
},
removeDate(index) {
this.task.timeblocks.splice(index, 1)
this.subtask.timeblocks.splice(index, 1)
},
openDeleteTaskModal(task) {
this.$events.emit("show-delete-task-modal", { task })
openDeleteTaskModal(subtask) {
this.$events.emit("show-delete-task-modal", { subtask })
},
showCompleteTaskModal() {
this.$events.emit('show-complete-task-modal', { subtask: this.task })
this.$events.emit('show-complete-task-modal', { subtask: this.subtask })
},
filesUploaded(files) {
this.task.files = files
this.subtask.files = files
},
_enrichTask(task) {
task.master_task = this.mastertasks.find((mastertask) => mastertask.id == task.master_task_id)
task.employee = this.enrichedEmployees.find((employee) => employee.id == task.employee_id)
task._created_by = this.enrichedEmployees.find((employee) => employee.id == task.created_by)
this.mastertaskIdSelect = task.master_task?.id
_enrichTask(subtask) {
subtask.master_task = this.mastertasks.find((mastertask) => mastertask.id == subtask.master_task_id)
subtask.employee = this.enrichedEmployees.find((employee) => employee.id == subtask.employee_id)
subtask._created_by = this.enrichedEmployees.find((employee) => employee.id == subtask.created_by)
this.mastertaskIdSelect = subtask.master_task?.id
return task
return subtask
}
},
watch: {
mastertaskIdSelect(value) {
if (!value || !this.task) return
if (!value || !this.subtask) return
this.task.master_task = this.mastertasks.find((mastertask) => mastertask.id == value)
this.task.project_code = this.task.master_task.project_code
this.subtask.master_task = this.mastertasks.find((mastertask) => mastertask.id == value)
this.subtask.project_code = this.subtask.master_task.project_code
},
"task.employee_id"(value, oldValue) {
"subtask.employee_id"(value, oldValue) {
if (!value) return
if (value && oldValue)
this.task.timeblocks = []
this.subtask.timeblocks = []
this.task.employee = this.enrichedEmployees.find((employee) => employee.id == value)
this.subtask.employee = this.enrichedEmployees.find((employee) => employee.id == value)
},
editMode() {
this.$nextTick(() => {
this.$refs["description"]?.setHTML(this.task.description || "")
this.$refs["description"]?.setHTML(this.subtask.description || "")
const employeeSelect = this.$refs['employee-select']?.$el?.querySelector('.v-select__selection-text')
if (employeeSelect)
employeeSelect.innerHTML = this.task?.employee?._fullName || ''
employeeSelect.innerHTML = this.subtask?.employee?._fullName || ''
})
}
}
@@ -28,7 +28,7 @@ export default {
},
methods: {
async showModal(team) {
async showModal({team}) {
this.team = team
this.visible = true
},
@@ -98,9 +98,10 @@ export default {
},
methods: {
async showModal(team = null) {
async showModal({ team = null}) {
this.visible = true
this.team = null
this.$nextTick(() => this.v$.$reset())
try {
const allEmployees = await this.$axios.get_auth_data('v1/employees')
@@ -11,16 +11,16 @@
</thead>
<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.master_task?.name || task.master_task }}</td>
<td>{{ task.duration }} h</td>
<td>{{ task.duration - task.spent_time }} h</td>
<tr class="cursor-pointer" v-for="subtask in subtasks" :key="subtask.id" @click.stop="editTask(subtask, false)">
<td>{{ subtask.project_code }}</td>
<td>{{ subtask.master_task?.name || subtask.master_task }}</td>
<td>{{ subtask.duration }} h</td>
<td>{{ subtask.duration - subtask.spent_time }} h</td>
<td class="task-action">
<div class="d-flex justify-start">
<img class="pencil-icon mr-3" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="editTask(task, false)">
<img class="pencil-icon" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="editTask(task, true)" />
<img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="deleteTask(task)" />
<img class="pencil-icon mr-3" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="editTask(subtask, false)">
<img class="pencil-icon" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="editTask(subtask, true)" />
<img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="deleteTask(subtask)" />
</div>
</td>
</tr>
@@ -33,19 +33,19 @@
<script>
export default {
props: {
tasks: {
subtasks: {
type: Array,
required: true
}
},
methods: {
editTask(task, editMode = false) {
this.$events.emit('show-task-modal', {task, editMode})
editTask(subtask, editMode = false) {
this.$events.emit('show-subtask-modal', {subtask, editMode})
},
deleteTask(task) {
this.$events.emit('show-delete-task-modal', {task})
deleteTask(subtask) {
this.$events.emit('show-delete-task-modal', {subtask})
}
}
}
@@ -4,7 +4,7 @@
<Z-tasks-search @search="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" />
<A-ongoing-table :subtasks="filteredOngoingTasks" />
</W-loadable>
</div>
@@ -10,16 +10,16 @@
</thead>
<tbody>
<tr class="cursor-pointer" v-for="task in tasks" :key="task.id" @click.stop="editTask(task, false)">
<tr class="cursor-pointer" v-for="subtask in subtasks" :key="subtask.id" @click.stop="editTask(subtask, false)">
<td>{{ task.project_code }}</td>
<td>{{ task.master_task?.name || task.master_task }}</td>
<td>{{ task.spent_time }} h</td>
<td>{{ subtask.project_code }}</td>
<td>{{ subtask.master_task?.name || subtask.master_task }}</td>
<td>{{ subtask.spent_time }} h</td>
<td class="task-action">
<div class="d-flex justify-start">
<img class="pencil-icon mr-3" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="editTask(task, false)">
<img class="pencil-icon" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="editTask(task, true)">
<img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="deleteTask(task)">
<img class="pencil-icon mr-3" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="editTask(subtask, false)">
<img class="pencil-icon" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="editTask(subtask, true)">
<img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="deleteTask(subtask)">
</div>
</td>
</tr>
@@ -30,19 +30,19 @@
<script>
export default {
props: {
tasks: {
subtasks: {
type: Array,
required: true
}
},
methods: {
editTask(task, editMode) {
this.$events.emit('show-task-modal', {task, editMode})
editTask(subtask, editMode) {
this.$events.emit('show-subtask-modal', {subtask, editMode})
},
deleteTask(task) {
this.$events.emit('show-delete-task-modal', {task})
deleteTask(subtask) {
this.$events.emit('show-delete-task-modal', {subtask})
}
}
}
@@ -4,7 +4,7 @@
<Z-tasks-search @search="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" />
<A-unscheduled-table :subtasks="filteredUnscheduledTasks" />
</W-loadable>
</div>