adminforth 1.2.42 → 1.2.44

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.
Files changed (45) hide show
  1. package/dist/index.js +5 -0
  2. package/dist/spa/index.html +4 -4
  3. package/dist/spa/package-lock.json +206 -5
  4. package/dist/spa/package.json +8 -2
  5. package/dist/spa/public/assets/favicon.png +0 -0
  6. package/dist/spa/src/App.vue +171 -72
  7. package/dist/spa/src/assets/logo.svg +19 -1
  8. package/dist/spa/src/components/AcceptModal.vue +3 -10
  9. package/dist/spa/src/components/BreadcrumbsWithButtons.vue +1 -1
  10. package/dist/spa/src/components/CustomDatePicker.vue +19 -6
  11. package/dist/spa/src/components/CustomDateRangePicker.vue +14 -5
  12. package/dist/spa/src/components/CustomRangePicker.vue +148 -0
  13. package/dist/spa/src/components/Dropdown.vue +19 -5
  14. package/dist/spa/src/components/Filters.vue +91 -37
  15. package/dist/spa/src/components/MenuLink.vue +2 -2
  16. package/dist/spa/src/components/ResourceForm.vue +163 -103
  17. package/dist/spa/src/components/ResourceListTable.vue +419 -0
  18. package/dist/spa/src/components/Toast.vue +66 -0
  19. package/dist/spa/src/components/ValueRenderer.vue +22 -6
  20. package/dist/spa/src/composables/useFrontendApi.ts +26 -0
  21. package/dist/spa/src/composables/useStores.ts +113 -0
  22. package/dist/spa/src/main.ts +1 -1
  23. package/dist/spa/src/router/index.ts +30 -19
  24. package/dist/spa/src/spa_types/core.ts +51 -0
  25. package/dist/spa/src/stores/core.ts +65 -59
  26. package/dist/spa/src/stores/filters.ts +22 -0
  27. package/dist/spa/src/stores/modal.ts +13 -3
  28. package/dist/spa/src/stores/toast.ts +15 -0
  29. package/dist/spa/src/stores/user.ts +54 -0
  30. package/dist/spa/src/utils.ts +65 -8
  31. package/dist/spa/src/views/CreateView.vue +76 -16
  32. package/dist/spa/src/views/EditView.vue +76 -14
  33. package/dist/spa/src/views/ListView.vue +88 -360
  34. package/dist/spa/src/views/LoginView.vue +17 -5
  35. package/dist/spa/src/views/ResourceParent.vue +1 -1
  36. package/dist/spa/src/views/ShowView.vue +114 -19
  37. package/dist/spa/tailwind.config.js +5 -2
  38. package/dist/spa/vite.config.ts +6 -0
  39. package/index.ts +5 -0
  40. package/package.json +1 -1
  41. package/dist/spa/public/favicon.ico +0 -0
  42. package/dist/spa/spa/public/favicon.ico +0 -0
  43. package/dist/spa/spa/src/views/HomeView.vue +0 -8
  44. package/dist/spa/src/views/HomeView.vue +0 -8
  45. 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 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"
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 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"
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-md sm:rounded-lg"
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-gray-50 dark:bg-gray-700 dark:text-gray-400">
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.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"
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
- <td class="px-6 py-4 whitespace-nowrap">
48
- {{ column.label }}
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
- <ValueRenderer :column="column" :row="coreStore.record" />
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
- import { IconPenSolid, IconTrashBinSolid } from '@iconify-prerendered/vue-flowbite';
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.fetchColumns({
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'),
@@ -11,6 +11,12 @@ const customLogger = {
11
11
  console.log(msg);
12
12
  }
13
13
  },
14
+ warnOnce(msg: string) {
15
+ console.warn('warn once', msg);
16
+ if (!this.hasWarned) {
17
+ this.hasWarned = true;
18
+ }
19
+ },
14
20
  warn(msg: string) {
15
21
  console.warn(msg);
16
22
  },
package/index.ts CHANGED
@@ -82,6 +82,11 @@ class AdminForth implements IAdminForth {
82
82
  for (let resource of this.config.resources) {
83
83
  for (let pluginInstance of resource.plugins || []) {
84
84
  pluginInstance.modifyResourceConfig(this, resource);
85
+ const plugin = this.activatedPlugins.find((p) => p.pluginInstanceId === pluginInstance.pluginInstanceId);
86
+ if (plugin) {
87
+ throw new Error(`Attempt to activate Plugin ${pluginInstance.constructor.name} second time for same resource, but plugin does not support it.
88
+ Tu support multiple plugin instance pre one resource, plugin should return unique string values for each installation from instanceUniqueRepresentation`);
89
+ }
85
90
  this.activatedPlugins.push(pluginInstance);
86
91
  }
87
92
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.2.42",
3
+ "version": "1.2.44",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
Binary file
Binary file
@@ -1,8 +0,0 @@
1
- <script setup lang="ts">
2
- </script>
3
-
4
- <template>
5
- <main>
6
- 123
7
- </main>
8
- </template>
@@ -1,8 +0,0 @@
1
- <script setup lang="ts">
2
- </script>
3
-
4
- <template>
5
- <main>
6
- 123
7
- </main>
8
- </template>
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
- };