adminforth 1.1.31 → 1.1.33
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.js +9 -0
- package/dist/modules/codeInjector.js +19 -7
- package/dist/modules/styles.js +2 -2
- 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/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/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/ValueRenderer.vue +22 -6
- package/dist/spa/src/main.ts +1 -1
- package/dist/spa/src/router/index.ts +30 -19
- package/dist/spa/src/stores/core.ts +65 -59
- package/dist/spa/src/stores/modal.ts +13 -3
- 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/index.ts +11 -0
- package/modules/codeInjector.ts +19 -1
- package/modules/styles.ts +2 -2
- package/package.json +1 -1
- package/spa/index.html +1 -1
- package/spa/src/App.vue +3 -2
- package/spa/src/components/ResourceForm.vue +1 -1
- package/types/AdminForthConfig.ts +15 -0
- package/dist/plugins/AccessControl/index.js +0 -13
- package/dist/plugins/AccessControl/types.js +0 -1
- package/dist/plugins/plugins/ForeignInlineListPlugin/custom/InlineList.vue +0 -248
- package/dist/spa/public/favicon.ico +0 -0
- package/dist/spa/spa/.eslintrc.cjs +0 -14
- package/dist/spa/spa/.vscode/extensions.json +0 -6
- package/dist/spa/spa/README.md +0 -39
- package/dist/spa/spa/env.d.ts +0 -1
- package/dist/spa/spa/index.html +0 -23
- package/dist/spa/spa/package-lock.json +0 -4359
- package/dist/spa/spa/package.json +0 -47
- package/dist/spa/spa/postcss.config.js +0 -6
- package/dist/spa/spa/public/favicon.ico +0 -0
- package/dist/spa/spa/src/App.vue +0 -270
- package/dist/spa/spa/src/assets/base.css +0 -0
- package/dist/spa/spa/src/assets/logo.svg +0 -19
- package/dist/spa/spa/src/components/AcceptModal.vue +0 -45
- package/dist/spa/spa/src/components/Breadcrumbs.vue +0 -40
- package/dist/spa/spa/src/components/BreadcrumbsWithButtons.vue +0 -26
- package/dist/spa/spa/src/components/CustomDatePicker.vue +0 -174
- package/dist/spa/spa/src/components/CustomDateRangePicker.vue +0 -218
- package/dist/spa/spa/src/components/Dropdown.vue +0 -168
- package/dist/spa/spa/src/components/Filters.vue +0 -211
- package/dist/spa/spa/src/components/HelloWorld.vue +0 -17
- package/dist/spa/spa/src/components/MenuLink.vue +0 -24
- package/dist/spa/spa/src/components/ResourceForm.vue +0 -265
- package/dist/spa/spa/src/components/ShowTableItem.vue +0 -14
- package/dist/spa/spa/src/components/SingleSkeletLoader.vue +0 -13
- package/dist/spa/spa/src/components/ValueRenderer.vue +0 -60
- package/dist/spa/spa/src/components/icons/IconCalendar.vue +0 -5
- package/dist/spa/spa/src/components/icons/IconCommunity.vue +0 -7
- package/dist/spa/spa/src/components/icons/IconDocumentation.vue +0 -7
- package/dist/spa/spa/src/components/icons/IconEcosystem.vue +0 -7
- package/dist/spa/spa/src/components/icons/IconSupport.vue +0 -7
- package/dist/spa/spa/src/components/icons/IconTime.vue +0 -5
- package/dist/spa/spa/src/components/icons/IconTooling.vue +0 -19
- package/dist/spa/spa/src/index.scss +0 -26
- package/dist/spa/spa/src/main.ts +0 -18
- package/dist/spa/spa/src/router/index.ts +0 -64
- package/dist/spa/spa/src/stores/core.ts +0 -144
- package/dist/spa/spa/src/stores/modal.ts +0 -48
- package/dist/spa/spa/src/utils.ts +0 -101
- package/dist/spa/spa/src/views/CreateView.vue +0 -163
- package/dist/spa/spa/src/views/EditView.vue +0 -165
- package/dist/spa/spa/src/views/HomeView.vue +0 -8
- package/dist/spa/spa/src/views/ListView.vue +0 -257
- package/dist/spa/spa/src/views/LoginView.vue +0 -134
- package/dist/spa/spa/src/views/ResourceParent.vue +0 -18
- package/dist/spa/spa/src/views/ShowView.vue +0 -188
- package/dist/spa/spa/tailwind.config.js +0 -15
- package/dist/spa/spa/tsconfig.app.json +0 -14
- package/dist/spa/spa/tsconfig.json +0 -11
- package/dist/spa/spa/tsconfig.node.json +0 -19
- package/dist/spa/spa/vite.config.ts +0 -49
- package/dist/spa/src/views/HomeView.vue +0 -8
- package/dist/types.js +0 -30
- /package/dist/spa/{spa/public → public/assets}/favicon.png +0 -0
- /package/dist/spa/{spa/src → src}/components/CustomRangePicker.vue +0 -0
- /package/dist/spa/{spa/src → src}/components/ResourceListTable.vue +0 -0
- /package/dist/spa/{spa/src → src}/components/Toast.vue +0 -0
- /package/dist/spa/{spa/src → src}/composables/useFrontendApi.ts +0 -0
- /package/dist/spa/{spa/src → src}/composables/useStores.ts +0 -0
- /package/dist/spa/{spa/src → src}/spa_types/core.ts +0 -0
- /package/dist/spa/{spa/src → src}/stores/filters.ts +0 -0
- /package/dist/spa/{spa/src → src}/stores/toast.ts +0 -0
- /package/dist/spa/{spa/src → src}/stores/user.ts +0 -0
- /package/spa/public/{favicon.png → assets/favicon.png} +0 -0
|
@@ -1,16 +1,24 @@
|
|
|
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
|
+
/>
|
|
3
11
|
|
|
4
12
|
<BreadcrumbsWithButtons>
|
|
5
13
|
<!-- save and cancle -->
|
|
6
14
|
<button @click="$router.back()"
|
|
7
|
-
class="flex items-center py-1 px-3 me-2
|
|
15
|
+
class="flex items-center py-1 px-3 me-2 text-sm font-medium text-gray-900 rounded-default 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"
|
|
8
16
|
>
|
|
9
17
|
Cancel
|
|
10
18
|
</button>
|
|
11
19
|
|
|
12
20
|
<button @click="saveRecord"
|
|
13
|
-
class="flex items-center py-1 px-3
|
|
21
|
+
class="flex items-center py-1 px-3 text-sm font-medium rounded-default 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"
|
|
14
22
|
:disabled="saving || (validating && !isValid)"
|
|
15
23
|
>
|
|
16
24
|
<IconFloppyDiskSolid class="w-4 h-4" />
|
|
@@ -19,31 +27,53 @@
|
|
|
19
27
|
|
|
20
28
|
</BreadcrumbsWithButtons>
|
|
21
29
|
|
|
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
|
+
|
|
22
39
|
<SingleSkeletLoader v-if="loading"></SingleSkeletLoader>
|
|
23
40
|
|
|
24
41
|
<ResourceForm
|
|
25
42
|
v-else
|
|
26
|
-
:record="
|
|
27
|
-
:
|
|
43
|
+
:record="editableRecord"
|
|
44
|
+
:resource="coreStore.resource"
|
|
45
|
+
:adminUser="coreStore.adminUser"
|
|
28
46
|
@update:record="onUpdateRecord"
|
|
29
47
|
@update:isValid="isValid = $event"
|
|
30
48
|
:validating="validating"
|
|
49
|
+
:customComponentsPerColumn="editComponentsPerColumn"
|
|
31
50
|
>
|
|
32
51
|
</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
|
+
|
|
33
62
|
</div>
|
|
34
63
|
</template>
|
|
35
64
|
|
|
36
65
|
|
|
37
66
|
<script setup>
|
|
38
67
|
|
|
39
|
-
import { ref, computed, onMounted } from 'vue';
|
|
40
|
-
import { useRoute, useRouter } from 'vue-router';
|
|
41
|
-
import { useCoreStore } from '@/stores/core';
|
|
42
|
-
import ResourceForm from '@/components/ResourceForm.vue';
|
|
43
68
|
import BreadcrumbsWithButtons from '@/components/BreadcrumbsWithButtons.vue';
|
|
44
|
-
import
|
|
69
|
+
import ResourceForm from '@/components/ResourceForm.vue';
|
|
45
70
|
import SingleSkeletLoader from '@/components/SingleSkeletLoader.vue';
|
|
46
|
-
import {
|
|
71
|
+
import { useCoreStore } from '@/stores/core';
|
|
72
|
+
import { callAdminForthApi, getCustomComponent,checkAcessByAllowedActions } from '@/utils';
|
|
73
|
+
import { IconFloppyDiskSolid } from '@iconify-prerendered/vue-flowbite';
|
|
74
|
+
import { computed, onMounted, ref } from 'vue';
|
|
75
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
76
|
+
import { showErrorTost } from '@/composables/useFrontendApi';
|
|
47
77
|
|
|
48
78
|
const coreStore = useCoreStore();
|
|
49
79
|
|
|
@@ -58,23 +88,44 @@ const loading = ref(false);
|
|
|
58
88
|
const saving = ref(false);
|
|
59
89
|
|
|
60
90
|
const record = ref({});
|
|
91
|
+
let editComponentsPerColumn = {};
|
|
61
92
|
|
|
62
93
|
async function onUpdateRecord(newRecord) {
|
|
63
94
|
record.value = newRecord;
|
|
64
95
|
}
|
|
65
96
|
|
|
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
|
+
})
|
|
66
109
|
|
|
67
110
|
onMounted(async () => {
|
|
111
|
+
|
|
68
112
|
loading.value = true;
|
|
69
113
|
|
|
70
|
-
await coreStore.
|
|
114
|
+
await coreStore.fetchResourceFull({
|
|
71
115
|
resourceId: route.params.resourceId
|
|
72
116
|
});
|
|
73
117
|
await coreStore.fetchRecord({
|
|
74
118
|
resourceId: route.params.resourceId,
|
|
75
119
|
primaryKey: route.params.primaryKey,
|
|
76
120
|
});
|
|
77
|
-
|
|
121
|
+
checkAcessByAllowedActions(coreStore.resourceOptions.allowedActions,'edit');
|
|
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
|
+
}, {});
|
|
78
129
|
loading.value = false;
|
|
79
130
|
});
|
|
80
131
|
|
|
@@ -87,15 +138,26 @@ async function saveRecord() {
|
|
|
87
138
|
}
|
|
88
139
|
|
|
89
140
|
saving.value = true;
|
|
90
|
-
|
|
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({
|
|
91
150
|
method: 'POST',
|
|
92
151
|
path: `/update_record`,
|
|
93
152
|
body: {
|
|
94
153
|
resourceId: route.params.resourceId,
|
|
95
154
|
recordId: route.params.primaryKey,
|
|
96
|
-
record:
|
|
155
|
+
record: updates,
|
|
97
156
|
},
|
|
98
157
|
});
|
|
158
|
+
if (resp.error) {
|
|
159
|
+
showErrorTost(resp.error);
|
|
160
|
+
}
|
|
99
161
|
saving.value = false;
|
|
100
162
|
router.push({ name: 'resource-show', params: { resourceId: route.params.resourceId, primaryKey: coreStore.record[coreStore.primaryKey] } });
|
|
101
163
|
}
|