adminforth 1.3.55-next.0 → 1.3.55
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/dist/spa/.eslintrc.cjs +14 -0
- package/dist/spa/README.md +39 -0
- package/dist/spa/env.d.ts +1 -0
- package/dist/spa/index.html +23 -0
- package/dist/spa/package-lock.json +4659 -0
- package/dist/spa/package.json +52 -0
- package/dist/spa/postcss.config.js +6 -0
- package/dist/spa/public/assets/favicon.png +0 -0
- package/dist/spa/src/App.vue +418 -0
- package/dist/spa/src/assets/base.css +2 -0
- package/dist/spa/src/assets/logo.svg +19 -0
- package/dist/spa/src/components/AcceptModal.vue +45 -0
- package/dist/spa/src/components/Breadcrumbs.vue +41 -0
- package/dist/spa/src/components/BreadcrumbsWithButtons.vue +26 -0
- package/dist/spa/src/components/CustomDatePicker.vue +176 -0
- package/dist/spa/src/components/CustomDateRangePicker.vue +218 -0
- package/dist/spa/src/components/CustomRangePicker.vue +156 -0
- package/dist/spa/src/components/Dropdown.vue +168 -0
- package/dist/spa/src/components/Filters.vue +222 -0
- package/dist/spa/src/components/HelloWorld.vue +17 -0
- package/dist/spa/src/components/MenuLink.vue +27 -0
- package/dist/spa/src/components/ResourceForm.vue +325 -0
- package/dist/spa/src/components/ResourceListTable.vue +466 -0
- package/dist/spa/src/components/SingleSkeletLoader.vue +13 -0
- package/dist/spa/src/components/SkeleteLoader.vue +23 -0
- package/dist/spa/src/components/ThreeDotsMenu.vue +43 -0
- package/dist/spa/src/components/Toast.vue +78 -0
- package/dist/spa/src/components/ValueRenderer.vue +141 -0
- package/dist/spa/src/components/icons/IconCalendar.vue +5 -0
- package/dist/spa/src/components/icons/IconCommunity.vue +7 -0
- package/dist/spa/src/components/icons/IconDocumentation.vue +7 -0
- package/dist/spa/src/components/icons/IconEcosystem.vue +7 -0
- package/dist/spa/src/components/icons/IconSupport.vue +7 -0
- package/dist/spa/src/components/icons/IconTime.vue +5 -0
- package/dist/spa/src/components/icons/IconTooling.vue +19 -0
- package/dist/spa/src/composables/useFrontendApi.ts +26 -0
- package/dist/spa/src/composables/useStores.ts +131 -0
- package/dist/spa/src/index.scss +31 -0
- package/dist/spa/src/main.ts +18 -0
- package/dist/spa/src/renderers/CompactUUID.vue +48 -0
- package/dist/spa/src/renderers/CountryFlag.vue +69 -0
- package/dist/spa/src/router/index.ts +59 -0
- package/dist/spa/src/spa_types/core.ts +53 -0
- package/dist/spa/src/stores/core.ts +148 -0
- package/dist/spa/src/stores/filters.ts +27 -0
- package/dist/spa/src/stores/modal.ts +48 -0
- package/dist/spa/src/stores/toast.ts +31 -0
- package/dist/spa/src/stores/user.ts +72 -0
- package/dist/spa/src/types/AdminForthConfig.ts +1762 -0
- package/dist/spa/src/types/FrontendAPI.ts +143 -0
- package/dist/spa/src/utils.ts +160 -0
- package/dist/spa/src/views/CreateView.vue +167 -0
- package/dist/spa/src/views/EditView.vue +170 -0
- package/dist/spa/src/views/ListView.vue +352 -0
- package/dist/spa/src/views/LoginView.vue +192 -0
- package/dist/spa/src/views/ResourceParent.vue +17 -0
- package/dist/spa/src/views/ShowView.vue +194 -0
- package/dist/spa/tailwind.config.js +17 -0
- package/dist/spa/tsconfig.app.json +14 -0
- package/dist/spa/tsconfig.json +11 -0
- package/dist/spa/tsconfig.node.json +19 -0
- package/dist/spa/vite.config.ts +56 -0
- package/package.json +2 -2
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- table -->
|
|
3
|
+
<div class="relative overflow-x-auto shadow-listTableShadow dark:shadow-darkListTableShadow overflow-y-hidden"
|
|
4
|
+
:class="{'rounded-default': !noRoundings}"
|
|
5
|
+
>
|
|
6
|
+
<!-- skelet loader -->
|
|
7
|
+
<div role="status" v-if="!resource || !resource.columns"
|
|
8
|
+
class="max-w p-4 space-y-4 divide-y divide-gray-200 rounded shadow animate-pulse dark:divide-gray-700 md:p-6 dark:border-gray-700">
|
|
9
|
+
|
|
10
|
+
<div role="status" class="max-w-sm animate-pulse">
|
|
11
|
+
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px]"></div>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<table v-else class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 rounded-default">
|
|
16
|
+
<thead class="text-xs text-view-table-heading-text bg-lightListTableHeading dark:bg-darkListTableHeading dark:text-gray-400">
|
|
17
|
+
<tr>
|
|
18
|
+
<th scope="col" class="p-4">
|
|
19
|
+
<div v-if="rows && rows.length" class="flex items-center">
|
|
20
|
+
<input id="checkbox-all-search" type="checkbox" :checked="allFromThisPageChecked" @change="selectAll()"
|
|
21
|
+
class="w-4 h-4 cursor-pointer text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 dark:focus:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
|
|
22
|
+
<label for="checkbox-all-search" class="sr-only">checkbox</label>
|
|
23
|
+
</div>
|
|
24
|
+
</th>
|
|
25
|
+
|
|
26
|
+
<th v-for="c in columnsListed" scope="col" class="px-2 md:px-3 lg:px-6 py-3">
|
|
27
|
+
|
|
28
|
+
<div @click="(evt) => c.sortable && onSortButtonClick(evt, c.name)"
|
|
29
|
+
class="flex items-center " :class="{'cursor-pointer':c.sortable}">
|
|
30
|
+
{{ c.label }}
|
|
31
|
+
|
|
32
|
+
<div v-if="c.sortable"
|
|
33
|
+
:style="{ 'color':ascArr.includes(c.name)?'green':descArr.includes(c.name)?'red':'currentColor'}">
|
|
34
|
+
<svg v-if="ascArr.includes(c.name) || descArr.includes(c.name)" class="w-3 h-3 ms-1.5"
|
|
35
|
+
:class="{'rotate-180':descArr.includes(c.name)}" viewBox="0 0 24 24">
|
|
36
|
+
<path
|
|
37
|
+
d="M8.574 11.024h6.852a2.075 2.075 0 0 0 1.847-1.086 1.9 1.9 0 0 0-.11-1.986L13.736 2.9a2.122 2.122 0 0 0-3.472 0L6.837 7.952a1.9 1.9 0 0 0-.11 1.986 2.074 2.074 0 0 0 1.847"/>
|
|
38
|
+
</svg>
|
|
39
|
+
<svg v-else class="w-3 h-3 ms-1.5 opacity-30" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
|
|
40
|
+
fill='currentColor'
|
|
41
|
+
viewBox="0 0 24 24">
|
|
42
|
+
<path
|
|
43
|
+
d="M8.574 11.024h6.852a2.075 2.075 0 0 0 1.847-1.086 1.9 1.9 0 0 0-.11-1.986L13.736 2.9a2.122 2.122 0 0 0-3.472 0L6.837 7.952a1.9 1.9 0 0 0-.11 1.986 2.074 2.074 0 0 0 1.847 1.086Zm6.852 1.952H8.574a2.072 2.072 0 0 0-1.847 1.087 1.9 1.9 0 0 0 .11 1.985l3.426 5.05a2.123 2.123 0 0 0 3.472 0l3.427-5.05a1.9 1.9 0 0 0 .11-1.985 2.074 2.074 0 0 0-1.846-1.087Z"/>
|
|
44
|
+
</svg>
|
|
45
|
+
</div>
|
|
46
|
+
<span
|
|
47
|
+
class="bg-red-100 text-red-800 text-xs font-medium me-1 px-1 py-0.5 rounded dark:bg-gray-700 dark:text-red-400 border border-red-400"
|
|
48
|
+
v-if="sort.findIndex((s) => s.field === c.name) !== -1 && sort?.length > 1">
|
|
49
|
+
{{ sort.findIndex((s) => s.field === c.name) + 1 }}
|
|
50
|
+
</span>
|
|
51
|
+
|
|
52
|
+
</div>
|
|
53
|
+
</th>
|
|
54
|
+
|
|
55
|
+
<th scope="col" class="px-6 py-3">
|
|
56
|
+
Actions
|
|
57
|
+
</th>
|
|
58
|
+
</tr>
|
|
59
|
+
</thead>
|
|
60
|
+
<tbody>
|
|
61
|
+
<SkeleteLoader
|
|
62
|
+
v-if="!rows"
|
|
63
|
+
:columns="resource?.columns.filter(c => c.showIn.includes('list')).length + 2"
|
|
64
|
+
:rows="3"
|
|
65
|
+
/>
|
|
66
|
+
<tr v-else-if="rows.length === 0" class="bg-lightListTable dark:bg-darkListTable dark:border-darkListTableBorder">
|
|
67
|
+
<td :colspan="resource?.columns.length + 2">
|
|
68
|
+
|
|
69
|
+
<div id="toast-simple"
|
|
70
|
+
class=" mx-auto my-5 flex items-center w-full max-w-xs p-4 space-x-4 rtl:space-x-reverse text-gray-500 divide-x rtl:divide-x-reverse divide-gray-200 dark:text-gray-400 dark:divide-gray-700 space-x dark:bg-gray-800"
|
|
71
|
+
role="alert">
|
|
72
|
+
<IconInboxOutline class="w-6 h-6 text-gray-500 dark:text-gray-400"/>
|
|
73
|
+
<div class="ps-4 text-sm font-normal">No items here yet</div>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
</td>
|
|
77
|
+
</tr>
|
|
78
|
+
|
|
79
|
+
<tr @click="onClick($event,row)"
|
|
80
|
+
v-else v-for="(row, rowI) in rows" :key="`row_${row._primaryKeyValue}`"
|
|
81
|
+
class="bg-lightListTable dark:bg-darkListTable border-lightListBorder dark:border-gray-700 hover:bg-lightListTableRowHover dark:hover:bg-darkListTableRowHover"
|
|
82
|
+
|
|
83
|
+
:class="{'border-b': rowI !== rows.length - 1, 'cursor-pointer': row._clickUrl !== null}"
|
|
84
|
+
>
|
|
85
|
+
<td class="w-4 p-4 cursor-default" @click="(e)=>{e.stopPropagation()}">
|
|
86
|
+
<div class="flex items center ">
|
|
87
|
+
<input
|
|
88
|
+
@click="(e)=>{e.stopPropagation()}"
|
|
89
|
+
id="checkbox-table-search-1"
|
|
90
|
+
type="checkbox"
|
|
91
|
+
:checked="checkboxesInternal.includes(row._primaryKeyValue)"
|
|
92
|
+
@change="(e)=>{addToCheckedValues(row._primaryKeyValue)}"
|
|
93
|
+
class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 dark:focus:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600 cursor-pointer">
|
|
94
|
+
<label for="checkbox-table-search-1" class="sr-only">checkbox</label>
|
|
95
|
+
</div>
|
|
96
|
+
</td>
|
|
97
|
+
<td v-for="c in columnsListed" class="px-2 md:px-3 lg:px-6 py-4">
|
|
98
|
+
<!-- if c.name in listComponentsPerColumn, render it. If not, render ValueRenderer -->
|
|
99
|
+
<component
|
|
100
|
+
:is="c?.components?.list ? getCustomComponent(c.components.list) : ValueRenderer"
|
|
101
|
+
:meta="c?.components?.list?.meta"
|
|
102
|
+
:column="c"
|
|
103
|
+
:record="row"
|
|
104
|
+
:adminUser="coreStore.adminUser"
|
|
105
|
+
:resource="resource"
|
|
106
|
+
/>
|
|
107
|
+
</td>
|
|
108
|
+
<td class=" items-center px-2 md:px-3 lg:px-6 py-4 cursor-default" @click="(e)=>{e.stopPropagation()}">
|
|
109
|
+
<div class="flex">
|
|
110
|
+
<RouterLink
|
|
111
|
+
v-if="resource.options?.allowedActions.show"
|
|
112
|
+
:to="{
|
|
113
|
+
name: 'resource-show',
|
|
114
|
+
params: {
|
|
115
|
+
resourceId: resource.resourceId,
|
|
116
|
+
primaryKey: row._primaryKeyValue,
|
|
117
|
+
}
|
|
118
|
+
}"
|
|
119
|
+
class="font-medium text-lightPrimary dark:text-darkPrimary hover:underline"
|
|
120
|
+
:data-tooltip-target="`tooltip-show-${rowI}`"
|
|
121
|
+
>
|
|
122
|
+
<IconEyeSolid class="w-5 h-5 me-2"/>
|
|
123
|
+
</RouterLink>
|
|
124
|
+
|
|
125
|
+
<div :id="`tooltip-show-${rowI}`"
|
|
126
|
+
role="tooltip"
|
|
127
|
+
class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white transition-opacity duration-300 bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700">
|
|
128
|
+
Show item
|
|
129
|
+
<div class="tooltip-arrow" data-popper-arrow></div>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<RouterLink v-if="resource.options?.allowedActions.edit"
|
|
133
|
+
:to="{
|
|
134
|
+
name: 'resource-edit',
|
|
135
|
+
params: {
|
|
136
|
+
resourceId: resource.resourceId,
|
|
137
|
+
primaryKey: row._primaryKeyValue
|
|
138
|
+
}
|
|
139
|
+
}"
|
|
140
|
+
class="font-medium text-lightPrimary dark:text-darkPrimary hover:underline ms-3"
|
|
141
|
+
:data-tooltip-target="`tooltip-edit-${rowI}`"
|
|
142
|
+
>
|
|
143
|
+
<IconPenSolid class="w-5 h-5 me-2"/>
|
|
144
|
+
</RouterLink>
|
|
145
|
+
|
|
146
|
+
<div :id="`tooltip-edit-${rowI}`"
|
|
147
|
+
role="tooltip"
|
|
148
|
+
class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white transition-opacity duration-300 bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700">
|
|
149
|
+
Edit
|
|
150
|
+
<div class="tooltip-arrow" data-popper-arrow></div>
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
<button v-if="resource.options?.allowedActions.delete"
|
|
154
|
+
class="font-medium text-lightPrimary dark:text-darkPrimary hover:underline ms-3"
|
|
155
|
+
:data-tooltip-target="`tooltip-delete-${rowI}`"
|
|
156
|
+
@click="deleteRecord(row)"
|
|
157
|
+
>
|
|
158
|
+
<IconTrashBinSolid class="w-5 h-5 me-2"/>
|
|
159
|
+
</button>
|
|
160
|
+
|
|
161
|
+
<div :id="`tooltip-delete-${rowI}`"
|
|
162
|
+
role="tooltip"
|
|
163
|
+
class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white transition-opacity duration-300 bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700">
|
|
164
|
+
Delete
|
|
165
|
+
<div class="tooltip-arrow" data-popper-arrow></div>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
<template v-if="coreStore.resourceOptions?.pageInjections?.list?.customActionIcons">
|
|
170
|
+
<component
|
|
171
|
+
v-for="c in coreStore.resourceOptions?.pageInjections?.list?.customActionIcons"
|
|
172
|
+
:is="getCustomComponent(c)"
|
|
173
|
+
:meta="c.meta"
|
|
174
|
+
:resource="coreStore.resource"
|
|
175
|
+
:adminUser="coreStore.adminUser"
|
|
176
|
+
:record="row"
|
|
177
|
+
/>
|
|
178
|
+
</template>
|
|
179
|
+
</div>
|
|
180
|
+
</td>
|
|
181
|
+
</tr>
|
|
182
|
+
</tbody>
|
|
183
|
+
</table>
|
|
184
|
+
</div>
|
|
185
|
+
<!-- pagination
|
|
186
|
+
totalRows in v-if is used to not hide page input during loading when user puts cursor into it and edit directly (rows gets null there during edit)
|
|
187
|
+
-->
|
|
188
|
+
<div class="flex flex-col items-center mt-4 mb-4 xs:flex-row xs:justify-between xs:items-center"
|
|
189
|
+
v-if="(rows || totalRows) && totalRows >= pageSize && totalRows > 0"
|
|
190
|
+
>
|
|
191
|
+
<!-- Help text -->
|
|
192
|
+
<span class="text-sm text-gray-700 dark:text-gray-400">
|
|
193
|
+
Showing <span class="font-semibold text-gray-900 dark:text-white">
|
|
194
|
+
{{ ((page || 1) - 1) * pageSize + 1 }}
|
|
195
|
+
</span> to <span class="font-semibold text-gray-900 dark:text-white">
|
|
196
|
+
{{ Math.min((page || 1) * pageSize, totalRows) }}
|
|
197
|
+
</span> of <span class="font-semibold text-gray-900 dark:text-white">{{
|
|
198
|
+
totalRows
|
|
199
|
+
}}</span> Entries
|
|
200
|
+
</span>
|
|
201
|
+
<div class="inline-flex mt-2 xs:mt-0">
|
|
202
|
+
<!-- Buttons -->
|
|
203
|
+
<button
|
|
204
|
+
class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white border-r-0 rounded-s border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
|
|
205
|
+
@click="page--" :disabled="page <= 1">
|
|
206
|
+
<svg class="w-3.5 h-3.5 me-2 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
|
207
|
+
viewBox="0 0 14 10">
|
|
208
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
209
|
+
d="M13 5H1m0 0 4 4M1 5l4-4"/>
|
|
210
|
+
</svg>
|
|
211
|
+
Prev
|
|
212
|
+
</button>
|
|
213
|
+
<button
|
|
214
|
+
class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white border-r-0 border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
|
|
215
|
+
@click="page = 1" :disabled="page <= 1">
|
|
216
|
+
<!-- <IconChevronDoubleLeftOutline class="w-4 h-4" /> -->
|
|
217
|
+
1
|
|
218
|
+
</button>
|
|
219
|
+
<div
|
|
220
|
+
contenteditable="true"
|
|
221
|
+
class="min-w-10 outline-none inline-block w-auto min-w-10 py-1.5 px-3 text-sm text-center text-gray-700 border border-gray-300 dark:border-gray-700 dark:text-gray-400 dark:bg-gray-800 z-10"
|
|
222
|
+
@input="page = parseInt($event.target.innerText) || ''"
|
|
223
|
+
>
|
|
224
|
+
{{ page }}
|
|
225
|
+
</div>
|
|
226
|
+
|
|
227
|
+
<button
|
|
228
|
+
class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white border-l-0 border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
|
|
229
|
+
@click="page = totalPages" :disabled="page >= totalPages">
|
|
230
|
+
{{ totalPages }}
|
|
231
|
+
|
|
232
|
+
<!-- <IconChevronDoubleRightOutline class="w-4 h-4" /> -->
|
|
233
|
+
</button>
|
|
234
|
+
<button
|
|
235
|
+
class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white border-l-0 rounded-e border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
|
|
236
|
+
|
|
237
|
+
@click="page++" :disabled="page >= totalPages">
|
|
238
|
+
Next
|
|
239
|
+
<svg class="w-3.5 h-3.5 ms-2 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
|
240
|
+
viewBox="0 0 14 10">
|
|
241
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
242
|
+
d="M1 5h12m0 0L9 1m4 4L9 9"/>
|
|
243
|
+
</svg>
|
|
244
|
+
</button>
|
|
245
|
+
</div>
|
|
246
|
+
|
|
247
|
+
</div>
|
|
248
|
+
</template>
|
|
249
|
+
|
|
250
|
+
<script setup>
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
import { computed, onMounted, ref, watch } from 'vue';
|
|
254
|
+
import { callAdminForthApi } from '@/utils';
|
|
255
|
+
|
|
256
|
+
import ValueRenderer from '@/components/ValueRenderer.vue';
|
|
257
|
+
import { getCustomComponent } from '@/utils';
|
|
258
|
+
import { useCoreStore } from '@/stores/core';
|
|
259
|
+
import { showSuccesTost, showErrorTost } from '@/composables/useFrontendApi';
|
|
260
|
+
import SkeleteLoader from '@/components/SkeleteLoader.vue';
|
|
261
|
+
|
|
262
|
+
import {
|
|
263
|
+
IconInboxOutline,
|
|
264
|
+
} from '@iconify-prerendered/vue-flowbite';
|
|
265
|
+
|
|
266
|
+
import {
|
|
267
|
+
IconEyeSolid,
|
|
268
|
+
IconPenSolid,
|
|
269
|
+
IconTrashBinSolid
|
|
270
|
+
} from '@iconify-prerendered/vue-flowbite';
|
|
271
|
+
import router from '@/router';
|
|
272
|
+
|
|
273
|
+
const coreStore = useCoreStore();
|
|
274
|
+
|
|
275
|
+
const props = defineProps([
|
|
276
|
+
'page',
|
|
277
|
+
'resource',
|
|
278
|
+
'rows',
|
|
279
|
+
'totalRows',
|
|
280
|
+
'pageSize',
|
|
281
|
+
'checkboxes',
|
|
282
|
+
'sort',
|
|
283
|
+
'noRoundings'
|
|
284
|
+
])
|
|
285
|
+
|
|
286
|
+
// emits, update page
|
|
287
|
+
const emits = defineEmits([
|
|
288
|
+
'update:page',
|
|
289
|
+
'update:sort',
|
|
290
|
+
'update:checkboxes',
|
|
291
|
+
'update:records'
|
|
292
|
+
|
|
293
|
+
]);
|
|
294
|
+
|
|
295
|
+
const checkboxesInternal = ref([]);
|
|
296
|
+
const page = ref(1);
|
|
297
|
+
const sort = ref([]);
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
watch(() => page.value, (newPage) => {
|
|
302
|
+
emits('update:page', newPage);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
watch(() => sort.value, (newSort) => {
|
|
306
|
+
emits('update:sort', newSort);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
watch(() => checkboxesInternal.value, (newCheckboxes) => {
|
|
310
|
+
console.log('checkboxesInternal ch changed, emiting', newCheckboxes)
|
|
311
|
+
|
|
312
|
+
emits('update:checkboxes', newCheckboxes);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
watch(() => props.checkboxes, (newCheckboxes) => {
|
|
316
|
+
console.log('Props ch changed', newCheckboxes)
|
|
317
|
+
checkboxesInternal.value = newCheckboxes;
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
watch(() => props.sort, (newSort) => {
|
|
321
|
+
sort.value = newSort;
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
watch(() => props.page, (newPage) => {
|
|
325
|
+
page.value = newPage;
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
function addToCheckedValues(id) {
|
|
329
|
+
console.log('checking', checkboxesInternal.value, 'id', id)
|
|
330
|
+
if (checkboxesInternal.value.includes(id)) {
|
|
331
|
+
checkboxesInternal.value = checkboxesInternal.value.filter((item) => item !== id);
|
|
332
|
+
} else {
|
|
333
|
+
checkboxesInternal.value.push(id);
|
|
334
|
+
}
|
|
335
|
+
checkboxesInternal.value = [ ...checkboxesInternal.value ]
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const columnsListed = computed(() => props.resource?.columns?.filter(c => c.showIn.includes('list')));
|
|
339
|
+
|
|
340
|
+
async function selectAll(value) {
|
|
341
|
+
if (!allFromThisPageChecked.value) {
|
|
342
|
+
props.rows.forEach((r) => {
|
|
343
|
+
if (!checkboxesInternal.value.includes(r._primaryKeyValue)) {
|
|
344
|
+
checkboxesInternal.value.push(r._primaryKeyValue)
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
} else {
|
|
348
|
+
props.rows.forEach((r) => {
|
|
349
|
+
checkboxesInternal.value = checkboxesInternal.value.filter((item) => item !== r._primaryKeyValue);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
checkboxesInternal.value = [ ...checkboxesInternal.value ];
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const totalPages = computed(() => Math.ceil(props.totalRows / props.pageSize));
|
|
356
|
+
|
|
357
|
+
const allFromThisPageChecked = computed(() => {
|
|
358
|
+
if (!props.rows) return false;
|
|
359
|
+
return props.rows.every((r) => checkboxesInternal.value.includes(r._primaryKeyValue));
|
|
360
|
+
});
|
|
361
|
+
const ascArr = computed(() => sort.value.filter((s) => s.direction === 'asc').map((s) => s.field));
|
|
362
|
+
const descArr = computed(() => sort.value.filter((s) => s.direction === 'desc').map((s) => s.field));
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
function onSortButtonClick(event, field) {
|
|
366
|
+
// if ctrl key is pressed, add to sort otherwise sort by this field
|
|
367
|
+
// in any case if field is already in sort, toggle direction
|
|
368
|
+
|
|
369
|
+
const sortIndex = sort.value.findIndex((s) => s.field === field);
|
|
370
|
+
if (sortIndex === -1) {
|
|
371
|
+
// field is not in sort, add it
|
|
372
|
+
if (event.ctrlKey) {
|
|
373
|
+
sort.value = [...sort.value,{field, direction: 'asc'}];
|
|
374
|
+
} else {
|
|
375
|
+
sort.value = [{field, direction: 'asc'}];
|
|
376
|
+
}
|
|
377
|
+
} else {
|
|
378
|
+
const sortField = sort.value[sortIndex];
|
|
379
|
+
if (sortField.direction === 'asc') {
|
|
380
|
+
sort.value[sortIndex].direction = 'desc';
|
|
381
|
+
} else {
|
|
382
|
+
sort.value.splice(sortIndex, 1);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
const clickTarget = ref(null);
|
|
389
|
+
|
|
390
|
+
async function onClick(e,row) {
|
|
391
|
+
if(clickTarget.value === e.target) return;
|
|
392
|
+
clickTarget.value = e.target;
|
|
393
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
394
|
+
if (window.getSelection().toString()) return;
|
|
395
|
+
else {
|
|
396
|
+
if (row._clickUrl === null) {
|
|
397
|
+
// user asked to nothing on click
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (e.ctrlKey || e.metaKey || row._clickUrl?.includes('target=_blank')) {
|
|
401
|
+
|
|
402
|
+
if (row._clickUrl) {
|
|
403
|
+
window.open(row._clickUrl, '_blank');
|
|
404
|
+
} else {
|
|
405
|
+
window.open(
|
|
406
|
+
router.resolve({
|
|
407
|
+
name: 'resource-show',
|
|
408
|
+
params: {
|
|
409
|
+
resourceId: props.resource.resourceId,
|
|
410
|
+
primaryKey: row._primaryKeyValue,
|
|
411
|
+
},
|
|
412
|
+
}).fullPath,
|
|
413
|
+
'_blank'
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
} else {
|
|
417
|
+
if (row._clickUrl) {
|
|
418
|
+
if (row._clickUrl.startsWith('http')) {
|
|
419
|
+
document.location.href = row._clickUrl;
|
|
420
|
+
} else {
|
|
421
|
+
router.push(row._clickUrl);
|
|
422
|
+
}
|
|
423
|
+
} else {
|
|
424
|
+
router.push({
|
|
425
|
+
name: 'resource-show',
|
|
426
|
+
params: {
|
|
427
|
+
resourceId: props.resource.resourceId,
|
|
428
|
+
primaryKey: row._primaryKeyValue,
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
async function deleteRecord(row) {
|
|
437
|
+
const data = await window.adminforth.confirm({
|
|
438
|
+
message: 'Are you sure you want to delete this item?',
|
|
439
|
+
yes: 'Delete',
|
|
440
|
+
no: 'Cancel',
|
|
441
|
+
});
|
|
442
|
+
if (data) {
|
|
443
|
+
try {
|
|
444
|
+
const res = await callAdminForthApi({
|
|
445
|
+
path: '/delete_record',
|
|
446
|
+
method: 'POST',
|
|
447
|
+
body: {
|
|
448
|
+
resourceId: props.resource.resourceId,
|
|
449
|
+
primaryKey: row._primaryKeyValue,
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
console.log('safsa', res)
|
|
453
|
+
if (!res.error){
|
|
454
|
+
emits('update:records', true)
|
|
455
|
+
showSuccesTost('Record deleted successfully')
|
|
456
|
+
} else {
|
|
457
|
+
showErrorTost(res.error)
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
} catch (e) {
|
|
461
|
+
showErrorTost(`Something went wrong, please try again later`);
|
|
462
|
+
console.error(e);
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
role="status" class="max-w-sm animate-pulse"
|
|
4
|
+
>
|
|
5
|
+
<div class="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4"></div>
|
|
6
|
+
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px] mb-2.5"></div>
|
|
7
|
+
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 mb-2.5"></div>
|
|
8
|
+
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[330px] mb-2.5"></div>
|
|
9
|
+
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[300px] mb-2.5"></div>
|
|
10
|
+
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px]"></div>
|
|
11
|
+
<span class="sr-only">Loading...</span>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<tr v-for="c in new Array(props.rows)" class="bg-lightListTable border-b dark:bg-darkListTable dark:border-darkListBorder">
|
|
3
|
+
<td v-for="r in new Array(props.columns)" class="items-center px-6 py-8 cursor-default" >
|
|
4
|
+
<div role="status" class="max-w-sm animate-pulse">
|
|
5
|
+
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px]"></div>
|
|
6
|
+
</div>
|
|
7
|
+
</td>
|
|
8
|
+
</tr>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script setup>
|
|
12
|
+
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
columns: Number,
|
|
15
|
+
rows: Number
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<style lang="scss" scoped>
|
|
22
|
+
|
|
23
|
+
</style>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template >
|
|
2
|
+
<template v-if="threeDotsDropdownItems?.length">
|
|
3
|
+
<button
|
|
4
|
+
data-dropdown-toggle="listThreeDotsDropdown"
|
|
5
|
+
class="flex items-center py-2 px-2 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 rounded-default"
|
|
6
|
+
>
|
|
7
|
+
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 4 15">
|
|
8
|
+
<path d="M3.5 1.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm0 6.041a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm0 5.959a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Z"/>
|
|
9
|
+
</svg>
|
|
10
|
+
</button>
|
|
11
|
+
|
|
12
|
+
<!-- Dropdown menu -->
|
|
13
|
+
<div
|
|
14
|
+
id="listThreeDotsDropdown"
|
|
15
|
+
class="z-10 hidden bg-white divide-y divide-gray-100 rounded-lg shadow w-44 dark:bg-gray-700 dark:divide-gray-600">
|
|
16
|
+
<ul class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdownMenuIconButton">
|
|
17
|
+
<li v-for="item in threeDotsDropdownItems" :key="`dropdown-item-${item.label}`">
|
|
18
|
+
<a href="#" class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
|
|
19
|
+
<component :is="getCustomComponent(item)"
|
|
20
|
+
:meta="item.meta"
|
|
21
|
+
:resource="coreStore.resource"
|
|
22
|
+
:adminUser="coreStore.adminUser"
|
|
23
|
+
/>
|
|
24
|
+
</a>
|
|
25
|
+
</li>
|
|
26
|
+
</ul>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<script setup lang="ts">
|
|
33
|
+
|
|
34
|
+
import { getCustomComponent } from '@/utils';
|
|
35
|
+
import { useCoreStore } from '@/stores/core'
|
|
36
|
+
|
|
37
|
+
const coreStore = useCoreStore()
|
|
38
|
+
|
|
39
|
+
const props = defineProps<{
|
|
40
|
+
threeDotsDropdownItems: any[] | undefined
|
|
41
|
+
}>()
|
|
42
|
+
|
|
43
|
+
</script>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
<div class="flex items-center w-full p-4 text-gray-500 rounded-lg shadow-lg dark:text-gray-400 dark:bg-gray-800 bg-white"
|
|
5
|
+
role="alert"
|
|
6
|
+
:class="
|
|
7
|
+
{
|
|
8
|
+
'danger': 'bg-red-100',
|
|
9
|
+
}[toast.variant]
|
|
10
|
+
"
|
|
11
|
+
>
|
|
12
|
+
<div v-if="toast.variant == 'info'" class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-lightPrimary dark:text-darkPrimary bg-lightPrimaryOpacity rounded-lg dark:bg-blue-800 dark:text-blue-200">
|
|
13
|
+
<svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 20">
|
|
14
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.147 15.085a7.159 7.159 0 0 1-6.189 3.307A6.713 6.713 0 0 1 3.1 15.444c-2.679-4.513.287-8.737.888-9.548A4.373 4.373 0 0 0 5 1.608c1.287.953 6.445 3.218 5.537 10.5 1.5-1.122 2.706-3.01 2.853-6.14 1.433 1.049 3.993 5.395 1.757 9.117Z"/>
|
|
15
|
+
</svg>
|
|
16
|
+
<span class="sr-only">Fire icon</span>
|
|
17
|
+
</div>
|
|
18
|
+
<div v-else-if="toast.variant == 'danger'" class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-red-500 bg-red-100 rounded-lg dark:bg-red-800 dark:text-red-200">
|
|
19
|
+
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
20
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 11.793a1 1 0 1 1-1.414 1.414L10 11.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L8.586 10 6.293 7.707a1 1 0 0 1 1.414-1.414L10 8.586l2.293-2.293a1 1 0 0 1 1.414 1.414L11.414 10l2.293 2.293Z"/>
|
|
21
|
+
</svg>
|
|
22
|
+
<span class="sr-only">Error icon</span>
|
|
23
|
+
</div>
|
|
24
|
+
<div v-else-if="toast.variant == 'warning'"class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-orange-500 bg-orange-100 rounded-lg dark:bg-orange-700 dark:text-orange-200">
|
|
25
|
+
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
26
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM10 15a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-4a1 1 0 0 1-2 0V6a1 1 0 0 1 2 0v5Z"/>
|
|
27
|
+
</svg>
|
|
28
|
+
<span class="sr-only">Warning icon</span>
|
|
29
|
+
</div>
|
|
30
|
+
<div v-else class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-green-500 bg-green-100 rounded-lg dark:bg-green-800 dark:text-green-200">
|
|
31
|
+
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
32
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/>
|
|
33
|
+
</svg>
|
|
34
|
+
<span class="sr-only">Check icon</span>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div class="ms-3 text-sm font-normal max-w-xs pr-2" v-if="toast.messageHtml" v-html="toast.messageHtml"></div>
|
|
38
|
+
<div class="ms-3 text-sm font-normal max-w-xs pr-2" v-else>{{toast.message}}</div>
|
|
39
|
+
<button @click="closeToast" type="button" class="ms-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2 focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex items-center justify-center h-8 w-8 dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700" >
|
|
40
|
+
<svg class="w-3 h-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
|
41
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
|
42
|
+
</svg>
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<script setup lang="ts">
|
|
50
|
+
import { onMounted } from 'vue';
|
|
51
|
+
import { useToastStore } from '@/stores/toast';
|
|
52
|
+
const toastStore = useToastStore();
|
|
53
|
+
const emit = defineEmits(['close']);
|
|
54
|
+
const props = defineProps<{
|
|
55
|
+
toast: {
|
|
56
|
+
message?: string;
|
|
57
|
+
messageHtml?: string;
|
|
58
|
+
variant: string;
|
|
59
|
+
id: string;
|
|
60
|
+
timeout?: number|'unlimited';
|
|
61
|
+
}
|
|
62
|
+
}>();
|
|
63
|
+
function closeToast() {
|
|
64
|
+
emit('close');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
onMounted(() => {
|
|
68
|
+
if (props.toast.timeout === 'unlimited') return;
|
|
69
|
+
else {
|
|
70
|
+
setTimeout(() => {emit('close');}, (props.toast.timeout || 10) * 1e3 );
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<style lang="scss" scoped>
|
|
77
|
+
|
|
78
|
+
</style>
|