Skip to content

Commit f369698

Browse files
committed
feat(fe): run task from template page
1 parent 8b5b8a3 commit f369698

File tree

3 files changed

+108
-35
lines changed

3 files changed

+108
-35
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<template>
2+
<EditDialog
3+
v-model="dialog"
4+
:save-button-text="TEMPLATE_TYPE_ACTION_TITLES[templateType]"
5+
title="New Task"
6+
@save="close"
7+
@close="close"
8+
>
9+
<template v-slot:title={}>
10+
<v-icon small class="mr-4">{{ TEMPLATE_TYPE_ICONS[templateType] }}</v-icon>
11+
<span class="breadcrumbs__item">{{ templateAlias }}</span>
12+
<v-icon>mdi-chevron-right</v-icon>
13+
<span class="breadcrumbs__item">New Task</span>
14+
</template>
15+
16+
<template v-slot:form="{ onSave, onError, needSave, needReset }">
17+
<TaskForm
18+
:project-id="projectId"
19+
item-id="new"
20+
:template-id="templateId"
21+
@save="onSave"
22+
@error="onError"
23+
:need-save="needSave"
24+
:need-reset="needReset"
25+
/>
26+
</template>
27+
</EditDialog>
28+
</template>
29+
<script>
30+
import TaskForm from './TaskForm.vue';
31+
import EditDialog from './EditDialog.vue';
32+
33+
import { TEMPLATE_TYPE_ACTION_TITLES, TEMPLATE_TYPE_ICONS } from '../lib/constants';
34+
import EventBus from '../event-bus';
35+
36+
export default {
37+
components: {
38+
TaskForm,
39+
EditDialog,
40+
},
41+
props: {
42+
value: Boolean,
43+
projectId: Number,
44+
templateId: Number,
45+
templateType: String,
46+
templateAlias: String,
47+
},
48+
data() {
49+
return {
50+
dialog: false,
51+
TEMPLATE_TYPE_ACTION_TITLES,
52+
TEMPLATE_TYPE_ICONS,
53+
};
54+
},
55+
watch: {
56+
async dialog(val) {
57+
this.$emit('input', val);
58+
},
59+
60+
async value(val) {
61+
this.dialog = val;
62+
},
63+
64+
close(e) {
65+
this.dialog = false;
66+
if (e) {
67+
EventBus.$emit('i-show-task', {
68+
taskId: e.item.id,
69+
});
70+
this.$emit('save', e);
71+
}
72+
this.$emit('close');
73+
},
74+
},
75+
};
76+
</script>

web/src/views/project/TemplateView.vue

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
</div>
88
<div v-else>
99

10+
<NewTaskDialog
11+
v-model="newTaskDialog"
12+
:project-id="projectId"
13+
:template-id="itemId"
14+
:template-alias="item.name"
15+
:template-type="item.type"
16+
/>
17+
1018
<EditDialog
1119
:max-width="700"
1220
v-model="editDialog"
@@ -68,14 +76,19 @@
6876
:to="viewId
6977
? `/project/${projectId}/views/${viewId}/templates/`
7078
: `/project/${projectId}/templates/`"
71-
>Task Templates
79+
>
80+
Task Templates
7281
</router-link>
7382
<v-icon>mdi-chevron-right</v-icon>
7483
<span class="breadcrumbs__item">{{ item.name }}</span>
7584
</v-toolbar-title>
7685

7786
<v-spacer></v-spacer>
7887

