adminforth 1.1.18 → 1.1.19

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.
@@ -65,7 +65,7 @@
65
65
  </BreadcrumbsWithButtons>
66
66
 
67
67
  <!-- table -->
68
- <div class="relative overflow-x-auto shadow-list-table-shadow dark:shadow-black dark:s">
68
+ <div class="relative overflow-x-auto shadow-md sm:rounded-lg dark:shadow-2xl">
69
69
 
70
70
 
71
71
  <!-- skelet loader -->
@@ -90,7 +90,7 @@
90
90
  </div>
91
91
 
92
92
  <table v-else class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
93
- <thead class="text-xs text-view-table-heading-text bg-list-view-table-heading dark:bg-gray-700 dark:text-gray-400">
93
+ <thead class="text-xs text-gray-700 bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
94
94
  <tr>
95
95
  <th scope="col" class="p-4">
96
96
  <div v-if="rows && rows.length" class="flex items-center">
@@ -127,7 +127,7 @@
127
127
  </tr>
128
128
  </thead>
129
129
  <tbody>
130
- <tr v-if="!rows" class="bg-list-view-table-bg border-b dark:bg-gray-800 dark:border-gray-700">
130
+ <tr v-if="!rows" class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
131
131
  <td :colspan="coreStore.resourceColumns.length + 2">
132
132
 
133
133
  <div role="status"
@@ -171,7 +171,7 @@
171
171
  </div>
172
172
  </td>
173
173
  </tr>
174
- <tr v-else-if="rows.length === 0" class="bg-list-view-table-bg border-b dark:bg-gray-800 dark:border-gray-700">
174
+ <tr v-else-if="rows.length === 0" class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
175
175
  <td :colspan="coreStore.resourceColumns.length + 2">
176
176
 
177
177
  <div id="toast-simple"
@@ -185,7 +185,7 @@
185
185
  </tr>
186
186
 
187
187
  <tr v-else v-for="(row, rowI) in rows" :key="row.id"
188
- class="bg-list-view-table-bg border-b dark:bg-gray-800 border-list-view-border-color dark:border-gray-700 hover:bg-list-view-table-row-hover dark:hover:bg-gray-600">
188
+ class="bg-white border-b dark:bg-gray-800 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600">
189
189
  <td class="w-4 p-4">
190
190
  <div class="flex items center">
191
191
  <input
@@ -198,12 +198,7 @@
198
198
  </div>
199
199
  </td>
200
200
  <td v-for="c in columnsListed" class="px-6 py-4">
201
- <!-- if c.name in listComponentsPerColumn, render it. If not, render ValueRenderer -->
202
- <component
203
- :is="listComponentsPerColumn[c.name] || ValueRenderer"
204
- :column="c"
205
- :row="row"
206
- />
201
+ <ValueRenderer :column="c" :row="row"/>
207
202
  </td>
208
203
  <td class="flex items-center px-6 py-4">
209
204
 
@@ -315,28 +310,29 @@
315
310
  </template>
316
311
 
317
312
  <script setup>
313
+ import {ref, onMounted, watch, computed} from 'vue';
314
+ import {callAdminForthApi, getIcon} from '@/utils';
315
+ import {useRoute} from 'vue-router';
316
+ import {useCoreStore} from '@/stores/core';
317
+ import {useModalStore} from '@/stores/modal';
318
318
  import BreadcrumbsWithButtons from '@/components/BreadcrumbsWithButtons.vue';
319
- import { useCoreStore } from '@/stores/core';
320
- import { useModalStore } from '@/stores/modal';
321
- import { callAdminForthApi, getIcon } from '@/utils';
322
- import { initFlowbite } from 'flowbite';
323
- import { computed, onMounted, ref, watch } from 'vue';
324
- import { useRoute } from 'vue-router';
319
+ import {initFlowbite} from 'flowbite'
325
320
 
326
321
  import ValueRenderer from '@/components/ValueRenderer.vue';
327
- import { getCustomComponent } from '@/utils';
328
322
 
