adminforth 1.1.69 → 1.1.70
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/auth.ts +1 -3
- package/dist/auth.js +1 -2
- package/dist/spa/index.html +4 -4
- package/dist/spa/package-lock.json +5 -206
- package/dist/spa/package.json +2 -8
- 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 +8 -0
- package/dist/spa/spa/src/views/LoginView.vue +0 -2
- package/dist/spa/src/App.vue +72 -171
- package/dist/spa/src/assets/logo.svg +1 -19
- package/dist/spa/src/components/AcceptModal.vue +10 -3
- package/dist/spa/src/components/BreadcrumbsWithButtons.vue +1 -1
- package/dist/spa/src/components/CustomDatePicker.vue +6 -19
- package/dist/spa/src/components/CustomDateRangePicker.vue +5 -14
- package/dist/spa/src/components/Dropdown.vue +5 -19
- package/dist/spa/src/components/Filters.vue +37 -91
- package/dist/spa/src/components/MenuLink.vue +2 -2
- package/dist/spa/src/components/ResourceForm.vue +103 -163
- package/dist/spa/src/components/ValueRenderer.vue +6 -22
- package/dist/spa/src/main.ts +1 -1
- package/dist/spa/src/router/index.ts +19 -30
- package/dist/spa/src/stores/core.ts +59 -65
- package/dist/spa/src/stores/modal.ts +3 -13
- package/dist/spa/src/utils.ts +8 -65
- package/dist/spa/src/views/CreateView.vue +16 -76
- package/dist/spa/src/views/EditView.vue +14 -76
- package/dist/spa/src/views/HomeView.vue +8 -0
- package/dist/spa/src/views/ListView.vue +360 -88
- package/dist/spa/src/views/LoginView.vue +5 -17
- package/dist/spa/src/views/ResourceParent.vue +1 -1
- package/dist/spa/src/views/ShowView.vue +19 -114
- package/dist/spa/tailwind.config.js +2 -5
- package/dist/spa/vite.config.ts +0 -6
- package/dist/types.js +30 -0
- package/package.json +1 -1
- package/spa/src/views/LoginView.vue +0 -2
- package/dist/spa/public/assets/favicon.png +0 -0
- package/dist/spa/src/components/CustomRangePicker.vue +0 -148
- package/dist/spa/src/components/ResourceListTable.vue +0 -419
- package/dist/spa/src/components/Toast.vue +0 -66
- package/dist/spa/src/composables/useFrontendApi.ts +0 -26
- package/dist/spa/src/composables/useStores.ts +0 -113
- package/dist/spa/src/spa_types/core.ts +0 -51
- package/dist/spa/src/stores/filters.ts +0 -22
- package/dist/spa/src/stores/toast.ts +0 -15
- package/dist/spa/src/stores/user.ts +0 -54
|
@@ -1,38 +1,21 @@
|
|
|
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
|
-
/>
|
|
11
3
|
<BreadcrumbsWithButtons>
|
|
12
|
-
<RouterLink
|
|
13
|
-
class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded
|
|
4
|
+
<RouterLink :to="{ name: 'resource-edit', params: { resourceId: $route.params.resourceId, primaryKey: $route.params.primaryKey } }"
|
|
5
|
+
class="flex items-center py-1 px-3 me-2 mb-2 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded 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"
|
|
14
6
|
>
|
|
15
7
|
<IconPenSolid class="w-4 h-4" />
|
|
16
8
|
Edit
|
|
17
9
|
</RouterLink>
|
|
18
10
|
|
|
19
|
-
<button
|
|
20
|
-
class="flex items-center py-1 px-3 text-sm font-medium
|
|
11
|
+
<button @click="deleteRecord"
|
|
12
|
+
class="flex items-center py-1 px-3 mb-2 text-sm font-medium text-red-600 focus:outline-none bg-white rounded 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"
|
|
21
13
|
>
|
|
22
14
|
<IconTrashBinSolid class="w-4 h-4" />
|
|
23
15
|
Delete
|
|
24
16
|
</button>
|
|
25
17
|
</BreadcrumbsWithButtons>
|
|
26
18
|
|
|
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
|
-
|
|
36
19
|
<div v-if="loading" role="status" class="max-w-sm animate-pulse">
|
|
37
20
|
<div class="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4"></div>
|
|
38
21
|
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px] mb-2.5"></div>
|
|
@@ -44,10 +27,10 @@
|
|
|
44
27
|
</div>
|
|
45
28
|
<div
|
|
46
29
|
v-else
|
|
47
|
-
class="relative overflow-x-auto shadow-
|
|
30
|
+
class="relative overflow-x-auto shadow-md sm:rounded-lg"
|
|
48
31
|
>
|
|
49
|
-
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400
|
|
50
|
-
<thead class="text-xs text-gray-700 uppercase bg-
|
|
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-gray-50 dark:bg-gray-700 dark:text-gray-400">
|
|
51
34
|
<tr>
|
|
52
35
|
<th scope="col" class="px-6 py-3">
|
|
53
36
|
Field
|
|
@@ -58,49 +41,19 @@
|
|
|
58
41
|
</tr>
|
|
59
42
|
</thead>
|
|
60
43
|
<tbody>
|
|
61
|
-
<tr v-for="column in coreStore.
|
|
62
|
-
class="bg-
|
|
44
|
+
<tr v-for="column in coreStore.resourceColumns?.filter(c => c.showIn.includes('show'))" :key="column.name"
|
|
45
|
+
class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 border-b dark:border-gray-700"
|
|
63
46
|
>
|
|
64
|
-
|
|
65
|
-
|
|
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 }}
|
|
47
|
+
<td class="px-6 py-4 whitespace-nowrap">
|
|
48
|
+
{{ column.label }}
|
|
75
49
|
</td>
|
|
76
50
|
<td class="px-6 py-4 whitespace-nowrap whitespace-pre-wrap">
|
|
77
|
-
|
|
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
|
-
/>
|
|
51
|
+
<ValueRenderer :column="column" :row="coreStore.record" />
|
|
89
52
|
</td>
|
|
90
|
-
</template>
|
|
91
53
|
</tr>
|
|
54
|
+
|
|
92
55
|
</tbody>
|
|
93
56
|
</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
|
-
/>
|
|
104
57
|
</div>
|
|
105
58
|
|
|
106
59
|
|
|
@@ -110,79 +63,31 @@
|
|
|
110
63
|
|
|
111
64
|
<script setup>
|
|
112
65
|
|
|
66
|
+
import { ref, computed, onMounted } from 'vue';
|
|
67
|
+
import { useRoute } from 'vue-router';
|
|
68
|
+
import { callAdminForthApi } from '@/utils';
|
|
113
69
|
import BreadcrumbsWithButtons from '@/components/BreadcrumbsWithButtons.vue';
|
|
114
|
-
|
|
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
70
|
import { IconPenSolid, IconTrashBinSolid } from '@iconify-prerendered/vue-flowbite';
|
|
120
|
-
import {
|
|
121
|
-
import
|
|
122
|
-
import {callAdminForthApi} from '@/utils';
|
|
123
|
-
import {showSuccesTost} from '@/composables/useFrontendApi';
|
|
71
|
+
import { useCoreStore } from '@/stores/core';
|
|
72
|
+
import ValueRenderer from '@/components/ValueRenderer.vue';
|
|
124
73
|
|
|
125
74
|
|
|
126
75
|
const item = ref(null);
|
|
127
76
|
const route = useRoute();
|
|
128
|
-
const router = useRouter();
|
|
129
77
|
const loading = ref(false);
|
|
130
|
-
let showComponentsPerColumn = {};
|
|
131
|
-
|
|
132
|
-
console.log(route.params,'showWiev');
|
|
133
|
-
|
|
134
78
|
|
|
135
79
|
const coreStore = useCoreStore();
|
|
136
|
-
const modalStore = useModalStore();
|
|
137
80
|
|
|
138
81
|
onMounted(async () => {
|
|
139
82
|
loading.value = true;
|
|
140
|
-
await coreStore.
|
|
83
|
+
await coreStore.fetchColumns({
|
|
141
84
|
resourceId: route.params.resourceId
|
|
142
85
|
});
|
|
143
86
|
await coreStore.fetchRecord({
|
|
144
87
|
resourceId: route.params.resourceId,
|
|
145
88
|
primaryKey: route.params.primaryKey,
|
|
146
89
|
});
|
|
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
|
-
}, {});
|
|
155
90
|
loading.value = false;
|
|
156
91
|
});
|
|
157
92
|
|
|
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
|
-
|
|
188
93
|
</script>
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/** @type {import('tailwindcss').Config} */
|
|
2
2
|
export default {
|
|
3
|
-
content: ["./src/**/*.{vue, js
|
|
3
|
+
content: ["./src/**/*.{vue, js}", "./node_modules/flowbite/**/*.js"],
|
|
4
4
|
theme: {
|
|
5
|
-
extend: {
|
|
6
|
-
/* IMPORTANT:ADMINFORTH TAILWIND STYLES */
|
|
7
|
-
}
|
|
5
|
+
extend: {},
|
|
8
6
|
},
|
|
9
|
-
|
|
10
7
|
darkMode: 'class',
|
|
11
8
|
plugins: [
|
|
12
9
|
require('flowbite/plugin'),
|
package/dist/spa/vite.config.ts
CHANGED
package/dist/types.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
};
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="flex flex-wrap gap-2">
|
|
3
|
-
<input
|
|
4
|
-
type="number" aria-describedby="helper-text-explanation"
|
|
5
|
-
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-20 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
6
|
-
placeholder="From"
|
|
7
|
-
v-model="start"
|
|
8
|
-
>
|
|
9
|
-
|
|
10
|
-
<input
|
|
11
|
-
type="number" aria-describedby="helper-text-explanation"
|
|
12
|
-
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-20 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
13
|
-
placeholder="To"
|
|
14
|
-
v-model="end"
|
|
15
|
-
>
|
|
16
|
-
|
|
17
|
-
<button
|
|
18
|
-
v-if="isChanged"
|
|
19
|
-
type="button"
|
|
20
|
-
class="flex items-center p-0.5 ml-auto px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded 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 disabled:opacity-50 disabled:cursor-not-allowed"
|
|
21
|
-
@click="clear">Clear
|
|
22
|
-
</button>
|
|
23
|
-
|
|
24
|
-
<div class="w-full">
|
|
25
|
-
<vue-slider
|
|
26
|
-
class="custom-slider"
|
|
27
|
-
:dot-size="20"
|
|
28
|
-
height="7.99px"
|
|
29
|
-
:min="minFormatted"
|
|
30
|
-
:max="maxFormatted"
|
|
31
|
-
v-model="sliderValue"
|
|
32
|
-
@update:model-value="updateFromSlider($event)"
|
|
33
|
-
/>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
</template>
|
|
37
|
-
<script setup lang="ts">
|
|
38
|
-
import VueSlider from 'vue-slider-component';
|
|
39
|
-
import 'vue-slider-component/theme/antd.css'
|
|
40
|
-
import {computed, onMounted, ref, watch} from "vue";
|
|
41
|
-
import debounce from 'debounce'
|
|
42
|
-
|
|
43
|
-
const props = defineProps({
|
|
44
|
-
valueStart: {
|
|
45
|
-
default: '',
|
|
46
|
-
},
|
|
47
|
-
valueEnd: {
|
|
48
|
-
default: '',
|
|
49
|
-
},
|
|
50
|
-
min: {
|
|
51
|
-
default: 0,
|
|
52
|
-
},
|
|
53
|
-
max: {
|
|
54
|
-
default: 10,
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const emit = defineEmits(['update:valueStart', 'update:valueEnd']);
|
|
59
|
-
|
|
60
|
-
const minFormatted = computed(() => Math.floor(props.min));
|
|
61
|
-
const maxFormatted = computed(() => Math.ceil(props.max));
|
|
62
|
-
|
|
63
|
-
const isChanged = computed(() => {
|
|
64
|
-
return start.value && start.value !== minFormatted.value || end.value && end.value !== maxFormatted.value;
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const start = ref(props.valueStart);
|
|
68
|
-
const end = ref(props.valueEnd);
|
|
69
|
-
|
|
70
|
-
const sliderValue = ref([minFormatted.value, maxFormatted.value]);
|
|
71
|
-
|
|
72
|
-
const updateFromSlider =
|
|
73
|
-
debounce((value: [number, number]) => {
|
|
74
|
-
start.value = value[0] === minFormatted.value ? '': value[0];
|
|
75
|
-
end.value = value[1] === maxFormatted.value ? '': value[1];
|
|
76
|
-
}, 500);
|
|
77
|
-
|
|
78
|
-
onMounted(() => {
|
|
79
|
-
updateStartFromProps();
|
|
80
|
-
updateEndFromProps();
|
|
81
|
-
|
|
82
|
-
watch(() => props.valueStart, (value) => {
|
|
83
|
-
updateStartFromProps();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
watch(() => props.valueEnd, (value) => {
|
|
87
|
-
updateEndFromProps();
|
|
88
|
-
});
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
function updateStartFromProps() {
|
|
92
|
-
start.value = props.valueStart;
|
|
93
|
-
setSliderValues(start.value, end.value)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function updateEndFromProps() {
|
|
97
|
-
end.value = props.valueEnd;
|
|
98
|
-
setSliderValues(start.value, end.value)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
watch(start, () => {
|
|
102
|
-
console.log('⚡ emit', start.value)
|
|
103
|
-
emit('update:valueStart', start.value)
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
watch(end, () => {
|
|
107
|
-
console.log('⚡ emit', end.value)
|
|
108
|
-
emit('update:valueEnd', end.value);
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
const clear = () => {
|
|
112
|
-
start.value = ''
|
|
113
|
-
end.value = ''
|
|
114
|
-
setSliderValues('', '')
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function setSliderValues(start, end) {
|
|
118
|
-
sliderValue.value = [start || minFormatted.value, end || maxFormatted.value];
|
|
119
|
-
}
|
|
120
|
-
</script>
|
|
121
|
-
|
|
122
|
-
<style lang="scss" scoped>
|
|
123
|
-
.custom-slider {
|
|
124
|
-
&:deep(.vue-slider-rail) {
|
|
125
|
-
background-color: rgb(229 231 235);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
&:deep(.vue-slider-dot-handle) {
|
|
129
|
-
background-color: #1c64f2;
|
|
130
|
-
border: none;
|
|
131
|
-
box-shadow: none;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
&:deep(.vue-slider-dot-handle:hover) {
|
|
135
|
-
background-color: #1c64f2;
|
|
136
|
-
border: none;
|
|
137
|
-
box-shadow: none;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
&:deep(.vue-slider-process) {
|
|
141
|
-
background-color: rgb(225 239 254);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
&:deep(.vue-slider-process:hover) {
|
|
145
|
-
background-color: rgb(225 239 254);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
</style>
|