1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-05 13:35:23 +02:00

feat: User Tooltip (#4319)

This commit is contained in:
Michael Genson 2024-10-11 19:36:26 -05:00 committed by GitHub
parent a2bdb02a7f
commit e06572b7ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 164 additions and 80 deletions

View file

@ -2,6 +2,7 @@ import { ref, reactive, Ref } from "@nuxtjs/composition-api";
import { useReadOnlyActions, useStoreActions } from "./use-actions-factory";
import { BoundT } from "./types";
import { BaseCRUDAPI, BaseCRUDAPIReadOnly } from "~/lib/api/base/base-clients";
import { QueryValue } from "~/lib/api/base/route";
export const useData = function<T extends BoundT>(defaultObject: T) {
const data = reactive({ ...defaultObject });
@ -16,16 +17,21 @@ export const useReadOnlyStore = function<T extends BoundT>(
store: Ref<T[]>,
loading: Ref<boolean>,
api: BaseCRUDAPIReadOnly<T>,
params = {} as Record<string, QueryValue>,
) {
const storeActions = useReadOnlyActions(api, store, loading);
const actions = {
...useReadOnlyActions(api, store, loading),
...storeActions,
async refresh() {
return await storeActions.refresh(1, -1, params);
},
flushStore() {
store.value = [];
},
};
if (!loading.value && (!store.value || store.value.length === 0)) {
const result = actions.getAll();
const result = actions.getAll(1, -1, params);
store.value = result.value || [];
}
@ -36,16 +42,21 @@ export const useStore = function<T extends BoundT>(
store: Ref<T[]>,
loading: Ref<boolean>,
api: BaseCRUDAPI<unknown, T, unknown>,
params = {} as Record<string, QueryValue>,
) {
const storeActions = useStoreActions(api, store, loading);
const actions = {
...useStoreActions(api, store, loading),
...storeActions,
async refresh() {
return await storeActions.refresh(1, -1, params);
},
flushStore() {
store = ref([]);
},
};
if (!loading.value && (!store.value || store.value.length === 0)) {
const result = actions.getAll();
const result = actions.getAll(1, -1, params);
store.value = result.value || [];
}