329
323
  import {
330
- IconInboxOutline,
331
- IconPlusOutline
324
+ IconChevronDoubleLeftOutline,
325
+ IconChevronDoubleRightOutline,
326
+ IconInboxFullSolid,
327
+ IconInboxOutline,
328
+ IconPlusOutline
332
329
  } from '@iconify-prerendered/vue-flowbite';
333
330
 
334
331
  import {
335
- IconBanOutline,
336
- IconEyeSolid,
337
- IconFilterOutline,
338
- IconPenSolid,
339
- IconTrashBinSolid
332
+ IconEyeSolid,
333
+ IconTrashBinSolid,
334
+ IconPenSolid,
335
+ IconFilterOutline, IconBanOutline
340
336
  } from '@iconify-prerendered/vue-flowbite';
341
337
 
342
338
  import Filters from '@/components/Filters.vue';
@@ -361,6 +357,7 @@ const totalRows = ref(0);
361
357
  const allCheckedActions = ref([]);
362
358
  const allowedActions = ref({});
363
359
 
360
+
364
361
  const DEFAULT_PAGE_SIZE = 10;
365
362
 
366
363
  const columnsListed = computed(() => coreStore.resourceColumns?.filter(c => c.showIn.includes('list')));
@@ -379,7 +376,6 @@ async function selectAll(value) {
379
376
 
380
377
  const pageSize = computed(() => coreStore.resourceById[route.params.resourceId]?.pageSize || DEFAULT_PAGE_SIZE);
381
378
  const totalPages = computed(() => Math.ceil(totalRows.value / pageSize.value));
382
- let listComponentsPerColumn = {};
383
379
  const allFromThisPageChecked = computed(() => {
384
380
  if (!rows.value) return false;
385
381
  return rows.value.every((r) => checkboxes.value.includes(r.id));
@@ -423,7 +419,6 @@ async function getList() {
423
419
  path: '/get_resource_data',
424
420
  method: 'POST',
425
421
  body: {
426
- source: 'list',
427
422
  resourceId: route.params.resourceId,
428
423
  limit: pageSize.value,
429
424
  offset: (page.value - 1) * pageSize.value,
@@ -431,14 +426,7 @@ async function getList() {
431
426
  sort: sort.value,
432
427
  }
433
428
  });
434
- listComponentsPerColumn = coreStore.resourceColumns.reduce((acc, column) => {
435
- if (column.component?.list) {
436
- acc[column.name] = getCustomComponent(column.component.list);
437
- }
438
- return acc;
439
- }, {});
440
-
441
- fetchStatus.value.pending = false;
429
+ fetchStatus.value.pending = false;
442
430
  rows.value = data.data?.map(row => {
443
431
  row._primaryKeyValue = row[coreStore.resourceColumns.find(c => c.primaryKey).name];
444
432
  return row;
@@ -11,7 +11,7 @@
11
11
  <div id="authentication-modal" tabindex="-1" class=" overflow-y-auto overflow-x-hidden z-50 min-w-[400px] justify-center items-center md:inset-0 h-[calc(100%-1rem)] max-h-full">
12
12
  <div class="relative p-4 w-full max-w-md max-h-full">
13
13
  <!-- Modal content -->
14
- <div class="relative bg-white rounded-lg shadow dark:bg-gray-700 dark:shadow-black" >
14
+ <div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
15
15
  <!-- Modal header -->
16
16
  <div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t dark:border-gray-600">
17
17
  <h3 class="text-xl font-semibold text-gray-900 dark:text-white">
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div :key="`${$route?.params.resourceId}---${$route?.params.primaryKey}`">
2
+ <div>
3
3
  <RouterView/>
4
4
  </div>
5
5
  </template>
@@ -27,10 +27,10 @@
27
27
  </div>
28
28
  <div
29
29
  v-else
30
- class="relative overflow-x-auto shadow-resourse-form-shadow "
30
+ class="relative overflow-x-auto shadow-md sm:rounded-lg"
31
31
  >
32
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-form-view-heading dark:bg-gray-700 dark:text-gray-400">
33
+ <thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
34
34
  <tr>
35
35
  <th scope="col" class="px-6 py-3">
36
36
  Field
@@ -42,17 +42,13 @@
42
42
  </thead>
43
43
  <tbody>
44
44
  <tr v-for="column in coreStore.resourceColumns?.filter(c => c.showIn.includes('show'))" :key="column.name"
45
- class="bg-form-view-bg odd:dark:bg-gray-900 even:dark:bg-gray-800 border-b dark:border-gray-700"
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"
46
46
  >
47
47
  <td class="px-6 py-4 whitespace-nowrap">
48
48
  {{ column.label }}
49
49
  </td>
50
50
  <td class="px-6 py-4 whitespace-nowrap whitespace-pre-wrap">
51
- <component
52
- :is="showComponentsPerColumn[column.name] || ValueRenderer"
53
- :column="column"
54
- :row="coreStore.record"
55
- />
51
+ <ValueRenderer :column="column" :row="coreStore.record" />
56
52
  </td>
57
53
  </tr>
58
54
 
@@ -67,19 +63,18 @@
67
63
 
68
64
  <script setup>
69
65
 
66
+ import { ref, computed, onMounted } from 'vue';
67
+ import { useRoute } from 'vue-router';
68
+ import { callAdminForthApi } from '@/utils';
70
69
  import BreadcrumbsWithButtons from '@/components/BreadcrumbsWithButtons.vue';
71
- import ValueRenderer from '@/components/ValueRenderer.vue';
72
- import { useCoreStore } from '@/stores/core';
73
- import { getCustomComponent } from '@/utils';
74
70
  import { IconPenSolid, IconTrashBinSolid } from '@iconify-prerendered/vue-flowbite';
75
- import { onMounted, ref } from 'vue';
76
- import { useRoute } from 'vue-router';
71
+ import { useCoreStore } from '@/stores/core';
72
+ import ValueRenderer from '@/components/ValueRenderer.vue';
77
73
 
78
74
 
79
75
  const item = ref(null);
80
76
  const route = useRoute();
81
77
  const loading = ref(false);
82
- let showComponentsPerColumn = {};
83
78
 
84
79
  const coreStore = useCoreStore();
85
80
 
@@ -92,12 +87,6 @@ onMounted(async () => {
92
87
  resourceId: route.params.resourceId,
93
88
  primaryKey: route.params.primaryKey,
94
89
  });
95
- showComponentsPerColumn = coreStore.resourceColumns.reduce((acc, column) => {
96
- if (column.component?.show) {
97
- acc[column.name] = getCustomComponent(column.component.show);
98
- }
99
- return acc;
100
- }, {});
101
90
  loading.value = false;
102
91
  });
103
92
 
@@ -1,12 +1,9 @@
1
1
  /** @type {import('tailwindcss').Config} */
2
2
  export default {
3
- content: ["./src/**/*.{vue, js}","./src/*.{vue, js}", "./index.html", "./node_modules/flowbite/**/*.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.1.18",
3
+ "version": "1.1.19",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -7,9 +7,9 @@ export type PluginOptions = {
7
7
  * Called to check if user has access to a page
8
8
  * Should return `true` if user has access. If user has no access, return `false` or a string with an error message
9
9
  * @param user - The user object
10
- * @param page - The page to check access for
10
+ * @param action - The {@link AllowedActionsEnum} action
11
11
  * @param meta - The meta object containing query for list/show or record for save/edit
12
12
  * @returns {boolean | string} -
13
13
  */
14
- hasAccess: (user: AdminUser, page: AllowedActionsEnum, meta: any) => Promise<boolean | string>;
14
+ hasAccess: (user: AdminUser, action: AllowedActionsEnum, meta: any) => Promise<boolean | string>;
15
15
  }
@@ -283,6 +283,12 @@ export type AdminForthConfigMenuItem = {
283
283
  meta?: {
284
284
  title?: string,
285
285
  },
286
+
287
+ /**
288
+ * Optional callback which will be called before rendering the menu for each item.
289
+ * You can use it to hide menu items depending on some user
290
+ */
291
+ visible?: (user: AdminUser) => boolean,
286
292
  }
287
293
 
288
294
 
@@ -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>