adminforth 1.1.52 → 1.1.54
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/modules/styles.js +3 -3
- package/dist/spa/index.html +4 -4
- package/dist/spa/package-lock.json +206 -5
- package/dist/spa/package.json +8 -2
- package/dist/spa/public/assets/favicon.png +0 -0
- package/dist/spa/spa/src/App.vue +2 -2
- package/dist/spa/spa/src/components/ResourceListTable.vue +14 -11
- package/dist/spa/spa/src/components/SkeleteLoader.vue +1 -1
- package/dist/spa/spa/src/views/ResourceParent.vue +1 -2
- package/dist/spa/src/App.vue +171 -72
- package/dist/spa/src/assets/logo.svg +19 -1
- package/dist/spa/src/components/AcceptModal.vue +3 -10
- package/dist/spa/src/components/BreadcrumbsWithButtons.vue +1 -1
- package/dist/spa/src/components/CustomDatePicker.vue +19 -6
- package/dist/spa/src/components/CustomDateRangePicker.vue +14 -5
- package/dist/spa/src/components/CustomRangePicker.vue +148 -0
- package/dist/spa/src/components/Dropdown.vue +19 -5
- package/dist/spa/src/components/Filters.vue +91 -37
- package/dist/spa/src/components/MenuLink.vue +2 -2
- package/dist/spa/src/components/ResourceForm.vue +163 -103
- package/dist/spa/src/components/ResourceListTable.vue +419 -0
- package/dist/spa/src/components/Toast.vue +66 -0
- package/dist/spa/src/components/ValueRenderer.vue +22 -6
- package/dist/spa/src/composables/useFrontendApi.ts +26 -0
- package/dist/spa/src/composables/useStores.ts +113 -0
- package/dist/spa/src/main.ts +1 -1
- package/dist/spa/src/router/index.ts +30 -19
- package/dist/spa/src/spa_types/core.ts +51 -0
- package/dist/spa/src/stores/core.ts +65 -59
- package/dist/spa/src/stores/filters.ts +22 -0
- package/dist/spa/src/stores/modal.ts +13 -3
- package/dist/spa/src/stores/toast.ts +15 -0
- package/dist/spa/src/stores/user.ts +54 -0
- package/dist/spa/src/utils.ts +65 -8
- package/dist/spa/src/views/CreateView.vue +76 -16
- package/dist/spa/src/views/EditView.vue +76 -14
- package/dist/spa/src/views/ListView.vue +88 -360
- package/dist/spa/src/views/LoginView.vue +17 -5
- package/dist/spa/src/views/ResourceParent.vue +1 -1
- package/dist/spa/src/views/ShowView.vue +114 -19
- package/dist/spa/tailwind.config.js +5 -2
- package/dist/spa/vite.config.ts +6 -0
- package/modules/styles.ts +4 -3
- package/package.json +1 -1
- package/spa/src/App.vue +2 -2
- package/spa/src/components/ResourceListTable.vue +14 -11
- package/spa/src/components/SkeleteLoader.vue +1 -1
- package/spa/src/views/ResourceParent.vue +1 -2
- package/dist/spa/public/favicon.ico +0 -0
- package/dist/spa/spa/public/favicon.ico +0 -0
- package/dist/spa/spa/src/views/HomeView.vue +0 -8
- package/dist/spa/src/views/HomeView.vue +0 -8
- package/dist/types.js +0 -30
|
@@ -1,21 +1,38 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="relative">
|
|
3
|
+
<component
|
|
4
|
+
v-for="c in coreStore?.resourceOptions?.pageInjections?.show?.beforeBreadcrumbs || []"
|
|
5
|
+
:is="getCustomComponent(c)"
|
|
6
|
+
:meta="c.meta"
|
|
7
|
+
:record="coreStore.record"
|
|
8
|
+
:resource="coreStore.resource"
|
|
9
|
+
:adminUser="coreStore.adminUser"
|
|
10
|
+
/>
|
|
3
11
|
<BreadcrumbsWithButtons>
|
|
4
|
-
<RouterLink :to="{ name: 'resource-edit', params: { resourceId: $route.params.resourceId, primaryKey: $route.params.primaryKey } }"
|
|
5
|
-
class="flex items-center py-1 px-3
|
|
12
|
+
<RouterLink v-if="coreStore?.resourceOptions?.allowedActions?.edit" :to="{ name: 'resource-edit', params: { resourceId: $route.params.resourceId, primaryKey: $route.params.primaryKey } }"
|
|
13
|
+
class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-default border border-gray-300 hover:bg-gray-100 hover:text-blue-700 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"
|
|
6
14
|
>
|
|
7
15
|
<IconPenSolid class="w-4 h-4" />
|
|
8
16
|
Edit
|
|
9
17
|
</RouterLink>
|
|
10
18
|
|
|
11
|
-
<button @click="deleteRecord"
|
|
12
|
-
class="flex items-center py-1 px-3
|
|
19
|
+
<button v-if="coreStore?.resourceOptions?.allowedActions?.delete" @click="deleteRecord"
|
|
20
|
+
class="flex items-center py-1 px-3 text-sm font-medium rounded-default text-red-600 focus:outline-none bg-white border border-gray-300 hover:bg-gray-100 hover:text-red-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-red-500 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
|
|
13
21
|
>
|
|
14
22
|
<IconTrashBinSolid class="w-4 h-4" />
|
|
15
23
|
Delete
|
|
16
24
|
</button>
|
|
17
25
|
</BreadcrumbsWithButtons>
|
|
18
26
|
|
|
27
|
+
<component
|
|
28
|
+
v-for="c in coreStore?.resourceOptions?.pageInjections?.show?.afterBreadcrumbs || []"
|
|
29
|
+
:is="getCustomComponent(c)"
|
|
30
|
+
:meta="c.meta"
|
|
31
|
+
:record="coreStore.record"
|
|
32
|
+
:resource="coreStore.resource"
|
|
33
|
+
:adminUser="coreStore.adminUser"
|
|
34
|
+
/>
|
|
35
|
+
|
|
19
36
|
<div v-if="loading" role="status" class="max-w-sm animate-pulse">
|
|
20
37
|
<div class="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4"></div>
|
|
21
38
|
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px] mb-2.5"></div>
|
|
@@ -27,10 +44,10 @@
|
|
|
27
44
|
</div>
|
|
28
45
|
<div
|
|
29
46
|
v-else
|
|
30
|
-
class="relative overflow-x-auto shadow-
|
|
47
|
+
class="relative overflow-x-auto shadow-resourse-form-shadow "
|
|
31
48
|
>
|
|
32
|
-
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
|
|
33
|
-
<thead class="text-xs text-gray-700 uppercase bg-
|
|
49
|
+
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 rounded-default">
|
|
50
|
+
<thead class="text-xs text-gray-700 uppercase bg-form-view-heading dark:bg-gray-700 dark:text-gray-400">
|
|
34
51
|
<tr>
|
|
35
52
|
<th scope="col" class="px-6 py-3">
|
|
36
53
|
Field
|
|
@@ -41,19 +58,49 @@
|
|
|
41
58
|
</tr>
|
|
42
59
|
</thead>
|
|
43
60
|
<tbody>
|
|
44
|
-
<tr v-for="column in coreStore.
|
|
45
|
-
class="
|
|
61
|
+
<tr v-for="column in coreStore.resource?.columns.filter(c => c.showIn.includes('show'))" :key="column.name"
|
|
62
|
+
class="bg-form-view-bg odd:dark:bg-gray-900 even:dark:bg-gray-800 border-b dark:border-gray-700"
|
|
46
63
|
>
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
<component
|
|
65
|
+
v-if="column.components?.showRow"
|
|
66
|
+
:is="getCustomComponent(column.components.showRow)"
|
|
67
|
+
:meta="column.components.showRow.meta"
|
|
68
|
+
:column="column"
|
|
69
|
+
:resource="coreStore.resource"
|
|
70
|
+
:record="coreStore.record"
|
|
71
|
+
/>
|
|
72
|
+
<template v-else>
|
|
73
|
+
<td class="px-6 py-4 whitespace-nowrap "> <!--align-top-->
|
|
74
|
+
{{ column.label }}
|
|
49
75
|
</td>
|
|
50
76
|
<td class="px-6 py-4 whitespace-nowrap whitespace-pre-wrap">
|
|
51
|
-
|
|
77
|
+
<component
|
|
78
|
+
v-if="showComponentsPerColumn[column.name]"
|
|
79
|
+
:is="showComponentsPerColumn[column.name]"
|
|
80
|
+
:resource="coreStore.resource"
|
|
81
|
+
:meta="column.components.show.meta"
|
|
82
|
+
:column="column"
|
|
83
|
+
:record="coreStore.record"
|
|
84
|
+
/>
|
|
85
|
+
<ValueRenderer v-else
|
|
86
|
+
:column="column"
|
|
87
|
+
:record="coreStore.record"
|
|
88
|
+
/>
|
|
52
89
|
</td>
|
|
90
|
+
</template>
|
|
53
91
|
</tr>
|
|
54
|
-
|
|
55
92
|
</tbody>
|
|
56
93
|
</table>
|
|
94
|
+
|
|
95
|
+
<component
|
|
96
|
+
v-for="c in coreStore?.resourceOptions?.pageInjections?.show?.bottom || []"
|
|
97
|
+
:is="getCustomComponent(c)"
|
|
98
|
+
:meta="c.meta"
|
|
99
|
+
:column="column"
|
|
100
|
+
:record="coreStore.record"
|
|
101
|
+
:resource="coreStore.resource"
|
|
102
|
+
:adminUser="coreStore.adminUser"
|
|
103
|
+
/>
|
|
57
104
|
</div>
|
|
58
105
|
|
|
59
106
|
|
|
@@ -63,31 +110,79 @@
|
|
|
63
110
|
|
|
64
111
|
<script setup>
|
|
65
112
|
|
|
66
|
-
import { ref, computed, onMounted } from 'vue';
|
|
67
|
-
import { useRoute } from 'vue-router';
|
|
68
|
-
import { callAdminForthApi } from '@/utils';
|
|
69
113
|
import BreadcrumbsWithButtons from '@/components/BreadcrumbsWithButtons.vue';
|
|
70
|
-
|
|
71
|
-
import { useCoreStore } from '@/stores/core';
|
|
114
|
+
|
|
72
115
|
import ValueRenderer from '@/components/ValueRenderer.vue';
|
|
116
|
+
import { useCoreStore } from '@/stores/core';
|
|
117
|
+
import { useModalStore } from '@/stores/modal';
|
|
118
|
+
import { getCustomComponent, checkAcessByAllowedActions } from '@/utils';
|
|
119
|
+
import { IconPenSolid, IconTrashBinSolid } from '@iconify-prerendered/vue-flowbite';
|
|
120
|
+
import { onMounted, ref } from 'vue';
|
|
121
|
+
import { useRoute,useRouter } from 'vue-router';
|
|
122
|
+
import {callAdminForthApi} from '@/utils';
|
|
123
|
+
import {showSuccesTost} from '@/composables/useFrontendApi';
|
|
73
124
|
|
|
74
125
|
|
|
75
126
|
const item = ref(null);
|
|
76
127
|
const route = useRoute();
|
|
128
|
+
const router = useRouter();
|
|
77
129
|
const loading = ref(false);
|
|
130
|
+
let showComponentsPerColumn = {};
|
|
131
|
+
|
|
132
|
+
console.log(route.params,'showWiev');
|
|
133
|
+
|
|
78
134
|
|
|
79
135
|
const coreStore = useCoreStore();
|
|
136
|
+
const modalStore = useModalStore();
|
|
80
137
|
|
|
81
138
|
onMounted(async () => {
|
|
82
139
|
loading.value = true;
|
|
83
|
-
await coreStore.
|
|
140
|
+
await coreStore.fetchResourceFull({
|
|
84
141
|
resourceId: route.params.resourceId
|
|
85
142
|
});
|
|
86
143
|
await coreStore.fetchRecord({
|
|
87
144
|
resourceId: route.params.resourceId,
|
|
88
145
|
primaryKey: route.params.primaryKey,
|
|
89
146
|
});
|
|
147
|
+
checkAcessByAllowedActions(coreStore.resourceOptions.allowedActions,'show');
|
|
148
|
+
|
|
149
|
+
showComponentsPerColumn = coreStore.resource.columns.reduce((acc, column) => {
|
|
150
|
+
if (column.components?.show) {
|
|
151
|
+
acc[column.name] = getCustomComponent(column.components.show);
|
|
152
|
+
}
|
|
153
|
+
return acc;
|
|
154
|
+
}, {});
|
|
90
155
|
loading.value = false;
|
|
91
156
|
});
|
|
92
157
|
|
|
158
|
+
async function deleteRecord(row) {
|
|
159
|
+
const data = await window.adminforth.confirm({
|
|
160
|
+
message: 'Are you sure you want to delete this item?',
|
|
161
|
+
yes: 'Delete',
|
|
162
|
+
no: 'Cancel',
|
|
163
|
+
});
|
|
164
|
+
if (data) {
|
|
165
|
+
try {
|
|
166
|
+
const res = await callAdminForthApi({
|
|
167
|
+
path: '/delete_record',
|
|
168
|
+
method: 'POST',
|
|
169
|
+
body: {
|
|
170
|
+
resourceId: route.params.resourceId,
|
|
171
|
+
primaryKey: route.params.primaryKey,
|
|
172
|
+
}});
|
|
173
|
+
if (!res.error){
|
|
174
|
+
router.push({ name: 'resource-list', params: { resourceId: route.params.resourceId } });
|
|
175
|
+
showSuccesTost('Record deleted successfully')
|
|
176
|
+
} else {
|
|
177
|
+
console.error(res.error)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
} catch (e) {
|
|
181
|
+
console.error(e);
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
93
188
|
</script>
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/** @type {import('tailwindcss').Config} */
|
|
2
2
|
export default {
|
|
3
|
-
content: ["./src/**/*.{vue, js}", "./node_modules/flowbite/**/*.js"],
|
|
3
|
+
content: ["./src/**/*.{vue, js, ts, tsx}","./src/*.{vue, js, ts, tsx}", "./index.html", "./node_modules/flowbite/**/*.js"],
|
|
4
4
|
theme: {
|
|
5
|
-
extend: {
|
|
5
|
+
extend: {
|
|
6
|
+
/* IMPORTANT:ADMINFORTH TAILWIND STYLES */
|
|
7
|
+
}
|
|
6
8
|
},
|
|
9
|
+
|
|
7
10
|
darkMode: 'class',
|
|
8
11
|
plugins: [
|
|
9
12
|
require('flowbite/plugin'),
|
package/dist/spa/vite.config.ts
CHANGED
package/modules/styles.ts
CHANGED
|
@@ -17,7 +17,7 @@ export const styles = () => ({
|
|
|
17
17
|
lightSidebarBorder: "rgb(229 231 235)", // sidebar right border
|
|
18
18
|
lightSidebarHover: "rgb(243 244 246)", // in development
|
|
19
19
|
lightSidebarActive: "rgb(233, 234, 236)", // in development
|
|
20
|
-
lightSidebarItemHover: "
|
|
20
|
+
lightSidebarItemHover: "#f3f4f6", // sidebar list item hover
|
|
21
21
|
lightSidebarItemActive: "rgb(233, 234, 236)", // sidebar list item active
|
|
22
22
|
lightSidebarText: "#4b5563", // sidebar list item text
|
|
23
23
|
lightSidebarTextHover: "#333333", // sidebar list item text hover
|
|
@@ -38,7 +38,8 @@ export const styles = () => ({
|
|
|
38
38
|
|
|
39
39
|
lightForm: "#FFFFFF", // show view background
|
|
40
40
|
lightFormBorder: "#F5F5F5", // show view rows border
|
|
41
|
-
lightFormHeading: "
|
|
41
|
+
lightFormHeading: "rgb(249 250 251)", // show view heading
|
|
42
|
+
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
// colors for dark theme
|
|
@@ -79,7 +80,7 @@ export const styles = () => ({
|
|
|
79
80
|
|
|
80
81
|
darkForm: "#111111",
|
|
81
82
|
darkFormBorder: "#222222",
|
|
82
|
-
darkFormHeading: "#
|
|
83
|
+
darkFormHeading: "#334155"
|
|
83
84
|
|
|
84
85
|
},
|
|
85
86
|
boxShadow: {
|
package/package.json
CHANGED
package/spa/src/App.vue
CHANGED
|
@@ -107,9 +107,9 @@
|
|
|
107
107
|
</aside>
|
|
108
108
|
|
|
109
109
|
|
|
110
|
-
<div class="
|
|
110
|
+
<div class="sm:ml-64 dark:bg-gray-800" v-if="loggedIn && routerIsReady && loginRedirectCheckIsReady">
|
|
111
111
|
<div class="p-0 dark:border-gray-700 mt-14">
|
|
112
|
-
|
|
112
|
+
<RouterView/>
|
|
113
113
|
</div>
|
|
114
114
|
</div>
|
|
115
115
|
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
</tr>
|
|
55
55
|
</thead>
|
|
56
56
|
<tbody>
|
|
57
|
-
<SkeleteLoader v-if="!rows
|
|
57
|
+
<SkeleteLoader v-if="!rows" :columns="3" :rows="resource?.columns.length + 2"/>
|
|
58
58
|
<tr v-else-if="rows.length === 0" class="bg-lightListTable border-b dark:bg-darkListTable dark:border-darkListTableBorder">
|
|
59
59
|
<td :colspan="resource?.columns.length + 2">
|
|
60
60
|
|
|
@@ -300,15 +300,18 @@ function addToCheckedValues(id) {
|
|
|
300
300
|
const columnsListed = computed(() => props.resource?.columns?.filter(c => c.showIn.includes('list')));
|
|
301
301
|
|
|
302
302
|
async function selectAll(value) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
checkboxesInternal.value.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
303
|
+
if (!allFromThisPageChecked.value) {
|
|
304
|
+
props.rows.forEach((r) => {
|
|
305
|
+
if (!checkboxesInternal.value.includes(r.id)) {
|
|
306
|
+
checkboxesInternal.value.push(r.id)
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
props.rows.forEach((r) => {
|
|
312
|
+
checkboxesInternal.value = checkboxesInternal.value.filter((item) => item !== r.id);
|
|
313
|
+
});
|
|
314
|
+
}
|
|
312
315
|
}
|
|
313
316
|
|
|
314
317
|
const totalPages = computed(() => Math.ceil(props.totalRows / props.pageSize));
|
|
@@ -318,7 +321,7 @@ const totalPages = computed(() => Math.ceil(props.totalRows / props.pageSize));
|
|
|
318
321
|
|
|
319
322
|
const allFromThisPageChecked = computed(() => {
|
|
320
323
|
if (!props.rows) return false;
|
|
321
|
-
return props.rows.every((r) =>
|
|
324
|
+
return props.rows.every((r) => checkboxesInternal.value.includes(r.id));
|
|
322
325
|
});
|
|
323
326
|
const ascArr = computed(() => sort.value.filter((s) => s.direction === 'asc').map((s) => s.field));
|
|
324
327
|
const descArr = computed(() => sort.value.filter((s) => s.direction === 'desc').map((s) => s.field));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<tr v-for="c in new Array(props.columns)" class="bg-lightListTable border-b dark:bg-darkListTable dark:border-darkListBorder">
|
|
3
|
-
<td v-for="r in new Array(props.rows)" class="items-center px-6 py-
|
|
3
|
+
<td v-for="r in new Array(props.rows)" class="items-center px-6 py-8 cursor-default" >
|
|
4
4
|
<div role="status" class="max-w-sm animate-pulse">
|
|
5
5
|
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px]"></div>
|
|
6
6
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :key="`${$route?.params.resourceId}---${$route?.params.primaryKey}`">
|
|
2
|
+
<div :key="`${$route?.params.resourceId}---${$route?.params.primaryKey}`" class="p-4">
|
|
3
3
|
<RouterView/>
|
|
4
4
|
</div>
|
|
5
5
|
</template>
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
import { useCoreStore } from '@/stores/core';
|
|
14
|
-
import { onMounted } from 'vue';
|
|
15
14
|
|
|
16
15
|
const coreStore = useCoreStore()
|
|
17
16
|
|
|
Binary file
|
|
Binary file
|
package/dist/types.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// typical types which AdminForth supports
|
|
2
|
-
//
|
|
3
|
-
export const AdminForthTypes = {
|
|
4
|
-
STRING: 'string',
|
|
5
|
-
INTEGER: 'integer',
|
|
6
|
-
FLOAT: 'float',
|
|
7
|
-
DECIMAL: 'decimal',
|
|
8
|
-
BOOLEAN: 'boolean',
|
|
9
|
-
DATE: 'date',
|
|
10
|
-
DATETIME: 'datetime',
|
|
11
|
-
TIME: 'time',
|
|
12
|
-
TEXT: 'text',
|
|
13
|
-
JSON: 'json',
|
|
14
|
-
};
|
|
15
|
-
export const AdminForthFilterOperators = {
|
|
16
|
-
EQ: 'eq',
|
|
17
|
-
NE: 'ne',
|
|
18
|
-
GT: 'gt',
|
|
19
|
-
LT: 'lt',
|
|
20
|
-
GTE: 'gte',
|
|
21
|
-
LTE: 'lte',
|
|
22
|
-
LIKE: 'like',
|
|
23
|
-
ILIKE: 'ilike',
|
|
24
|
-
IN: 'in',
|
|
25
|
-
NIN: 'nin',
|
|
26
|
-
};
|
|
27
|
-
export const AdminForthSortDirections = {
|
|
28
|
-
ASC: 'asc',
|
|
29
|
-
DESC: 'desc',
|
|
30
|
-
};
|