[subtask, masterTask] delete requests

This commit is contained in:
romankko2 committed 2023-02-08 18:41:07 +01:00
1 parent 17ed7616ee
commit 72d709cd13
4 files changed
+44 -29

No files matched your search

+4 -4
View File
@@ -54,17 +54,17 @@ const options: Options = {
// 'GET v1/master-tasks/(id)': true, // 'GET v1/master-tasks/(id)': true,
// 'GET v1/master-tasks': true, // 'GET v1/master-tasks': true,
'POST v1/master-tasks/(id)': true, 'POST v1/master-tasks/(id)': true,
'DELETE v1/master-tasks/(id)': true, // 'DELETE v1/master-tasks/(id)': true,
'POST v1/master-tasks': true, // 'POST v1/master-tasks': true,
'GET v1/overview/projects': true, // 'GET v1/overview/projects': true,
'GET v1/overview/tasks': true, 'GET v1/overview/tasks': true,
'GET v1/overview/teams': true, 'GET v1/overview/teams': true,
'GET v1/overview/ongoing-tasks': true, 'GET v1/overview/ongoing-tasks': true,
'GET v1/overview/unscheduled-tasks': true, 'GET v1/overview/unscheduled-tasks': true,
'GET v1/tasks/(id)': true, 'GET v1/tasks/(id)': true,
'POST v1/tasks/(id)': true, // 'POST v1/tasks/(id)': true,
'DELETE v1/tasks/(id)': true, 'DELETE v1/tasks/(id)': true,
// 'GET v1/teams/(id)': true, // 'GET v1/teams/(id)': true,
@@ -12,19 +12,22 @@
</div> </div>
<v-card-actions class="d-flex flex-column modal-content"> <v-card-actions class="d-flex flex-column modal-content">
<v-text-field <v-select
v-model="masterTask.project_code" v-model="masterTask.project_id"
@focus="onInputFocus" @focus="onInputFocus"
class="modal-input" class="modal-input border-select"
label="Kód projektu" label="Kód projektu"
variant="solo" variant="solo"
:class="{ error: v$.masterTask.project_code.$errors.length }" :items="projects"
item-value="id"
item-title="code"
:class="{ error: v$.masterTask.project_id.$errors.length }"
:hint=" :hint="
v$.masterTask.project_code.$errors v$.masterTask.project_id.$errors
? errorUtils.parseErrors(v$.masterTask.project_code.$errors) ? errorUtils.parseErrors(v$.masterTask.project_id.$errors)
: null : null
" "
></v-text-field> ></v-select>
<v-text-field <v-text-field
v-model="masterTask.name" v-model="masterTask.name"
@@ -285,7 +288,7 @@
<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 class="pencil-icon" :src="require('@/plugins/tm@dashboard/_components/_img/checkmark.svg')" alt="checkmark-icon" :style="{opacity: 0.3}">
<img class="pencil-icon ml-2" :src="require('@/plugins/tm@overview/_img/pencil-icon.svg')" alt="pencil-icon" :style="{opacity: 0.3}"> <img class="pencil-icon ml-2" :src="require('@/plugins/tm@overview/_img/pencil-icon.svg')" alt="pencil-icon" :style="{opacity: 0.3}">
<img class="trash-icon" :src="require('@/plugins/tm@overview/_img/trash-icon.svg')" alt="trash-icon" :style="{opacity: 0.3}"> <img class="trash-icon" :src="require('@/plugins/tm@overview/_img/trash-icon.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(task)">
</div> </div>
</td> </td>
</tr> </tr>
@@ -336,6 +339,7 @@ export default {
errorUtils, errorUtils,
v$: useVuelidate(), v$: useVuelidate(),
teams: null, teams: null,
projects: null,
employees: null, employees: null,
employeeSelect: null, employeeSelect: null,
teamSelect: '', teamSelect: '',
@@ -348,9 +352,11 @@ export default {
validations() { validations() {
return { return {
masterTask: { masterTask: {
project_code: { required }, project_id: { required },
name: { required }, name: { required },
team: { required }, team: { required },
// duration: { required },
// description: { required },
deadline: { required }, deadline: { required },
employees: { atLeastOne } employees: { atLeastOne }
}, },
@@ -364,10 +370,6 @@ export default {
}, },
methods: { methods: {
itemSelected(x) {
console.log(x)
},
getFullNameByEmployeeId(employee_id) { getFullNameByEmployeeId(employee_id) {
let fullName = '' let fullName = ''
let initials = '' let initials = ''
@@ -394,6 +396,7 @@ export default {
try { try {
this.teams = await this.$axios.get_auth_data('v1/teams') this.teams = await this.$axios.get_auth_data('v1/teams')
const employees = await this.$axios.get_auth_data('v1/employees') const employees = await this.$axios.get_auth_data('v1/employees')
this.projects = await this.$axios.get_auth_data('v1/projects')
this.employees = tmUtils.enrichEmployeesByFullName(employees) this.employees = tmUtils.enrichEmployeesByFullName(employees)
if (masterTask?.id) { if (masterTask?.id) {
@@ -414,15 +417,23 @@ export default {
return return
try { try {
this.masterTask.duration = 5
this.masterTask.description = 'popis'
this.masterTask.employees = this.masterTask.employees.map(employee => {
employee.duration = 5
return employee
})
this.masterTask.deadline = moment(this.masterTask.deadline).format("YYYY-MM-DD HH:MM:SS")
if (this.masterTask.id) if (this.masterTask.id)
await this.$axios.put_auth(`v1/mastertasks/${this.masterTask.id}`, this.masterTask) await this.$axios.put_auth(`v1/mastertasks/${this.masterTask.id}`, this.masterTask)
else else
await this.$axios.post_auth('v1/mastertasks', this.masterTask) await this.$axios.post_auth_data('v1/mastertasks', this.masterTask)
this.closeModal() this.closeModal()
} catch (error) { } catch (error) {
this.$toast(error) this.$toast.error(error)
} }
}, },
@@ -435,6 +446,10 @@ export default {
this.$events.emit('show-delete-master-task-modal', { masterTask }) this.$events.emit('show-delete-master-task-modal', { masterTask })
}, },
openDeleteTaskModal(task) {
this.$events.emit('show-delete-task-modal', { task })
},
employeeSelected(selectedOption) { employeeSelected(selectedOption) {
const employee = this.employees.find((empl) => empl.id == selectedOption.key) const employee = this.employees.find((empl) => empl.id == selectedOption.key)
this.masterTask.employees.push(employee) this.masterTask.employees.push(employee)
@@ -2,7 +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 zmazať <b>{{ task.title }}</b>?</h1> <h1>Ste si istý, že chcete zmazať task z masterTasku <b>{{ task.project_code }}</b>?</h1>
<v-icon <v-icon
@click.stop="closeModal()" @click.stop="closeModal()"
@@ -42,7 +42,7 @@ export default {
async deleteTask() { async deleteTask() {
try { try {
await this.$axios.delete(`v1/tasks/${this.task.id}`) await this.$axios.delete(`v1/subtasks/${this.task.id}`)
this.$emit('on-task-deleted', this.task) this.$emit('on-task-deleted', this.task)
this.closeModal() this.closeModal()
} catch (error) { } catch (error) {
@@ -211,8 +211,6 @@
<v-card-actions class="mt-10 d-flex justify-start align-center"> <v-card-actions class="mt-10 d-flex justify-start align-center">
<Datepicker <Datepicker
v-model="selectedNewDate" v-model="selectedNewDate"
:class="{ error: v$.selectedNewDate.$errors.length }"
:validations="v$.selectedNewDate"
class="modal-input" class="modal-input"
format="dd.MM.yyyy, HH:mm" format="dd.MM.yyyy, HH:mm"
locale="sk" locale="sk"
@@ -414,13 +412,11 @@ export default {
validations() { validations() {
return { return {
task: { task: {
// project_code: { required },
date: { required }, date: { required },
// team: { required }, // team: { required },
duration: { required }, duration: { required },
employee: { required }, employee: { required },
}, }
selectedNewDate: { required }
} }
}, },
@@ -438,7 +434,7 @@ export default {
try { try {
this.masterTasks = await this.$axios.get_auth_data('v1/mastertasks') this.masterTasks = await this.$axios.get_auth_data('v1/mastertasks')
if (task?.id) { if (task?.id) {
const t = await this.$axios.get_auth_data(`v1/tasks/${task.id}`) const t = await this.$axios.get_auth_data(`v1/subtasks/${task.id}`)
this.employeeIdSelect = t.employee.id this.employeeIdSelect = t.employee.id
this.masterTaskIdSelect = t.master_task.id this.masterTaskIdSelect = t.master_task.id
@@ -459,14 +455,14 @@ export default {
}, },
async save() { async save() {
if (!(await this.v$.$validate())) return if (!(await this.v$.$validate())) return console.log(this.v$)
try { try {
if (this.task.id) { if (this.task.id) {
await this.$axios.put_auth(`v1/mastertasks/${this.task.id}`, this.task) await this.$axios.put_auth(`v1/mastertasks/${this.task.id}`, this.task)
this.$events.emit('on-task-edited', this.task) this.$events.emit('on-task-edited', this.task)
} else { } else {
await this.$axios.post_auth('v1/mastertasks', this.task) await this.$axios.post_auth('v1/subtasks', this.task)
} }
this.closeModal() this.closeModal()
@@ -504,6 +500,10 @@ export default {
if (!value || !this.task) return if (!value || !this.task) return
this.task.master_task = this.masterTasks.find(masterTask => masterTask.id == value) this.task.master_task = this.masterTasks.find(masterTask => masterTask.id == value)
const selectedMasterTask = this.masterTasks.find(masterTask => masterTask.id === value)
if (selectedMasterTask) {
this.task.project_code = selectedMasterTask.project_code
}
}, },
employeeIdSelect(value) { employeeIdSelect(value) {