88+
<v-btn color="primary" depressed class="mr-3" @click="newTaskDialog = true">
89+
{{ TEMPLATE_TYPE_ACTION_TITLES[item.type] }}
90+
</v-btn>
91+
7992
<v-btn
8093
icon
8194
color="error"
@@ -202,10 +215,11 @@ import TemplateForm from '@/components/TemplateForm.vue';
202215
import TaskList from '@/components/TaskList.vue';
203216
import { TEMPLATE_TYPE_ACTION_TITLES, TEMPLATE_TYPE_ICONS, TEMPLATE_TYPE_TITLES } from '@/lib/constants';
204217
import ObjectRefsDialog from '@/components/ObjectRefsDialog.vue';
218+
import NewTaskDialog from '@/components/NewTaskDialog.vue';
205219
206220
export default {
207221
components: {
208-
YesNoDialog, EditDialog, TemplateForm, TaskList, ObjectRefsDialog,
222+
YesNoDialog, EditDialog, TemplateForm, TaskList, ObjectRefsDialog, NewTaskDialog,
209223
},
210224
211225
props: {
@@ -226,6 +240,7 @@ export default {
226240
TEMPLATE_TYPE_ACTION_TITLES,
227241
itemRefs: null,
228242
itemRefsDialog: null,
243+
newTaskDialog: null,
229244
};
230245
},
231246

web/src/views/project/Templates.vue

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,15 @@
4545
</template>
4646
</EditDialog>
4747

48-
<EditDialog
48+
<NewTaskDialog
4949
v-model="newTaskDialog"
50-
:save-button-text="TEMPLATE_TYPE_ACTION_TITLES[templateType]"
51-
title="New Task"
52-
@save="onTaskCreated"
50+
@save="itemId = null"
5351
@close="itemId = null"
54-
>
55-
<template v-slot:title={}>
56-
<v-icon small class="mr-4">{{ TEMPLATE_TYPE_ICONS[templateType] }}</v-icon>
57-
<span class="breadcrumbs__item">{{ templateAlias }}</span>
58-
<v-icon>mdi-chevron-right</v-icon>
59-
<span class="breadcrumbs__item">New Task</span>
60-
</template>
61-
62-
<template v-slot:form="{ onSave, onError, needSave, needReset }">
63-
<TaskForm
64-
:project-id="projectId"
65-
item-id="new"
66-
:template-id="itemId"
67-
@save="onSave"
68-
@error="onError"
69-
:need-save="needSave"
70-
:need-reset="needReset"
71-
/>
72-
</template>
73-
</EditDialog>
52+
:project-id="projectId"
53+
:template-id="itemId"
54+
:template-alias="templateAlias"
55+
:template-type="templateType"
56+
/>
7457

7558
<v-toolbar flat>
7659
<v-app-bar-nav-icon @click="showDrawer()"></v-app-bar-nav-icon>
@@ -245,19 +228,25 @@ import ItemListPageBase from '@/components/ItemListPageBase';
245228
import TemplateForm from '@/components/TemplateForm.vue';
246229
import TaskLink from '@/components/TaskLink.vue';
247230
import axios from 'axios';
248-
import TaskForm from '@/components/TaskForm.vue';
249231
import EditViewsForm from '@/components/EditViewsForm.vue';
250232
import TableSettingsSheet from '@/components/TableSettingsSheet.vue';
251233
import TaskList from '@/components/TaskList.vue';
252234
import EventBus from '@/event-bus';
253235
import TaskStatus from '@/components/TaskStatus.vue';
254236
import socket from '@/socket';
237+
import NewTaskDialog from '@/components/NewTaskDialog.vue';
255238
256239
import { TEMPLATE_TYPE_ACTION_TITLES, TEMPLATE_TYPE_ICONS } from '../../lib/constants';
257240
258241
export default {
259242
components: {
260-
TemplateForm, TaskForm, TableSettingsSheet, TaskStatus, TaskLink, TaskList, EditViewsForm,
243+
TemplateForm,
244+
TableSettingsSheet,
245+
TaskStatus,
246+
TaskLink,
247+
TaskList,
248+
EditViewsForm,
249+
NewTaskDialog,
261250
},
262251
mixins: [ItemListPageBase],
263252
async created() {
@@ -383,13 +372,6 @@ export default {
383372
});
384373
},
385374
386-
onTaskCreated(e) {
387-
EventBus.$emit('i-show-task', {
388-
taskId: e.item.id,
389-
});
390-
this.itemId = null;
391-
},
392-
393375
showTaskLog(taskId) {
394376
EventBus.$emit('i-show-task', {
395377
taskId,

0 commit comments

Comments
 (0)