From 8107222e8ccde2ed5ec3dda31aa19300735d384d Mon Sep 17 00:00:00 2001 From: Jarlem Red de Peralta Date: Wed, 23 Nov 2022 15:13:57 +0800 Subject: [PATCH] intrn(component): generalize resetting of resource --- .../helpers/reset_resource_list.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/components/resource_management/helpers/reset_resource_list.ts b/components/resource_management/helpers/reset_resource_list.ts index e69de29bb..281ef24c5 100644 --- a/components/resource_management/helpers/reset_resource_list.ts +++ b/components/resource_management/helpers/reset_resource_list.ts @@ -0,0 +1,35 @@ +import { Ref } from "vue" + +import type { + ResourceIdentifier, + Attributes, + + DeserializedResource, + DeserializedResourceListDocument +} from "$/types/documents/base" + + +export default async function< + T extends ResourceIdentifier<"read">, + U extends Attributes<"deserialized">, + V extends DeserializedResource, + W extends DeserializedResourceListDocument +>( + list: Ref, + receivedErrors: Ref, + selectedIDs: Ref, + fetchResourceInfo: () => Promise +) { + list.value = { + ...list.value, + "data": [], + "meta": { + ...list.value.meta, + "count": 0 + } + } + receivedErrors.value = [] + selectedIDs.value = [] + + await fetchResourceInfo() +}