adminforth 1.2.38 → 1.2.40
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/basePlugin.ts +4 -5
- package/dataConnectors/mongo.ts +7 -5
- package/dist/basePlugin.js +2 -4
- package/dist/dataConnectors/mongo.js +4 -1
- package/dist/modules/configValidator.js +2 -3
- 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/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/modules/configValidator.ts +4 -3
- package/package.json +1 -3
- 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,24 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="relative">
|
|
3
|
-
<component
|
|
4
|
-
v-for="c in coreStore?.resourceOptions?.pageInjections?.edit?.beforeBreadcrumbs || []"
|
|
5
|
-
:is="getCustomComponent(c)"
|
|
6
|
-
:meta="c.meta"
|
|
7
|
-
:record="editableRecord"
|
|
8
|
-
:resource="coreStore.resource"
|
|
9
|
-
:adminUser="coreStore.adminUser"
|
|
10
|
-
/>
|
|
11
3
|
|
|
12
4
|
<BreadcrumbsWithButtons>
|
|
13
5
|
<!-- save and cancle -->
|
|
14
6
|
<button @click="$router.back()"
|
|
15
|
-
class="flex items-center py-1 px-3 me-2 text-sm font-medium text-gray-900
|
|
7
|
+
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"
|
|
16
8
|
>
|
|
17
9
|
Cancel
|
|
18
10
|
</button>
|
|
19
11
|
|
|
20
12
|
<button @click="saveRecord"
|
|
21
|
-
class="flex items-center py-1 px-3 text-sm font-medium
|
|
13
|
+
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"
|
|
22
14
|
:disabled="saving || (validating && !isValid)"
|
|
23
15
|
>
|
|
24
16
|
<IconFloppyDiskSolid class="w-4 h-4" />
|
|
@@ -27,53 +19,31 @@
|
|
|
27
19
|
|
|
28
20
|
</BreadcrumbsWithButtons>
|
|
29
21
|
|
|
30
|
-
<component
|
|
31
|
-
v-for="c in coreStore?.resourceOptions?.pageInjections?.edit?.afterBreadcrumbs || []"
|
|
32
|
-
:is="getCustomComponent(c)"
|
|
33
|
-
:meta="c.meta"
|
|
34
|
-
:record="coreStore.record"
|
|
35
|
-
:resource="coreStore.resource"
|
|
36
|
-
:adminUser="coreStore.adminUser"
|
|
37
|
-
/>
|
|
38
|
-
|
|
39
22
|
<SingleSkeletLoader v-if="loading"></SingleSkeletLoader>
|
|
40
23
|
|
|
41
24
|
<ResourceForm
|
|
42
25
|
v-else
|
|
43
|
-
:record="
|
|
44
|
-
:
|
|
45
|
-
:adminUser="coreStore.adminUser"
|
|
26
|
+
:record="coreStore.record"
|
|
27
|
+
:resourceColumns="coreStore.resourceColumns"
|
|
46
28
|
@update:record="onUpdateRecord"
|
|
47
29
|
@update:isValid="isValid = $event"
|
|
48
30
|
:validating="validating"
|
|
49
|
-
:customComponentsPerColumn="editComponentsPerColumn"
|
|
50
31
|
>
|
|
51
32
|
</ResourceForm>
|
|
52
|
-
|
|
53
|
-
<component
|
|
54
|
-
v-for="c in coreStore?.resourceOptions?.pageInjections?.edit?.bottom || []"
|
|
55
|
-
:is="getCustomComponent(c)"
|
|
56
|
-
:meta="c.meta"
|
|
57
|
-
:record="coreStore.record"
|
|
58
|
-
:resource="coreStore.resource"
|
|
59
|
-
:adminUser="coreStore.adminUser"
|
|
60
|
-
/>
|
|
61
|
-
|
|
62
33
|
</div>
|
|
63
34
|
</template>
|
|
64
35
|
|
|
65
36
|
|
|
66
37
|
<script setup>
|
|
67
38
|
|
|
68
|
-
import
|
|
69
|
-
import
|
|
70
|
-
import SingleSkeletLoader from '@/components/SingleSkeletLoader.vue';
|
|
39
|
+
import { ref, computed, onMounted } from 'vue';
|
|
40
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
71
41
|
import { useCoreStore } from '@/stores/core';
|
|
72
|
-
import
|
|
42
|
+
import ResourceForm from '@/components/ResourceForm.vue';
|
|
43
|
+
import BreadcrumbsWithButtons from '@/components/BreadcrumbsWithButtons.vue';
|
|
73
44
|
import { IconFloppyDiskSolid } from '@iconify-prerendered/vue-flowbite';
|
|
74
|
-
import
|
|
75
|
-
import {
|
|
76
|
-
import { showErrorTost } from '@/composables/useFrontendApi';
|
|
45
|
+
import SingleSkeletLoader from '@/components/SingleSkeletLoader.vue';
|
|
46
|
+
import { callAdminForthApi } from '@/utils';
|
|
77
47
|
|
|
78
48
|
const coreStore = useCoreStore();
|
|
79
49
|
|
|
@@ -88,44 +58,23 @@ const loading = ref(false);
|
|
|
88
58
|
const saving = ref(false);
|
|
89
59
|
|
|
90
60
|
const record = ref({});
|
|
91
|
-
let editComponentsPerColumn = {};
|
|
92
61
|
|
|
93
62
|
async function onUpdateRecord(newRecord) {
|
|
94
63
|
record.value = newRecord;
|
|
95
64
|
}
|
|
96
65
|
|
|
97
|
-
const editableRecord = computed(() => {
|
|
98
|
-
const newRecord = { ...coreStore.record };
|
|
99
|
-
if (!coreStore.resource) {
|
|
100
|
-
return {};
|
|
101
|
-
}
|
|
102
|
-
coreStore.resource.columns.forEach(column => {
|
|
103
|
-
if (column.foreignResource) {
|
|
104
|
-
newRecord[column.name] = newRecord[column.name]?.pk
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
return newRecord;
|
|
108
|
-
})
|
|
109
66
|
|
|
110
67
|
onMounted(async () => {
|
|
111
|
-
|
|
112
68
|
loading.value = true;
|
|
113
69
|
|
|
114
|
-
await coreStore.
|
|
70
|
+
await coreStore.fetchColumns({
|
|
115
71
|
resourceId: route.params.resourceId
|
|
116
72
|
});
|
|
117
73
|
await coreStore.fetchRecord({
|
|
118
74
|
resourceId: route.params.resourceId,
|
|
119
75
|
primaryKey: route.params.primaryKey,
|
|
120
76
|
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
editComponentsPerColumn = coreStore.resource.columns.reduce((acc, column) => {
|
|
124
|
-
if (column.components?.edit) {
|
|
125
|
-
acc[column.name] = getCustomComponent(column.components.edit);
|
|
126
|
-
}
|
|
127
|
-
return acc;
|
|
128
|
-
}, {});
|
|
77
|
+
|
|
129
78
|
loading.value = false;
|
|
130
79
|
});
|
|
131
80
|
|
|
@@ -138,26 +87,15 @@ async function saveRecord() {
|
|
|
138
87
|
}
|
|
139
88
|
|
|
140
89
|
saving.value = true;
|
|
141
|
-
|
|
142
|
-
const updates = {};
|
|
143
|
-
for (const key in record.value) {
|
|
144
|
-
if (record.value[key] !== coreStore.record[key]) {
|
|
145
|
-
updates[key] = record.value[key];
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const resp = await callAdminForthApi({
|
|
90
|
+
await callAdminForthApi({
|
|
150
91
|
method: 'POST',
|
|
151
92
|
path: `/update_record`,
|
|
152
93
|
body: {
|
|
153
94
|
resourceId: route.params.resourceId,
|
|
154
95
|
recordId: route.params.primaryKey,
|
|
155
|
-
record:
|
|
96
|
+
record: record.value,
|
|
156
97
|
},
|
|
157
98
|
});
|
|
158
|
-
if (resp.error) {
|
|
159
|
-
showErrorTost(resp.error);
|
|
160
|
-
}
|
|
161
99
|
saving.value = false;
|
|
162
100
|
router.push({ name: 'resource-show', params: { resourceId: route.params.resourceId, primaryKey: coreStore.record[coreStore.primaryKey] } });
|
|
163
101
|
}
|