@eeplatform/nuxt-layer-common 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/components/Curriculum.vue +269 -0
- package/components/CurriculumForm.vue +347 -0
- package/components/CurriculumSubject.vue +273 -0
- package/components/CurriculumSubjectForm.vue +597 -0
- package/components/EnrollmentForm.vue +5 -3
- package/composables/useBasicEdu.ts +15 -3
- package/composables/useCurriculum.ts +49 -0
- package/composables/useCurriculumSubject.ts +58 -0
- package/package.json +1 -1
- package/types/curriculum.d.ts +31 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-row no-gutters class="pa-4">
|
|
3
|
+
<v-col v-if="localProps.canAdd" cols="12" class="mb-2">
|
|
4
|
+
<v-row no-gutters>
|
|
5
|
+
<v-btn
|
|
6
|
+
class="text-none"
|
|
7
|
+
rounded="pill"
|
|
8
|
+
variant="tonal"
|
|
9
|
+
@click="dialogCreate = true"
|
|
10
|
+
size="large"
|
|
11
|
+
>
|
|
12
|
+
Add subject
|
|
13
|
+
</v-btn>
|
|
14
|
+
</v-row>
|
|
15
|
+
</v-col>
|
|
16
|
+
|
|
17
|
+
<v-col cols="12">
|
|
18
|
+
<v-card width="100%" variant="outlined" border="thin" rounded="lg">
|
|
19
|
+
<v-toolbar density="compact" color="grey-lighten-4">
|
|
20
|
+
<template #prepend>
|
|
21
|
+
<v-btn fab icon density="comfortable" @click="">
|
|
22
|
+
<v-icon>mdi-refresh</v-icon>
|
|
23
|
+
</v-btn>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<template #append>
|
|
27
|
+
<v-row no-gutters justify="end" align="center">
|
|
28
|
+
<span class="mr-2 text-caption text-fontgray">
|
|
29
|
+
{{ pageRange }}
|
|
30
|
+
</span>
|
|
31
|
+
<local-pagination
|
|
32
|
+
v-model="page"
|
|
33
|
+
:length="pages"
|
|
34
|
+
@update:value=""
|
|
35
|
+
/>
|
|
36
|
+
</v-row>
|
|
37
|
+
</template>
|
|
38
|
+
</v-toolbar>
|
|
39
|
+
|
|
40
|
+
<v-data-table
|
|
41
|
+
:headers="headers"
|
|
42
|
+
:items="items"
|
|
43
|
+
item-value="_id"
|
|
44
|
+
items-per-page="20"
|
|
45
|
+
fixed-header
|
|
46
|
+
hide-default-footer
|
|
47
|
+
hide-default-header
|
|
48
|
+
@click:row="tableRowClickHandler"
|
|
49
|
+
style="max-height: calc(100vh - (200px))"
|
|
50
|
+
>
|
|
51
|
+
</v-data-table>
|
|
52
|
+
</v-card>
|
|
53
|
+
</v-col>
|
|
54
|
+
|
|
55
|
+
<!-- dialog -->
|
|
56
|
+
<v-dialog v-model="dialogCreate" persistent width="450">
|
|
57
|
+
<CurriculumSubjectForm
|
|
58
|
+
title="Add subject"
|
|
59
|
+
@cancel="dialogCreate = false"
|
|
60
|
+
@success="successHandler()"
|
|
61
|
+
mode="create"
|
|
62
|
+
/>
|
|
63
|
+
</v-dialog>
|
|
64
|
+
|
|
65
|
+
<v-dialog v-model="dialogView" persistent width="450">
|
|
66
|
+
<CurriculumSubjectForm
|
|
67
|
+
title="View subject details"
|
|
68
|
+
@cancel="dialogView = false"
|
|
69
|
+
@edit="handleEdit()"
|
|
70
|
+
@delete="dialogDelete = true"
|
|
71
|
+
:data="subject"
|
|
72
|
+
:can-edit="localProps.canEdit"
|
|
73
|
+
:can-delete="localProps.canDelete"
|
|
74
|
+
mode="view"
|
|
75
|
+
/>
|
|
76
|
+
</v-dialog>
|
|
77
|
+
|
|
78
|
+
<v-dialog v-model="dialogUpdate" persistent width="450">
|
|
79
|
+
<CurriculumSubjectForm
|
|
80
|
+
title="Update subject details"
|
|
81
|
+
@cancel="dialogUpdate = false"
|
|
82
|
+
:data="subject"
|
|
83
|
+
:can-edit="localProps.canEdit"
|
|
84
|
+
:can-delete="localProps.canDelete"
|
|
85
|
+
mode="edit"
|
|
86
|
+
/>
|
|
87
|
+
</v-dialog>
|
|
88
|
+
|
|
89
|
+
<v-dialog
|
|
90
|
+
v-model="dialogDelete"
|
|
91
|
+
:loading="loadingDelete"
|
|
92
|
+
width="450"
|
|
93
|
+
persistent
|
|
94
|
+
>
|
|
95
|
+
<v-card width="100%">
|
|
96
|
+
<v-toolbar density="compact" class="pl-4">
|
|
97
|
+
<span class="font-weight-medium text-h5">Delete Subject</span>
|
|
98
|
+
</v-toolbar>
|
|
99
|
+
|
|
100
|
+
<v-card-text>
|
|
101
|
+
<p class="text-subtitle-2 text-center">
|
|
102
|
+
Are you sure you want to delete this subject? This action cannot be
|
|
103
|
+
undone.
|
|
104
|
+
</p>
|
|
105
|
+
|
|
106
|
+
<v-row v-if="message" no-gutters justify="center" class="mt-4">
|
|
107
|
+
<span class="text-caption text-error text-center">
|
|
108
|
+
{{ message }}
|
|
109
|
+
</span>
|
|
110
|
+
</v-row>
|
|
111
|
+
</v-card-text>
|
|
112
|
+
|
|
113
|
+
<v-toolbar density="compact">
|
|
114
|
+
<v-row no-gutters>
|
|
115
|
+
<v-col cols="6">
|
|
116
|
+
<v-btn
|
|
117
|
+
tile
|
|
118
|
+
block
|
|
119
|
+
size="48"
|
|
120
|
+
variant="text"
|
|
121
|
+
class="text-none"
|
|
122
|
+
@click="dialogDelete = false"
|
|
123
|
+
:disabled="loadingDelete"
|
|
124
|
+
>
|
|
125
|
+
Cancel
|
|
126
|
+
</v-btn>
|
|
127
|
+
</v-col>
|
|
128
|
+
<v-col cols="6">
|
|
129
|
+
<v-btn
|
|
130
|
+
tile
|
|
131
|
+
block
|
|
132
|
+
size="48"
|
|
133
|
+
color="black"
|
|
134
|
+
variant="flat"
|
|
135
|
+
class="text-none"
|
|
136
|
+
@click="submitDelete()"
|
|
137
|
+
:loading="loadingDelete"
|
|
138
|
+
>
|
|
139
|
+
Delete Subject
|
|
140
|
+
</v-btn>
|
|
141
|
+
</v-col>
|
|
142
|
+
</v-row>
|
|
143
|
+
</v-toolbar>
|
|
144
|
+
</v-card>
|
|
145
|
+
</v-dialog>
|
|
146
|
+
</v-row>
|
|
147
|
+
</template>
|
|
148
|
+
|
|
149
|
+
<script setup lang="ts">
|
|
150
|
+
const localProps = defineProps({
|
|
151
|
+
status: {
|
|
152
|
+
type: String,
|
|
153
|
+
default: "active",
|
|
154
|
+
required: true,
|
|
155
|
+
},
|
|
156
|
+
canAdd: {
|
|
157
|
+
type: Boolean,
|
|
158
|
+
default: false,
|
|
159
|
+
},
|
|
160
|
+
canEdit: {
|
|
161
|
+
type: Boolean,
|
|
162
|
+
default: false,
|
|
163
|
+
},
|
|
164
|
+
canDelete: {
|
|
165
|
+
type: Boolean,
|
|
166
|
+
default: false,
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const headers = [
|
|
171
|
+
{
|
|
172
|
+
title: "Subject Name",
|
|
173
|
+
value: "subjectName",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
title: "Subject Code",
|
|
177
|
+
value: "subjectCode",
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
title: "Curriculum",
|
|
181
|
+
value: "curriculumName",
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
title: "Grade Level",
|
|
185
|
+
value: "gradeLevel",
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
title: "Session Per Week",
|
|
189
|
+
value: "sessionFrequency",
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
title: "Session Duration",
|
|
193
|
+
value: "sessionDuration",
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
title: "Session Per Week",
|
|
197
|
+
value: "totalMinutesPerWeek",
|
|
198
|
+
},
|
|
199
|
+
];
|
|
200
|
+
|
|
201
|
+
const page = ref(1);
|
|
202
|
+
const pages = ref(0);
|
|
203
|
+
const pageRange = ref("-- - -- of --");
|
|
204
|
+
|
|
205
|
+
const items = ref<Array<Record<string, any>>>([]);
|
|
206
|
+
|
|
207
|
+
const { getAll, deleteById } = useCurriculumSubject();
|
|
208
|
+
|
|
209
|
+
const { data: getCurriculumReq, refresh: refreshCurriculumItems } =
|
|
210
|
+
await useLazyAsyncData(
|
|
211
|
+
`subject-subjects-page-${page.value}-${localProps.status}`,
|
|
212
|
+
() =>
|
|
213
|
+
getAll({
|
|
214
|
+
page: page.value,
|
|
215
|
+
limit: 20,
|
|
216
|
+
status: localProps.status,
|
|
217
|
+
}),
|
|
218
|
+
{
|
|
219
|
+
watch: [page, () => localProps.status],
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
watchEffect(() => {
|
|
224
|
+
if (getCurriculumReq.value) {
|
|
225
|
+
items.value = getCurriculumReq.value.items;
|
|
226
|
+
pages.value = getCurriculumReq.value.pages;
|
|
227
|
+
pageRange.value = getCurriculumReq.value.pageRange;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
const subject = ref<TCurriculum>();
|
|
232
|
+
|
|
233
|
+
function tableRowClickHandler(_: any, data: any) {
|
|
234
|
+
dialogView.value = true;
|
|
235
|
+
subject.value = data.item;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const dialogCreate = ref(false);
|
|
239
|
+
const dialogView = ref(false);
|
|
240
|
+
|
|
241
|
+
function successHandler() {
|
|
242
|
+
dialogCreate.value = false;
|
|
243
|
+
refreshCurriculumItems();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const dialogUpdate = ref(false);
|
|
247
|
+
|
|
248
|
+
function handleEdit() {
|
|
249
|
+
dialogView.value = false;
|
|
250
|
+
dialogUpdate.value = true;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const dialogDelete = ref(false);
|
|
254
|
+
const loadingDelete = ref(false);
|
|
255
|
+
const message = ref("");
|
|
256
|
+
|
|
257
|
+
async function submitDelete() {
|
|
258
|
+
loadingDelete.value = true;
|
|
259
|
+
message.value = "";
|
|
260
|
+
try {
|
|
261
|
+
if (subject.value && subject.value._id) {
|
|
262
|
+
await deleteById(subject.value._id);
|
|
263
|
+
dialogDelete.value = false;
|
|
264
|
+
dialogView.value = false;
|
|
265
|
+
refreshCurriculumItems();
|
|
266
|
+
}
|
|
267
|
+
} catch (error: any) {
|
|
268
|
+
message.value = error.response._data.message;
|
|
269
|
+
} finally {
|
|
270
|
+
loadingDelete.value = false;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
</script>
|