-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathRequestList.vue
More file actions
106 lines (97 loc) · 2.29 KB
/
RequestList.vue
File metadata and controls
106 lines (97 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<template>
<div class="flex flex-col bg-white rounded mt-5 overflow-auto" v-if="props.items?.length">
<div
class="flex flex-row p-3.5 items-center justify-between border-b cursor-pointer"
v-for="link in props.items"
:key="link.name"
@click="openRequestModal(link)"
>
<component
:is="props.component || link.component"
:doc="link"
:workflowStateField="link.workflow_state_field"
:isTeamRequest="props.teamRequests"
/>
</div>
<router-link
v-if="props.addListButton"
:to="{ name: props.listButtonRoute }"
v-slot="{ navigate }"
>
<Button
variant="ghost"
@click="navigate"
class="w-full !text-gray-600 py-6 text-sm border-none bg-white hover:bg-white"
>
{{ __("View List") }}
</Button>
</router-link>
</div>
<EmptyState :message="emptyStateMessage || __('You have no requests')" v-else />
<ion-modal
ref="modal"
:is-open="isRequestModalOpen"
@didDismiss="closeRequestModal"
:initial-breakpoint="1"
:breakpoints="[0, 1]"
>
<RequestActionSheet
:fields="fieldsMap[selectedRequest?.doctype]"
v-model="selectedRequest"
/>
</ion-modal>
</template>
<script setup>
import { ref, inject } from "vue"
import { IonModal } from "@ionic/vue"
import RequestActionSheet from "@/components/RequestActionSheet.vue"
import {
LEAVE_FIELDS,
EXPENSE_CLAIM_FIELDS,
ATTENDANCE_REQUEST_FIELDS,
SHIFT_REQUEST_FIELDS,
SHIFT_FIELDS,
} from "@/data/config/requestSummaryFields"
const __ = inject("$translate")
const props = defineProps({
component: {
type: Object,
},
items: {
type: Array,
},
teamRequests: {
type: Boolean,
default: false,
},
addListButton: {
type: Boolean,
default: false,
},
listButtonRoute: {
type: String,
default: "",
},
emptyStateMessage: {
type: String,
default: "",
},
})
const fieldsMap = {
"Leave Application": LEAVE_FIELDS,
"Expense Claim": EXPENSE_CLAIM_FIELDS,
"Attendance Request": ATTENDANCE_REQUEST_FIELDS,
"Shift Request": SHIFT_REQUEST_FIELDS,
"Shift Assignment": SHIFT_FIELDS,
}
const isRequestModalOpen = ref(false)
const selectedRequest = ref(null)
const openRequestModal = async (request) => {
selectedRequest.value = request
isRequestModalOpen.value = true
}
const closeRequestModal = async () => {
isRequestModalOpen.value = false
selectedRequest.value = null
}
</script>