adminforth 1.6.2-next.3 → 1.6.2-next.5
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/index.d.ts.map +1 -1
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- 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 +5062 -0
- package/dist/spa/package.json +58 -0
- package/dist/spa/postcss.config.js +6 -0
- package/dist/spa/public/assets/favicon.png +0 -0
- package/dist/spa/src/App.vue +432 -0
- package/dist/spa/src/adminforth.ts +160 -0
- package/dist/spa/src/afcl/AreaChart.vue +160 -0
- package/dist/spa/src/afcl/BarChart.vue +170 -0
- package/dist/spa/src/afcl/Button.vue +27 -0
- package/dist/spa/src/afcl/Checkbox.vue +24 -0
- package/dist/spa/src/afcl/Dropzone.vue +128 -0
- package/dist/spa/src/afcl/Input.vue +41 -0
- package/dist/spa/src/afcl/Link.vue +17 -0
- package/dist/spa/src/afcl/LinkButton.vue +25 -0
- package/dist/spa/src/afcl/PieChart.vue +175 -0
- package/dist/spa/src/afcl/ProgressBar.vue +57 -0
- package/dist/spa/src/afcl/Select.vue +246 -0
- package/dist/spa/src/afcl/Skeleton.vue +26 -0
- package/dist/spa/src/afcl/Spinner.vue +9 -0
- package/dist/spa/src/afcl/Table.vue +116 -0
- package/dist/spa/src/afcl/Tooltip.vue +43 -0
- package/dist/spa/src/afcl/VerticalTabs.vue +49 -0
- package/dist/spa/src/afcl/index.ts +20 -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 +44 -0
- package/dist/spa/src/components/Breadcrumbs.vue +41 -0
- package/dist/spa/src/components/BreadcrumbsWithButtons.vue +25 -0
- package/dist/spa/src/components/CustomDatePicker.vue +180 -0
- package/dist/spa/src/components/CustomDateRangePicker.vue +218 -0
- package/dist/spa/src/components/CustomRangePicker.vue +156 -0
- package/dist/spa/src/components/Filters.vue +232 -0
- package/dist/spa/src/components/GroupsTable.vue +218 -0
- package/dist/spa/src/components/HelloWorld.vue +17 -0
- package/dist/spa/src/components/MenuLink.vue +41 -0
- package/dist/spa/src/components/ResourceForm.vue +260 -0
- package/dist/spa/src/components/ResourceListTable.vue +486 -0
- package/dist/spa/src/components/ShowTable.vue +81 -0
- package/dist/spa/src/components/SingleSkeletLoader.vue +13 -0
- package/dist/spa/src/components/SkeleteLoader.vue +18 -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 +28 -0
- package/dist/spa/src/i18n.ts +54 -0
- package/dist/spa/src/index.scss +34 -0
- package/dist/spa/src/main.ts +22 -0
- package/dist/spa/src/renderers/CompactField.vue +46 -0
- package/dist/spa/src/renderers/CompactUUID.vue +46 -0
- package/dist/spa/src/renderers/CountryFlag.vue +65 -0
- package/dist/spa/src/renderers/HumanNumber.vue +58 -0
- package/dist/spa/src/renderers/RelativeTime.vue +42 -0
- package/dist/spa/src/renderers/URL.vue +18 -0
- package/dist/spa/src/router/index.ts +70 -0
- package/dist/spa/src/spa_types/core.ts +51 -0
- package/dist/spa/src/stores/core.ts +228 -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 +30 -0
- package/dist/spa/src/stores/user.ts +79 -0
- package/dist/spa/src/types/Adapters.ts +26 -0
- package/dist/spa/src/types/Back.ts +1344 -0
- package/dist/spa/src/types/Common.ts +940 -0
- package/dist/spa/src/types/FrontendAPI.ts +189 -0
- package/dist/spa/src/utils.ts +184 -0
- package/dist/spa/src/views/CreateView.vue +167 -0
- package/dist/spa/src/views/EditView.vue +171 -0
- package/dist/spa/src/views/ListView.vue +442 -0
- package/dist/spa/src/views/LoginView.vue +199 -0
- package/dist/spa/src/views/PageNotFound.vue +20 -0
- package/dist/spa/src/views/ResourceParent.vue +50 -0
- package/dist/spa/src/views/ShowView.vue +209 -0
- package/dist/spa/src/websocket.ts +129 -0
- package/dist/spa/tailwind.config.js +19 -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 +52 -0
- package/package.json +1 -1
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- table -->
|
|
3
|
+
<div class="relative shadow-listTableShadow dark:shadow-darkListTableShadow overflow-auto "
|
|
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
|
+
<table v-else class=" w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 rounded-default">
|
|
15
|
+
|
|
16
|
+
<tbody>
|
|
17
|
+
|
|
18
|
+
<!-- table header -->
|
|
19
|
+
<tr class="t-header sticky z-10 top-0 text-xs bg-lightListTableHeading dark:bg-darkListTableHeading dark:text-gray-400">
|
|
20
|
+
<td scope="col" class="p-4">
|
|
21
|
+
<div v-if="rows && rows.length" class="flex items-center">
|
|
22
|
+
<input id="checkbox-all-search" type="checkbox" :checked="allFromThisPageChecked" @change="selectAll()"
|
|
23
|
+
class="w-4 h-4 cursor-pointer text-blue-600 bg-gray-100 border-gray-300 rounded
|
|
24
|
+
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">
|
|
25
|
+
<label for="checkbox-all-search" class="sr-only">{{ $t('checkbox') }}</label>
|
|
26
|
+
</div>
|
|
27
|
+
</td>
|
|
28
|
+
|
|
29
|
+
<td v-for="c in columnsListed" scope="col" class="px-2 md:px-3 lg:px-6 py-3">
|
|
30
|
+
|
|
31
|
+
<div @click="(evt) => c.sortable && onSortButtonClick(evt, c.name)"
|
|
32
|
+
class="flex items-center " :class="{'cursor-pointer':c.sortable}">
|
|
33
|
+
{{ c.label }}
|
|
34
|
+
|
|
35
|
+
<div v-if="c.sortable">
|
|
36
|
+
<svg v-if="ascArr.includes(c.name) || descArr.includes(c.name)" class="w-3 h-3 ms-1.5"
|
|
37
|
+
fill='currentColor'
|
|
38
|
+
:class="{'rotate-180':descArr.includes(c.name)}" viewBox="0 0 24 24">
|
|
39
|
+
<path
|
|
40
|
+
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 0z"/>
|
|
41
|
+
</svg>
|
|
42
|
+
<svg v-else class="w-3 h-3 ms-1.5 opacity-30" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
|
|
43
|
+
fill='currentColor'
|
|
44
|
+
viewBox="0 0 24 24">
|
|
45
|
+
<path
|
|
46
|
+
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"/>
|
|
47
|
+
</svg>
|
|
48
|
+
</div>
|
|
49
|
+
<span
|
|
50
|
+
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"
|
|
51
|
+
v-if="sort.findIndex((s) => s.field === c.name) !== -1 && sort?.length > 1">
|
|
52
|
+
{{ sort.findIndex((s) => s.field === c.name) + 1 }}
|
|
53
|
+
</span>
|
|
54
|
+
|
|
55
|
+
</div>
|
|
56
|
+
</td>
|
|
57
|
+
|
|
58
|
+
<td scope="col" class="px-6 py-3">
|
|
59
|
+
{{ $t('Actions') }}
|
|
60
|
+
</td>
|
|
61
|
+
</tr>
|
|
62
|
+
<!-- table header end -->
|
|
63
|
+
<SkeleteLoader
|
|
64
|
+
v-if="!rows"
|
|
65
|
+
:columns="resource?.columns.filter(c => c.showIn.includes('list')).length + 2"
|
|
66
|
+
:rows="3"
|
|
67
|
+
/>
|
|
68
|
+
<tr v-else-if="rows.length === 0" class="bg-lightListTable dark:bg-darkListTable dark:border-darkListTableBorder">
|
|
69
|
+
<td :colspan="resource?.columns.length + 2">
|
|
70
|
+
|
|
71
|
+
<div id="toast-simple"
|
|
72
|
+
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"
|
|
73
|
+
role="alert">
|
|
74
|
+
<IconInboxOutline class="w-6 h-6 text-gray-500 dark:text-gray-400"/>
|
|
75
|
+
<div class="ps-4 text-sm font-normal">{{ $t('No items here yet') }}</div>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
</td>
|
|
79
|
+
</tr>
|
|
80
|
+
|
|
81
|
+
<tr @click="onClick($event,row)"
|
|
82
|
+
v-else v-for="(row, rowI) in rows" :key="`row_${row._primaryKeyValue}`"
|
|
83
|
+
class="bg-lightListTable dark:bg-darkListTable border-lightListBorder dark:border-gray-700 hover:bg-lightListTableRowHover dark:hover:bg-darkListTableRowHover"
|
|
84
|
+
|
|
85
|
+
:class="{'border-b': rowI !== rows.length - 1, 'cursor-pointer': row._clickUrl !== null}"
|
|
86
|
+
>
|
|
87
|
+
<td class="w-4 p-4 cursor-default" @click="(e)=>{e.stopPropagation()}">
|
|
88
|
+
<div class="flex items center ">
|
|
89
|
+
<input
|
|
90
|
+
@click="(e)=>{e.stopPropagation()}"
|
|
91
|
+
id="checkbox-table-search-1"
|
|
92
|
+
type="checkbox"
|
|
93
|
+
:checked="checkboxesInternal.includes(row._primaryKeyValue)"
|
|
94
|
+
@change="(e)=>{addToCheckedValues(row._primaryKeyValue)}"
|
|
95
|
+
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">
|
|
96
|
+
<label for="checkbox-table-search-1" class="sr-only">{{ $t('checkbox') }}</label>
|
|
97
|
+
</div>
|
|
98
|
+
</td>
|
|
99
|
+
<td v-for="c in columnsListed" class="px-2 md:px-3 lg:px-6 py-4">
|
|
100
|
+
<!-- if c.name in listComponentsPerColumn, render it. If not, render ValueRenderer -->
|
|
101
|
+
<component
|
|
102
|
+
:is="c?.components?.list ? getCustomComponent(c.components.list) : ValueRenderer"
|
|
103
|
+
:meta="c?.components?.list?.meta"
|
|
104
|
+
:column="c"
|
|
105
|
+
:record="row"
|
|
106
|
+
:adminUser="coreStore.adminUser"
|
|
107
|
+
:resource="resource"
|
|
108
|
+
/>
|
|
109
|
+
</td>
|
|
110
|
+
<td class=" items-center px-2 md:px-3 lg:px-6 py-4 cursor-default" @click="(e)=>{e.stopPropagation()}">
|
|
111
|
+
<div class="flex text-lightPrimary dark:text-darkPrimary items-center">
|
|
112
|
+
<Tooltip>
|
|
113
|
+
<RouterLink
|
|
114
|
+
v-if="resource.options?.allowedActions.show"
|
|
115
|
+
:to="{
|
|
116
|
+
name: 'resource-show',
|
|
117
|
+
params: {
|
|
118
|
+
resourceId: resource.resourceId,
|
|
119
|
+
primaryKey: row._primaryKeyValue,
|
|
120
|
+
}
|
|
121
|
+
}"
|
|
122
|
+
|
|
123
|
+
>
|
|
124
|
+
<IconEyeSolid class="w-5 h-5 me-2"/>
|
|
125
|
+
</RouterLink>
|
|
126
|
+
|
|
127
|
+
<template v-slot:tooltip>
|
|
128
|
+
{{ $t('Show item') }}
|
|
129
|
+
</template>
|
|
130
|
+
</Tooltip>
|
|
131
|
+
|
|
132
|
+
<Tooltip>
|
|
133
|
+
<RouterLink
|
|
134
|
+
v-if="resource.options?.allowedActions.edit"
|
|
135
|
+
:to="{
|
|
136
|
+
name: 'resource-edit',
|
|
137
|
+
params: {
|
|
138
|
+
resourceId: resource.resourceId,
|
|
139
|
+
primaryKey: row._primaryKeyValue,
|
|
140
|
+
}
|
|
141
|
+
}"
|
|
142
|
+
>
|
|
143
|
+
<IconPenSolid class="w-5 h-5 me-2"/>
|
|
144
|
+
</RouterLink>
|
|
145
|
+
<template v-slot:tooltip>
|
|
146
|
+
{{ $t('Edit item') }}
|
|
147
|
+
</template>
|
|
148
|
+
</Tooltip>
|
|
149
|
+
|
|
150
|
+
<Tooltip>
|
|
151
|
+
<button
|
|
152
|
+
v-if="resource.options?.allowedActions.delete"
|
|
153
|
+
@click="deleteRecord(row)"
|
|
154
|
+
>
|
|
155
|
+
<IconTrashBinSolid class="w-5 h-5 me-2"/>
|
|
156
|
+
</button>
|
|
157
|
+
|
|
158
|
+
<template v-slot:tooltip>
|
|
159
|
+
{{ $t('Delete item') }}
|
|
160
|
+
</template>
|
|
161
|
+
</Tooltip>
|
|
162
|
+
|
|
163
|
+
<template v-if="customActionsInjection">
|
|
164
|
+
<component
|
|
165
|
+
v-for="c in customActionsInjection"
|
|
166
|
+
:is="getCustomComponent(c)"
|
|
167
|
+
:meta="c.meta"
|
|
168
|
+
:resource="coreStore.resource"
|
|
169
|
+
:adminUser="coreStore.adminUser"
|
|
170
|
+
:record="row"
|
|
171
|
+
/>
|
|
172
|
+
</template>
|
|
173
|
+
</div>
|
|
174
|
+
</td>
|
|
175
|
+
</tr>
|
|
176
|
+
</tbody>
|
|
177
|
+
</table>
|
|
178
|
+
</div>
|
|
179
|
+
<!-- pagination
|
|
180
|
+
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)
|
|
181
|
+
-->
|
|
182
|
+
<div class="flex flex-row items-center mt-4 xs:flex-row xs:justify-between xs:items-center gap-3"
|
|
183
|
+
v-if="(rows || totalRows) && totalRows >= pageSize && totalRows > 0"
|
|
184
|
+
>
|
|
185
|
+
|
|
186
|
+
<div class="inline-flex ">
|
|
187
|
+
<!-- Buttons -->
|
|
188
|
+
<button
|
|
189
|
+
class="flex items-center py-1 px-3 gap-1 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"
|
|
190
|
+
@click="page--" :disabled="page <= 1">
|
|
191
|
+
<svg class="w-3.5 h-3.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
|
192
|
+
viewBox="0 0 14 10">
|
|
193
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
194
|
+
d="M13 5H1m0 0 4 4M1 5l4-4"/>
|
|
195
|
+
</svg>
|
|
196
|
+
<span class="hidden sm:inline">
|
|
197
|
+
{{ $t('Prev') }}
|
|
198
|
+
</span>
|
|
199
|
+
</button>
|
|
200
|
+
<button
|
|
201
|
+
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"
|
|
202
|
+
@click="page = 1" :disabled="page <= 1">
|
|
203
|
+
<!-- <IconChevronDoubleLeftOutline class="w-4 h-4" /> -->
|
|
204
|
+
1
|
|
205
|
+
</button>
|
|
206
|
+
<div
|
|
207
|
+
contenteditable="true"
|
|
208
|
+
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"
|
|
209
|
+
@input="page = parseInt($event.target.innerText) || ''"
|
|
210
|
+
>
|
|
211
|
+
{{ page }}
|
|
212
|
+
</div>
|
|
213
|
+
|
|
214
|
+
<button
|
|
215
|
+
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"
|
|
216
|
+
@click="page = totalPages" :disabled="page >= totalPages">
|
|
217
|
+
{{ totalPages }}
|
|
218
|
+
|
|
219
|
+
<!-- <IconChevronDoubleRightOutline class="w-4 h-4" /> -->
|
|
220
|
+
</button>
|
|
221
|
+
<button
|
|
222
|
+
class="flex items-center py-1 px-3 gap-1 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"
|
|
223
|
+
@click="page++" :disabled="page >= totalPages">
|
|
224
|
+
<span class="hidden sm:inline">{{ $t('Next') }}</span>
|
|
225
|
+
<svg class="w-3.5 h-3.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
|
226
|
+
viewBox="0 0 14 10">
|
|
227
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
228
|
+
d="M1 5h12m0 0L9 1m4 4L9 9"/>
|
|
229
|
+
</svg>
|
|
230
|
+
</button>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
<!-- Help text -->
|
|
234
|
+
<span class="text-sm text-gray-700 dark:text-gray-400">
|
|
235
|
+
<span v-if="((page || 1) - 1) * pageSize + 1 > totalRows">{{ $t('Wrong Page') }} </span>
|
|
236
|
+
<template v-else>
|
|
237
|
+
|
|
238
|
+
<span class="hidden sm:inline">
|
|
239
|
+
<i18n-t keypath="Showing {from} to {to} of {total} Entries" tag="p" >
|
|
240
|
+
<template v-slot:from>
|
|
241
|
+
<strong>{{ from }}</strong>
|
|
242
|
+
</template>
|
|
243
|
+
<template v-slot:to>
|
|
244
|
+
<strong>{{ to }}</strong>
|
|
245
|
+
</template>
|
|
246
|
+
<template v-slot:total>
|
|
247
|
+
<strong>{{ totalRows }}</strong>
|
|
248
|
+
</template>
|
|
249
|
+
</i18n-t>
|
|
250
|
+
</span>
|
|
251
|
+
<span class="sm:hidden">
|
|
252
|
+
<i18n-t keypath="{from} - {to} of {total}" tag="p" >
|
|
253
|
+
<template v-slot:from>
|
|
254
|
+
<strong>{{ from }}</strong>
|
|
255
|
+
</template>
|
|
256
|
+
<template v-slot:to>
|
|
257
|
+
<strong>{{ to }}</strong>
|
|
258
|
+
</template>
|
|
259
|
+
<template v-slot:total>
|
|
260
|
+
<strong>{{ totalRows }}</strong>
|
|
261
|
+
</template>
|
|
262
|
+
</i18n-t>
|
|
263
|
+
</span>
|
|
264
|
+
</template>
|
|
265
|
+
</span>
|
|
266
|
+
</div>
|
|
267
|
+
</template>
|
|
268
|
+
|
|
269
|
+
<script setup lang="ts">
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
import { computed, onMounted, ref, watch, type Ref } from 'vue';
|
|
273
|
+
import { callAdminForthApi } from '@/utils';
|
|
274
|
+
|
|
275
|
+
import ValueRenderer from '@/components/ValueRenderer.vue';
|
|
276
|
+
import { getCustomComponent } from '@/utils';
|
|
277
|
+
import { useCoreStore } from '@/stores/core';
|
|
278
|
+
import { showSuccesTost, showErrorTost } from '@/composables/useFrontendApi';
|
|
279
|
+
import SkeleteLoader from '@/components/SkeleteLoader.vue';
|
|
280
|
+
|
|
281
|
+
import {
|
|
282
|
+
IconInboxOutline,
|
|
283
|
+
} from '@iconify-prerendered/vue-flowbite';
|
|
284
|
+
|
|
285
|
+
import {
|
|
286
|
+
IconEyeSolid,
|
|
287
|
+
IconPenSolid,
|
|
288
|
+
IconTrashBinSolid
|
|
289
|
+
} from '@iconify-prerendered/vue-flowbite';
|
|
290
|
+
import router from '@/router';
|
|
291
|
+
import { Tooltip } from '@/afcl';
|
|
292
|
+
import type { AdminForthResourceCommon } from '@/types/Common';
|
|
293
|
+
import adminforth from '@/adminforth';
|
|
294
|
+
|
|
295
|
+
const coreStore = useCoreStore();
|
|
296
|
+
|
|
297
|
+
const props = defineProps<{
|
|
298
|
+
page: number,
|
|
299
|
+
resource: AdminForthResourceCommon,
|
|
300
|
+
rows: any[] | null,
|
|
301
|
+
totalRows: number,
|
|
302
|
+
pageSize: number,
|
|
303
|
+
checkboxes: any[],
|
|
304
|
+
sort: any[],
|
|
305
|
+
noRoundings?: boolean,
|
|
306
|
+
customActionsInjection?: any[],
|
|
307
|
+
}>();
|
|
308
|
+
|
|
309
|
+
// emits, update page
|
|
310
|
+
const emits = defineEmits([
|
|
311
|
+
'update:page',
|
|
312
|
+
'update:sort',
|
|
313
|
+
'update:checkboxes',
|
|
314
|
+
'update:records'
|
|
315
|
+
|
|
316
|
+
]);
|
|
317
|
+
|
|
318
|
+
const checkboxesInternal: Ref<any[]> = ref([]);
|
|
319
|
+
const page = ref(1);
|
|
320
|
+
const sort = ref([]);
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
const from = computed(() => ((page.value || 1) - 1) * props.pageSize + 1);
|
|
324
|
+
const to = computed(() => Math.min((page.value || 1) * props.pageSize, props.totalRows));
|
|
325
|
+
|
|
326
|
+
watch(() => page.value, (newPage) => {
|
|
327
|
+
emits('update:page', newPage);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
watch(() => sort.value, (newSort) => {
|
|
331
|
+
emits('update:sort', newSort);
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
watch(() => checkboxesInternal.value, (newCheckboxes) => {
|
|
335
|
+
emits('update:checkboxes', newCheckboxes);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
watch(() => props.checkboxes, (newCheckboxes) => {
|
|
339
|
+
checkboxesInternal.value = newCheckboxes;
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
watch(() => props.sort, (newSort) => {
|
|
343
|
+
sort.value = newSort;
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
watch(() => props.page, (newPage) => {
|
|
347
|
+
page.value = newPage;
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
function addToCheckedValues(id) {
|
|
351
|
+
if (checkboxesInternal.value.includes(id)) {
|
|
352
|
+
checkboxesInternal.value = checkboxesInternal.value.filter((item) => item !== id);
|
|
353
|
+
} else {
|
|
354
|
+
checkboxesInternal.value.push(id);
|
|
355
|
+
}
|
|
356
|
+
checkboxesInternal.value = [ ...checkboxesInternal.value ]
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const columnsListed = computed(() => props.resource?.columns?.filter(c => c.showIn.includes('list')));
|
|
360
|
+
|
|
361
|
+
async function selectAll(value) {
|
|
362
|
+
if (!allFromThisPageChecked.value) {
|
|
363
|
+
props.rows.forEach((r) => {
|
|
364
|
+
if (!checkboxesInternal.value.includes(r._primaryKeyValue)) {
|
|
365
|
+
checkboxesInternal.value.push(r._primaryKeyValue)
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
} else {
|
|
369
|
+
props.rows.forEach((r) => {
|
|
370
|
+
checkboxesInternal.value = checkboxesInternal.value.filter((item) => item !== r._primaryKeyValue);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
checkboxesInternal.value = [ ...checkboxesInternal.value ];
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const totalPages = computed(() => Math.ceil(props.totalRows / props.pageSize));
|
|
377
|
+
|
|
378
|
+
const allFromThisPageChecked = computed(() => {
|
|
379
|
+
if (!props.rows) return false;
|
|
380
|
+
return props.rows.every((r) => checkboxesInternal.value.includes(r._primaryKeyValue));
|
|
381
|
+
});
|
|
382
|
+
const ascArr = computed(() => sort.value.filter((s) => s.direction === 'asc').map((s) => s.field));
|
|
383
|
+
const descArr = computed(() => sort.value.filter((s) => s.direction === 'desc').map((s) => s.field));
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
function onSortButtonClick(event, field) {
|
|
387
|
+
// if ctrl key is pressed, add to sort otherwise sort by this field
|
|
388
|
+
// in any case if field is already in sort, toggle direction
|
|
389
|
+
|
|
390
|
+
const sortIndex = sort.value.findIndex((s) => s.field === field);
|
|
391
|
+
if (sortIndex === -1) {
|
|
392
|
+
// field is not in sort, add it
|
|
393
|
+
if (event.ctrlKey) {
|
|
394
|
+
sort.value = [...sort.value,{field, direction: 'asc'}];
|
|
395
|
+
} else {
|
|
396
|
+
sort.value = [{field, direction: 'asc'}];
|
|
397
|
+
}
|
|
398
|
+
} else {
|
|
399
|
+
const sortField = sort.value[sortIndex];
|
|
400
|
+
if (sortField.direction === 'asc') {
|
|
401
|
+
sort.value[sortIndex].direction = 'desc';
|
|
402
|
+
} else {
|
|
403
|
+
sort.value.splice(sortIndex, 1);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
const clickTarget = ref(null);
|
|
410
|
+
|
|
411
|
+
async function onClick(e,row) {
|
|
412
|
+
if(clickTarget.value === e.target) return;
|
|
413
|
+
clickTarget.value = e.target;
|
|
414
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
415
|
+
if (window.getSelection().toString()) return;
|
|
416
|
+
else {
|
|
417
|
+
if (row._clickUrl === null) {
|
|
418
|
+
// user asked to nothing on click
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (e.ctrlKey || e.metaKey || row._clickUrl?.includes('target=_blank')) {
|
|
422
|
+
|
|
423
|
+
if (row._clickUrl) {
|
|
424
|
+
window.open(row._clickUrl, '_blank');
|
|
425
|
+
} else {
|
|
426
|
+
window.open(
|
|
427
|
+
router.resolve({
|
|
428
|
+
name: 'resource-show',
|
|
429
|
+
params: {
|
|
430
|
+
resourceId: props.resource.resourceId,
|
|
431
|
+
primaryKey: row._primaryKeyValue,
|
|
432
|
+
},
|
|
433
|
+
}).fullPath,
|
|
434
|
+
'_blank'
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
} else {
|
|
438
|
+
if (row._clickUrl) {
|
|
439
|
+
if (row._clickUrl.startsWith('http')) {
|
|
440
|
+
document.location.href = row._clickUrl;
|
|
441
|
+
} else {
|
|
442
|
+
router.push(row._clickUrl);
|
|
443
|
+
}
|
|
444
|
+
} else {
|
|
445
|
+
router.push({
|
|
446
|
+
name: 'resource-show',
|
|
447
|
+
params: {
|
|
448
|
+
resourceId: props.resource.resourceId,
|
|
449
|
+
primaryKey: row._primaryKeyValue,
|
|
450
|
+
},
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
async function deleteRecord(row) {
|
|
458
|
+
const data = await adminforth.confirm({
|
|
459
|
+
message: 'Are you sure you want to delete this item?',
|
|
460
|
+
yes: 'Delete',
|
|
461
|
+
no: 'Cancel',
|
|
462
|
+
});
|
|
463
|
+
if (data) {
|
|
464
|
+
try {
|
|
465
|
+
const res = await callAdminForthApi({
|
|
466
|
+
path: '/delete_record',
|
|
467
|
+
method: 'POST',
|
|
468
|
+
body: {
|
|
469
|
+
resourceId: props.resource.resourceId,
|
|
470
|
+
primaryKey: row._primaryKeyValue,
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
if (!res.error){
|
|
474
|
+
emits('update:records', true)
|
|
475
|
+
showSuccesTost('Record deleted successfully')
|
|
476
|
+
} else {
|
|
477
|
+
showErrorTost(res.error)
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
} catch (e) {
|
|
481
|
+
showErrorTost(`Something went wrong, please try again later`);
|
|
482
|
+
console.error(e);
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
</script>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="overflow-x-auto rounded-default shadow-resourseFormShadow dark:shadow-darkResourseFormShadow">
|
|
3
|
+
<div v-if="groupName" class="text-md font-semibold px-6 py-3 flex flex-1 items-center dark:border-gray-600 text-gray-700 bg-lightFormHeading dark:bg-gray-700 dark:text-gray-400 rounded-t-lg">
|
|
4
|
+
{{ groupName }}
|
|
5
|
+
</div>
|
|
6
|
+
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 table-fixed mb-4">
|
|
7
|
+
<thead class="text-gray-700 dark:text-gray-400 bg-lightFormHeading dark:bg-gray-700 block md:table-row-group">
|
|
8
|
+
<tr>
|
|
9
|
+
<th scope="col" class="px-6 py-3 text-xs uppercase hidden md:w-52 md:table-cell">
|
|
10
|
+
{{ $t('Field') }}
|
|
11
|
+
</th>
|
|
12
|
+
<th scope="col" class="px-6 py-3 text-xs uppercase hidden md:table-cell">
|
|
13
|
+
{{ $t('Value') }}
|
|
14
|
+
</th>
|
|
15
|
+
</tr>
|
|
16
|
+
</thead>
|
|
17
|
+
<tbody>
|
|
18
|
+
<tr
|
|
19
|
+
v-for="column in columns"
|
|
20
|
+
:key="column.name"
|
|
21
|
+
class="bg-lightForm bg-darkForm odd:dark:bg-gray-900 even:dark:bg-gray-800 dark:border-gray-700 block md:table-row"
|
|
22
|
+
>
|
|
23
|
+
<component
|
|
24
|
+
v-if="column.components?.showRow"
|
|
25
|
+
:is="getCustomComponent(column.components.showRow)"
|
|
26
|
+
:meta="column.components.showRow.meta"
|
|
27
|
+
:column="column"
|
|
28
|
+
:resource="coreStore.resource"
|
|
29
|
+
:record="coreStore.record"
|
|
30
|
+
/>
|
|
31
|
+
<template v-else>
|
|
32
|
+
<td class="px-6 py-4 relative block md:table-cell font-bold md:font-normal pb-0 md:pb-4">
|
|
33
|
+
{{ column.label }}
|
|
34
|
+
</td>
|
|
35
|
+
<td class="px-6 py-4 whitespace-pre-wrap" :data-af-column="column.name">
|
|
36
|
+
<component
|
|
37
|
+
v-if="column?.components?.show"
|
|
38
|
+
:is="getCustomComponent(column?.components?.show)"
|
|
39
|
+
:resource="resource"
|
|
40
|
+
:meta="column.components.show.meta"
|
|
41
|
+
:column="column"
|
|
42
|
+
:record="record"
|
|
43
|
+
/>
|
|
44
|
+
<ValueRenderer
|
|
45
|
+
v-else
|
|
46
|
+
:column="column"
|
|
47
|
+
:record="record"
|
|
48
|
+
/>
|
|
49
|
+
</td>
|
|
50
|
+
</template>
|
|
51
|
+
</tr>
|
|
52
|
+
</tbody>
|
|
53
|
+
</table>
|
|
54
|
+
</div>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<script setup lang="ts">
|
|
58
|
+
import { defineProps } from 'vue';
|
|
59
|
+
import ValueRenderer from '@/components/ValueRenderer.vue';
|
|
60
|
+
import { getCustomComponent } from '@/utils';
|
|
61
|
+
import { useCoreStore } from '@/stores/core';
|
|
62
|
+
defineProps<{
|
|
63
|
+
columns: Array<{
|
|
64
|
+
name: string;
|
|
65
|
+
label: string;
|
|
66
|
+
components?: {
|
|
67
|
+
show?: {
|
|
68
|
+
meta: Record<string, any>;
|
|
69
|
+
};
|
|
70
|
+
showRow?: {
|
|
71
|
+
meta: Record<string, any>;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
}>;
|
|
75
|
+
groupName?: string | null;
|
|
76
|
+
resource: Record<string, any>;
|
|
77
|
+
record: Record<string, any>;
|
|
78
|
+
}>();
|
|
79
|
+
|
|
80
|
+
const coreStore = useCoreStore();
|
|
81
|
+
</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">{{ $t('Loading...') }}</span>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
@@ -0,0 +1,18 @@
|
|
|
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 lang="ts">
|
|
12
|
+
|
|
13
|
+
const props = defineProps<{
|
|
14
|
+
columns: number;
|
|
15
|
+
rows: number;
|
|
16
|
+
}>();
|
|
17
|
+
|
|
18
|
+
</script>
|
|
@@ -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-20 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>
|