Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
const props = defineProps<iLoaderContentFetchProps<T, P>>();
const emit = defineEmits(["refresh", "has-content", "hydrate"]);

const { logger, isBrowser } = useHelpers(useUtils);
const { logger } = useHelpers(useUtils);
const { useFetch } = useFetchUtils();
const { internals } = inject<iVuePluginOptions>("xamu") || {};
const useAsyncData: typeof useAsyncDataFn = internals?.useAsyncData ?? useAsyncDataFn;
Expand Down Expand Up @@ -237,7 +237,7 @@
(newContent) => {
const isContent = patchedIsContent(newContent);

if (isBrowser) emit("has-content", isContent, newContent, hydrate);
emit("has-content", isContent, newContent, hydrate);
},
{ immediate: true }
);
Expand Down
42 changes: 23 additions & 19 deletions packages/components-vue/src/components/pagination/ContentTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
createNodeAndRefresh,
}"
></slot>
<!-- Temporary head actions -->
<div
v-if="!emittedHasContent && $slots.headActions"
key="external-head-actions"
class="flx --flxRow --flx-start-center --gap-10 --gap:md"
>
<slot
name="headActions"
v-bind="{
refreshData,
hasContent: emittedHasContent,
hydrateData: emittedHydrateNodes,
createNodeAndRefresh,
}"
></slot>
</div>
<PaginationContent
v-slot="{ content }"
v-bind="{
Expand All @@ -25,21 +41,6 @@
@refresh="emittedRefresh = $event"
@has-content="hasContent"
>
<!-- Temporary head actions -->
<div
v-if="!emittedHasContent && $slots.headActions"
class="flx --flxRow --flx-start-center --gap-10 --gap:md"
>
<slot
name="headActions"
v-bind="{
refreshData,
hasContent: emittedHasContent,
hydrateData: emittedHydrateNodes,
createNodeAndRefresh,
}"
></slot>
</div>
<!-- Tabulated data -->
<div class="flx --flxColumn --flx-start-stretch">
<Table
Expand All @@ -60,7 +61,10 @@
}"
>
<template v-if="emittedHasContent && $slots.headActions" #headActions>
<div class="flx --flxRow --flx-start-center --gap-10 --gap:md">
<div
key="internal-head-actions"
class="flx --flxRow --flx-start-center --gap-10 --gap:md"
>
<slot
name="headActions"
v-bind="{
Expand Down Expand Up @@ -168,7 +172,7 @@
const Swal = useHelpers(useSwal);

const emittedRefresh = ref<() => void>();
const emittedHasContent = ref<boolean>(true);
const emittedHasContent = ref<boolean>();
const emittedContent = ref<T[] | null>();
const emittedHydrateNodes = ref<(newContent: T[] | null, newErrors?: unknown) => void>();

Expand Down Expand Up @@ -225,8 +229,8 @@
createdNodes = [created, ...(emittedContent.value || [])];
}

// Prefer hydration over refreshing
if (emittedHydrateNodes.value && createdNodes) {
// If has content, prefer hydration over refreshing
if (emittedHasContent.value && emittedHydrateNodes.value && createdNodes) {
emittedHydrateNodes.value(createdNodes);
} else if (!props.omitRefresh) refreshData();

Expand Down
8 changes: 6 additions & 2 deletions packages/components-vue/src/components/table/Body.vue
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,12 @@
title: t("swal.table_created"),
text: t("swal.table_created_text"),
willOpen() {
// Prefer hydration over refreshing
if (props.hydrateNodes && typeof updatedParent === "object") {
// If has children, prefer hydration over refreshing
if (
props.childrenCount(node) &&
props.hydrateNodes &&
typeof updatedParent === "object"
) {
hydrateNode({ ...node, ...updatedParent });
} else if (!props.omitRefresh) props.refresh?.();

Expand Down
2 changes: 1 addition & 1 deletion packages/components-vue/src/components/table/Simple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@
Swal.fireLoader();

let updatedNodes: T[] = [...props.nodes];
// run process
// run process in parallel
const deleted: iNodeFnResponse<T>[] = await Promise.all(
nodes.map(async (node) => {
const response = await useResolveNodeFn(props.deleteNode?.(node));
Expand Down