This commit is contained in:
romankko2 committed 2023-02-10 17:33:51 +01:00
1 parent 1024f73ab5
commit 4e8fa39e34
8 files changed
+79 -13

No files matched your search

+3
View File
@@ -41,6 +41,9 @@
height: 24px height: 24px
width: 24px width: 24px
.is-finished
background: #06dece !important
.add-date .add-date
color: white color: white
border-radius: 50% border-radius: 50%
@@ -5,6 +5,7 @@
variant="solo" variant="solo"
v-model="search" v-model="search"
@keydown.enter="optionSelected()" @keydown.enter="optionSelected()"
@keydown.tab="optionSelected()"
:class="{ error: validations?.$errors?.length }" :class="{ error: validations?.$errors?.length }"
:hint=" :hint="
validations?.$errors validations?.$errors
@@ -196,7 +196,7 @@ export default {
} else { } else {
event.completed = !event.completed event.completed = !event.completed
try { try {
await this.$axios.patch_auth(`v1/tasks/${event.id}`, event) await this.$axios.patch_auth(`v1/subtasks/${event.id}`, event)
this.$emit('reopenTask', event) this.$emit('reopenTask', event)
} catch (error) { } catch (error) {
this.$toast.error(error) this.$toast.error(error)
@@ -9,9 +9,14 @@
</p> </p>
<p class="ml-2">{{ task._employeeFullName }}</p> <p class="ml-2">{{ task._employeeFullName }}</p>
</td> </td>
<td>
<p class="text-light-green" v-if="task.is_finished">Ukončený</p>
<p v-if="!task.is_finished">Neukončený</p>
</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/tm@dashboard/_components/_img/checkmark.svg')" alt="checkmark-icon" :style="{opacity: 0.3}"> <img v-if="task.is_finished" class="pencil-icon is-finished" :src="require('@/plugins/tm@dashboard/_components/_img/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(task)">
<img v-if="!task.is_finished" class="pencil-icon" :src="require('@/plugins/tm@dashboard/_components/_img/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(task)">
<img class="pencil-icon ml-2" :src="require('@/plugins/tm@overview/_img/pencil-icon.svg')" alt="pencil-icon" @click.stop="openEditTaskModal(task)"> <img class="pencil-icon ml-2" :src="require('@/plugins/tm@overview/_img/pencil-icon.svg')" alt="pencil-icon" @click.stop="openEditTaskModal(task)">
<img class="trash-icon" :src="require('@/plugins/tm@overview/_img/trash-icon.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(task)"> <img class="trash-icon" :src="require('@/plugins/tm@overview/_img/trash-icon.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(task)">
</div> </div>
@@ -56,6 +61,24 @@ export default {
openEditTaskModal(task) { openEditTaskModal(task) {
this.$events.emit('show-task-modal', { task, editMode: false }) this.$events.emit('show-task-modal', { task, editMode: false })
},
async clickCompleteTask(task) {
if (!task.is_finished) {
this.openCompleteTaskModal(task)
} else {
task.is_finished = !task.is_finished
try {
await this.$axios.patch_auth(`v1/subtasks/${task.id}`, task)
this.$emit('reopenTask', task)
} catch (error) {
this.$toast.error(error)
}
}
},
openCompleteTaskModal(task) {
this.$events.emit('show-complete-task-modal', { task })
} }
} }
} }
@@ -24,6 +24,13 @@ export default {
this.masterTask.project_id = project.id this.masterTask.project_id = project.id
}, },
onMasterTaskSelected({ key }) {
const masterTask = this.masterTasks.find(masterTask => masterTask.id == key)
this.masterTask.name = masterTask.name
console.log(masterTask.name)
this.masterTask.master_task.id = masterTask.id
},
onEmployeeSelected({ key }) { onEmployeeSelected({ key }) {
const employee = this.employees.find(employee => employee.id == key) const employee = this.employees.find(employee => employee.id == key)
this.masterTask.employees.push(employee) this.masterTask.employees.push(employee)
@@ -50,9 +57,11 @@ export default {
}, },
watch: { watch: {
'masterTask.team_id'(value) { 'masterTask.team_id'(value, oldValue) {
if (!value) return if (!value || !oldValue) return
this.masterTask.team = this.teams.find(team => team.id == value) this.masterTask.team = this.teams.find(team => team.id == value)
this.masterTask.employees = this.masterTask.team.employees
} }
} }
} }
@@ -24,11 +24,11 @@
</p> </p>
</v-text-field> </v-text-field>
<v-text-field v-for="(employee, index) in masterTask.team?.employees" :key="employee.id" @focus="onInputFocus" :class="{ error: !masterTask.team.employees[index].duration }" class="modal-input" :label="`${employee.name} ${employee.surname}`" variant="solo" placeholder="h" v-model="masterTask.team.employees[index].duration" type="number" min="1" @input="onEmployeeDurationChanged"> <!-- <v-text-field v-for="(employee, index) in masterTask.team?.employees" :key="employee.id" @focus="onInputFocus" :class="{ error: !masterTask.team.employees[index].duration }" class="modal-input" :label="`${employee.name} ${employee.surname}`" variant="solo" placeholder="h" v-model="masterTask.team.employees[index].duration" type="number" min="1" @input="onEmployeeDurationChanged">
<p class="employee-select-avatar d-flex justify-center align-center"> <p class="employee-select-avatar d-flex justify-center align-center">
{{ employee.name.charAt(0) + employee.surname.charAt(0) }} {{ employee.name.charAt(0) + employee.surname.charAt(0) }}
</p> </p>
</v-text-field> </v-text-field> -->
<Z-autocomplete label="Vyhľadať zamestnanca" v-if="showAddEmployeeInput" :options="employeesOptions" class="modal-input" @option-selected="onEmployeeSelected" /> <Z-autocomplete label="Vyhľadať zamestnanca" v-if="showAddEmployeeInput" :options="employeesOptions" class="modal-input" @option-selected="onEmployeeSelected" />
@@ -184,6 +184,16 @@ export default {
this.masterTask.team_id = this.masterTask.team.id this.masterTask.team_id = this.masterTask.team.id
this.masterTask.project_id = project.id this.masterTask.project_id = project.id
this.masterTask.project_code = project.code this.masterTask.project_code = project.code
// TODO refactor
this.masterTask.employees = this.masterTask.employees.map(employee => {
const subtask = this.masterTask?.subtasks.find(subtask => subtask.employee_id == employee.id)
employee.duration = subtask.duration
return employee
})
console.log(this.masterTask.employees)
} else { } else {
this.masterTask = { employees: [], duration: 0 } this.masterTask = { employees: [], duration: 0 }
} }
@@ -198,9 +208,15 @@ export default {
if (!(await this.v$.$validate())) return if (!(await this.v$.$validate())) return
this.masterTask.description = this.$refs['description'].getHTML() this.masterTask.description = this.$refs['description'].getHTML()
this.masterTask.employees = [...this.masterTask.employees, ...this.masterTask.team?.employees]
this.masterTask.project_code = null // this.masterTask.subtasks = this.masterTask.subtasks.map(subtask => {
// const employee = this.masterTask.employees.find(employee => employee.id == subtask.employee_id)
// subtask.duration = employee.duration
// return subtask
// })
// this.masterTask.project_code = null
try { try {
this.masterTask.deadline = moment(this.masterTask.deadline).format('YYYY-MM-DD HH:MM:SS') this.masterTask.deadline = moment(this.masterTask.deadline).format('YYYY-MM-DD HH:MM:SS')
@@ -2,8 +2,7 @@
<v-dialog v-model="visible" max-width="650"> <v-dialog v-model="visible" max-width="650">
<v-card> <v-card>
<div class="d-flex justify-space-between align-center"> <div class="d-flex justify-space-between align-center">
<h1>Ste si istý, že chcete ukončiť <b>{{ task.title }}</b>?</h1> <h1>Ste si istý, že chcete {{ this.task?.id ? 'ukončiť' : 'obnoviť' }} task, z masterTasku <b>{{ task.master_task }}</b>?</h1>
<v-icon <v-icon
@click.stop="visible = false" @click.stop="visible = false"
icon="mdi-close" icon="mdi-close"
@@ -38,7 +37,7 @@ export default {
async complete() { async complete() {
try { try {
const task = {...this.task, is_finished: true} const task = {...this.task, is_finished: true}
await this.$axios.patch_auth(`v1/tasks/${this.task.id}`, task) await this.$axios.patch_auth(`v1/subtasks/${this.task.id}`, task)
this.visible = false this.visible = false
this.$emit('task-completed', task) this.$emit('task-completed', task)
} catch (error) { } catch (error) {
+17 -2
View File
@@ -17,6 +17,17 @@
disabled disabled
></v-text-field> ></v-text-field>
<!-- <Z-autocomplete
label="Master task"
:options="masterTasks.map((masterTask) => ({ key: masterTask.id, value: masterTask.name }))"
:validations="v$.task.master_task"
:clear-on-submit="false"
:value="task.master_task.name"
:class="{ error: v$.task.master_task.$errors.length }"
class="modal-input"
@option-selected="onMasterTaskSelected"
/> -->
<!-- Toto treba fixnut --> <!-- Toto treba fixnut -->
<v-select <v-select
v-model="task.master_task.id" v-model="task.master_task.id"
@@ -373,18 +384,21 @@ import errorUtils from '@/plugins/lib@auth/_utils/error.utils'
import moment from 'moment' import moment from 'moment'
import { QuillEditor } from '@vueup/vue-quill' import { QuillEditor } from '@vueup/vue-quill'
import VuetifyFixFocusMixin from '@/plugins/tm@modal/_mixins/vuetify-fix-focus' import VuetifyFixFocusMixin from '@/plugins/tm@modal/_mixins/vuetify-fix-focus'
import SelectsMixin from '../master-task/_mixins/selects.mixin'
import * as FileSaver from 'file-saver' import * as FileSaver from 'file-saver'
import tmUtils from '@/plugins/tm@_utils/tm.utils' import tmUtils from '@/plugins/tm@_utils/tm.utils'
import '@vueup/vue-quill/dist/vue-quill.snow.css' import '@vueup/vue-quill/dist/vue-quill.snow.css'
import ZAutocomplete from '@/plugins/tm@_components/z-autocomplete.vue'
export default { export default {
emits: ['close', 'refresh'], emits: ['close', 'refresh'],
mixins: [VuetifyFixFocusMixin], mixins: [VuetifyFixFocusMixin, SelectsMixin],
components: { components: {
Datepicker, Datepicker,
ZFilesUpload, ZFilesUpload,
QuillEditor, QuillEditor,
// ZAutocomplete
}, },
data() { data() {
@@ -469,8 +483,9 @@ export default {
}, },
async save() { async save() {
console.log(this.task)
if (!(await this.v$.$validate())) if (!(await this.v$.$validate()))
return return console.log(this.v$);
this.task.description = this.$refs['description'].getHTML() this.task.description = this.$refs['description'].getHTML()