[Master Task Modal] refactor

This commit is contained in:
Matej Glasnák committed 2022-12-06 19:50:26 +01:00
1 parent e1d9e6302f
commit dd05c715b5
4 files changed
+54 -12

No files matched your search

+3 -1
View File
@@ -9,7 +9,9 @@
"starts_at": "2022-05-10T00:00:00+00:00", "starts_at": "2022-05-10T00:00:00+00:00",
"deadilne": "2022-11-10T00:00:00+00:00", "deadilne": "2022-11-10T00:00:00+00:00",
"project_code": "CO-2201", "project_code": "CO-2201",
"team_id": 1, "team": {
"id": 1
},
"employees": [ "employees": [
{ {
"id": 1, "id": 1,
@@ -3,7 +3,7 @@
<W-loadable :content="allEmployees" class="h-100"> <W-loadable :content="allEmployees" class="h-100">
<v-card height="100%" class="d-flex flex-column"> <v-card height="100%" class="d-flex flex-column">
<div class="d-flex justify-space-between align-center modal-header"> <div class="d-flex justify-space-between align-center modal-header">
<h1>Vytvoriť blocker</h1> <h1>{{ blocker.id ? 'Upraviť' : 'Vytvoriť'}} blocker</h1>
<v-icon <v-icon
@click.stop="show = false" @click.stop="show = false"
icon="mdi-close" icon="mdi-close"
@@ -57,7 +57,7 @@
/> />
</v-card-actions> </v-card-actions>
<v-btn class="z-btn" @click="save()">VYTVORIŤ</v-btn> <v-btn class="z-btn" @click="save()">{{ blocker.id ? 'UPRAVIŤ' : 'VYTVORIŤ'}}</v-btn>
</v-card> </v-card>
</W-loadable> </W-loadable>
</v-dialog> </v-dialog>
@@ -12,6 +12,7 @@
<v-card-actions class="d-flex flex-column modal-content"> <v-card-actions class="d-flex flex-column modal-content">
<v-text-field <v-text-field
v-model="masterTask.project_code"
@focus="onInputFocus" @focus="onInputFocus"
class="modal-input" class="modal-input"
label="Kód projektu" label="Kód projektu"
@@ -19,6 +20,7 @@
></v-text-field> ></v-text-field>
<v-text-field <v-text-field
v-model="masterTask.name"
@focus="onInputFocus" @focus="onInputFocus"
class="modal-input" class="modal-input"
label="Názov mastertasku" label="Názov mastertasku"
@@ -26,9 +28,9 @@
></v-text-field> ></v-text-field>
<Datepicker <Datepicker
v-model="masterTask.deadline"
@focus="onDateFocus" @focus="onDateFocus"
class="modal-input" class="modal-input"
v-model="date"
format="dd.MM.yyyy, HH:mm" format="dd.MM.yyyy, HH:mm"
locale="sk" locale="sk"
select-text="Vybrať" select-text="Vybrať"
@@ -37,12 +39,14 @@
/> />
<v-text-field <v-text-field
v-model="masterTask.duration"
@focus="onInputFocus" @focus="onInputFocus"
class="modal-input mt-5" class="modal-input mt-5"
label="Celkový odhad" label="Celkový odhad"
variant="solo" variant="solo"
type="number" type="number"
placeholder="h" placeholder="h"
disabled
></v-text-field> ></v-text-field>
<v-select <v-select
@@ -56,11 +60,13 @@
label="Popis" label="Popis"
class="modal-input" class="modal-input"
variant="solo" variant="solo"
v-model="masterTask.description"
></v-textarea> ></v-textarea>
<Z-files-upload @files-uploaded="filesUploaded"/> <Z-files-upload @files-uploaded="filesUploaded"/>
</v-card-actions> </v-card-actions>
<v-btn class="z-btn" @click="createMasterTask()">VYTVORIŤ</v-btn> <v-btn class="z-btn" @click="save()">VYTVORIŤ</v-btn>
</v-card> </v-card>
</v-dialog> </v-dialog>
</template> </template>
@@ -79,24 +85,58 @@ export default {
visible: { visible: {
type: Boolean, type: Boolean,
required: true required: true
},
masterTaskId: {
type: Number || null,
required: false,
default: null
} }
}, },
data() { data() {
return { return {
date: '', masterTask: {
project_code: null,
name: null,
deadilne: null,
duration: null,
team: {},
description: null,
files: []
},
preventInputFocus: false preventInputFocus: false
} }
}, },
methods: { methods: {
async createMasterTask() { async save() {
try { try {
await this.$axios.post_auth('v1/master-tasks') if (this.masterTask.id)
await this._update()
else
await this._create()
this.$router.push({ name: 'Dashboard - Tasks' }) this.$router.push({ name: 'Dashboard - Tasks' })
this.show = false this.show = false
} catch (error) { } catch (error) {
this.$toast.error(error.response.data.error) console.log(error)
}
},
async _create() {
try {
await this.$axios.post_auth('v1/master-tasks')
} catch (error) {
this.$toast.error(error)
}
},
async _update() {
try {
await this.$axios.post_auth(`v1/master-tasks/${this.masterTask.id}`)
} catch (error) {
this.$toast.error(error)
} }
}, },
@@ -115,7 +155,7 @@ export default {
}, },
filesUploaded(files) { filesUploaded(files) {
console.log(files.length) this.masterTask.files = files
} }
}, },
@@ -3,7 +3,7 @@
<W-loadable :content="allEmployees" class="h-100"> <W-loadable :content="allEmployees" class="h-100">
<v-card height="100%" class="d-flex flex-column"> <v-card height="100%" class="d-flex flex-column">
<div class="d-flex justify-space-between align-center modal-header"> <div class="d-flex justify-space-between align-center modal-header">
<h1>Vytvoriť tím</h1> <h1>{{ team.id ? 'Upraviť tím' : 'Vytvoriť tím' }}</h1>
<v-icon <v-icon
@click.stop="show = false" @click.stop="show = false"
icon="mdi-close" icon="mdi-close"
@@ -54,7 +54,7 @@
/> />
</v-card-actions> </v-card-actions>
<v-btn class="z-btn" @click="save()">VYTVORIŤ</v-btn> <v-btn class="z-btn" @click="save()">{{ team.id ? 'UPRAVIŤ' : 'VYTVORIŤ' }}</v-btn>
</v-card> </v-card>
</W-loadable> </W-loadable>
</v-dialog> </v-dialog>