adminforth 2.4.0-next.125 → 2.4.0-next.127

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.
@@ -44,9 +44,9 @@
44
44
  <i18n-t
45
45
  keypath="Showing {from} to {to} of {total}" tag="span" class="afcl-table-pagination-text text-sm font-normal text-lightTablePaginationText dark:text-darkTablePaginationText mb-4 md:mb-0 block w-full md:inline md:w-auto"
46
46
  >
47
- <template #from><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{ Math.min((currentPage - 1) * props.pageSize + 1, props.data.length) }}</span></template>
48
- <template #to><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{ Math.min(currentPage * props.pageSize, props.data.length) }}</span></template>
49
- <template #total><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{ props.data.length }}</span></template>
47
+ <template #from><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{ Math.min((currentPage - 1) * props.pageSize + 1, dataResult.total) }}</span></template>
48
+ <template #to><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{ Math.min(currentPage * props.pageSize, dataResult.total) }}</span></template>
49
+ <template #total><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{ dataResult.total }}</span></template>
50
50
  </i18n-t>
51
51
 
52
52
  <ul class="afcl-table-pagination-list inline-flex -space-x-px rtl:space-x-reverse text-sm h-8">
@@ -74,6 +74,8 @@
74
74
 
75
75
  <script setup lang="ts">
76
76
  import { ref, type Ref, computed } from 'vue';
77
+ import { asyncComputed } from '@vueuse/core';
78
+ import { IconArrowRightOutline, IconArrowLeftOutline } from '@iconify-prerendered/vue-flowbite';
77
79
 
78
80
  const props = withDefaults(
79
81
  defineProps<{
@@ -83,7 +85,7 @@
83
85
  }[],
84
86
  data: {
85
87
  [key: string]: any,
86
- }[],
88
+ }[] | ((offset: number, limit: number) => Promise<{data: {[key: string]: any}[], total: number}>),
87
89
  evenHighlights?: boolean,
88
90
  pageSize?: number,
89
91
  }>(), {
@@ -94,14 +96,21 @@
94
96
 
95
97
  const currentPage = ref(1);
96
98
 
99
+ const dataResult = asyncComputed( async() => {
100
+ if (typeof props.data === 'function') {
101
+ return await props.data(currentPage.value, props.pageSize);
102
+ }
103
+ const start = (currentPage.value - 1) * props.pageSize;
104
+ const end = start + props.pageSize;
105
+ return { data: props.data.slice(start, end), total: props.data.length };
106
+ });
107
+
97
108
  const totalPages = computed(() => {
98
- return Math.ceil(props.data.length / props.pageSize);
109
+ return dataResult.value?.total ? Math.ceil(dataResult.value.total / props.pageSize) : 1;
99
110
  });
100
111
 
101
- const dataPage = computed(() => {
102
- const start = (currentPage.value - 1) * props.pageSize;
103
- const end = start + props.pageSize;
104
- return props.data.slice(start, end);
112
+ const dataPage = asyncComputed( async() => {
113
+ return dataResult.value.data;
105
114
  });
106
115
 
107
116
  function switchPage(p: number) {
@@ -21,8 +21,9 @@
21
21
  'pointer-events-none': checkboxes && checkboxes.length === 0 && item.meta?.disabledWhenNoCheckboxes,
22
22
  'opacity-50': checkboxes && checkboxes.length === 0 && item.meta?.disabledWhenNoCheckboxes,
23
23
  'cursor-not-allowed': checkboxes && checkboxes.length === 0 && item.meta?.disabledWhenNoCheckboxes,
24
- }">
25
- <component :is="getCustomComponent(item)"
24
+ }"
25
+ @click="injectedComponentClick(i)">
26
+ <component :ref="(el: any) => setComponentRef(el, i)" :is="getCustomComponent(item)"
26
27
  :meta="item.meta"
27
28
  :resource="coreStore.resource"
28
29
  :adminUser="coreStore.adminUser"
@@ -75,10 +76,12 @@ import adminforth from '@/adminforth';
75
76
  import { callAdminForthApi } from '@/utils';
76
77
  import { useRoute, useRouter } from 'vue-router';
77
78
  import type { AdminForthComponentDeclarationFull, AdminForthBulkActionCommon, AdminForthActionInput } from '@/types/Common.js';
79
+ import { ref, type ComponentPublicInstance } from 'vue';
78
80
 
79
81
  const route = useRoute();
80
82
  const coreStore = useCoreStore();
81
83
  const router = useRouter();
84
+ const threeDotsDropdownItemsRefs = ref<Array<ComponentPublicInstance | null>>([]);
82
85
 
83
86
  const props = defineProps({
84
87
  threeDotsDropdownItems: Array<AdminForthComponentDeclarationFull>,
@@ -95,6 +98,12 @@ const props = defineProps({
95
98
 
96
99
  const emit = defineEmits(['startBulkAction']);
97
100
 
101
+ function setComponentRef(el: ComponentPublicInstance | null, index: number) {
102
+ if (el) {
103
+ threeDotsDropdownItemsRefs.value[index] = el;
104
+ }
105
+ }
106
+
98
107
  async function handleActionClick(action: AdminForthActionInput) {
99
108
  adminforth.list.closeThreeDotsDropdown();
100
109
 
@@ -151,4 +160,11 @@ function startBulkAction(actionId: string) {
151
160
  adminforth.list.closeThreeDotsDropdown();
152
161
  emit('startBulkAction', actionId);
153
162
  }
163
+
164
+ async function injectedComponentClick(index: number) {
165
+ const componentRef = threeDotsDropdownItemsRefs.value[index];
166
+ if (componentRef && 'click' in componentRef) {
167
+ (componentRef as any).click?.();
168
+ }
169
+ }
154
170
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "2.4.0-next.125",
3
+ "version": "2.4.0-next.127",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",