Skip to content

Commit 99d93c4

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
2 parents 48815e1 + 17ce665 commit 99d93c4

3 files changed

Lines changed: 51 additions & 36 deletions

File tree

adminforth/spa/src/afcl/Skeleton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div
1818
v-else-if="type === 'input'"
1919
role="input"
20-
:class="['animate-pulse bg-gray-100 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded', $attrs.class]"
20+
:class="['animate-pulse bg-gray-100 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-default', $attrs.class]"
2121
></div>
2222
<div v-else role="status" class="flex items-center justify-center animate-pulse bg-lightSkeletonIconColor rounded-full dark:bg-darkSkeletonBackgroundColor">
2323
<span class="sr-only">Loading...</span>

adminforth/spa/src/views/CreateEditSkeleton.vue

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,57 +11,72 @@
1111
</div>
1212
</div>
1313

14-
<div v-for="i in 5" :key="i"
15-
class="flex items-center bg-lightForm dark:bg-darkForm border-b border-gray-100 dark:border-darkFormBorder"
16-
:style="{ height: i === 2 ? '95px' : '75px' }"
17-
>
18-
<div class="w-[208px] flex-shrink-0 px-6 flex items-center gap-1">
14+
<template v-for="column in visibleColumns" :key="column.name">
15+
<div
16+
class="flex items-center bg-lightForm dark:bg-darkForm border-b border-gray-100 dark:border-darkFormBorder"
17+
:style="{ height: getFieldHeight(column) }"
18+
>
19+
<div class="w-[208px] flex-shrink-0 px-6 flex items-center">
1920
<Skeleton class="w-24 h-[10px]" />
2021
</div>
21-
22-
<div class="flex-1 px-6">
23-
<div v-if="i === 2">
24-
<Skeleton type="input" class="h-[42px] w-[160px]" />
25-
<Skeleton class="mt-1 h-[12px] w-20" />
26-
</div>
27-
<Skeleton type="input" v-else-if="i === 4 || i === 5" class="h-[42px] w-[160px]" />
28-
<Skeleton v-else type="input" class="h-[42px] w-full" />
29-
</div>
30-
</div>
3122

32-
<div class="flex items-start bg-lightForm dark:bg-darkForm" style="height: 759px;">
33-
<div class="w-[208px] flex-shrink-0 px-6 pt-7">
34-
<Skeleton class="w-24 h-[10px]" />
35-
</div>
36-
37-
<div class="flex-1 px-6 pt-4 h-full flex flex-col">
38-
<div class="flex flex-wrap items-center gap-3 p-1.5 border border-gray-300 dark:border-gray-600 rounded-t-lg bg-gray-50 dark:bg-gray-800 w-full box-border h-[44px]">
39-
<template v-for="btn in skeletonButtons" :key="btn.id">
40-
<div class=" animate-pulse flex items-center justify-center h-8 px-1 text-gray-300 dark:text-gray-600">
41-
<component :is="btn.icon" class="w-5 h-5" />
42-
</div>
43-
<div v-if="btn.sep" class="w-px h-4 bg-gray-300 dark:bg-gray-600 mx-1"></div>
44-
</template>
23+
<div class="flex-1 px-6">
24+
<Skeleton type="input" :class="getSkeletonInputClass(column)" />
25+
26+
<div v-if="hasEditingNote(column)" class="mt-1">
27+
<Skeleton class="h-[12px] w-20" />
28+
</div>
4529
</div>
46-
<div class="flex-1 animate-pulse bg-white dark:bg-gray-950 border-x border-b border-gray-200 dark:border-gray-700 rounded-b-lg w-full shadow-inner"></div>
47-
<div class="h-10"></div>
4830
</div>
49-
</div>
31+
32+
</template>
5033
</div>
5134
</div>
5235
</template>
5336

5437
<script setup lang="ts">
55-
import { markRaw } from 'vue';
56-
import { IconExclamationCircleSolid } from '@iconify-prerendered/vue-flowbite';
57-
import {
38+
import { computed, markRaw } from 'vue';
39+
import {
5840
IconLinkOutline, IconCodeOutline, IconRectangleListOutline,
5941
IconOrderedListOutline, IconLetterBoldOutline, IconLetterUnderlineOutline,
6042
IconLetterItalicOutline, IconTextSlashOutline
6143
} from '@iconify-prerendered/vue-flowbite';
6244
import { IconH116Solid, IconH216Solid, IconH316Solid } from '@iconify-prerendered/vue-heroicons';
6345
import { Skeleton } from '@/afcl';
6446
47+
interface Props {
48+
resource?: any;
49+
page?: string;}
50+
51+
const props = withDefaults(defineProps<Props>(), {
52+
page: 'edit'
53+
});
54+
55+
const visibleColumns = computed(() => {
56+
if (!props.resource?.columns) return [];
57+
58+
return props.resource.columns.filter((col: any) => {
59+
if (col.virtual) return false;
60+
if (col.primaryKey) return false;
61+
if (col.backendOnly) return false;
62+
if (col.showIn?.[props.page] === false) return false;
63+
return true;
64+
});
65+
});
66+
67+
68+
const hasEditingNote = (column: any) => !!column.editingNote;
69+
70+
const getFieldHeight = (column: any) =>
71+
hasEditingNote(column) ? '95px' : '75px';
72+
73+
const getSkeletonInputClass = (column: any) => {
74+
if (['integer', 'decimal', 'float'].includes(column.type)) {
75+
return 'h-[42px] w-[160px]';
76+
}
77+
return 'h-[42px] w-full';
78+
};
79+
6580
const skeletonButtons = [
6681
{ id: 'bold', icon: markRaw(IconLetterBoldOutline), sep: false },
6782
{ id: 'italic', icon: markRaw(IconLetterItalicOutline), sep: false },

adminforth/spa/src/views/EditView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
:adminUser="coreStore.adminUser"
4242
/>
4343

44-
<CreateEditSkeleton v-if="loading"></CreateEditSkeleton>
44+
<CreateEditSkeleton :resource="coreStore.resource" v-if="loading"></CreateEditSkeleton>
4545

4646
<ResourceForm
4747
v-else-if="coreStore.resource"

0 commit comments

Comments
 (0)