permission update on querystore

This commit is contained in:
Julian Krauser 2024-12-19 10:46:45 +01:00
parent ce8157e6bf
commit 3c4380c91b

View file

@ -5,6 +5,7 @@ import type { AxiosResponse } from "axios";
import { useQueryBuilderStore } from "./queryBuilder";
import { useModalStore } from "../modal";
import { defineAsyncComponent, markRaw } from "vue";
import { useAbilityStore } from "../ability";
export const useQueryStoreStore = defineStore("queryStore", {
state: () => {
@ -32,19 +33,20 @@ export const useQueryStoreStore = defineStore("queryStore", {
triggerSave() {
const queryBuilderStore = useQueryBuilderStore();
const modalStore = useModalStore();
if (queryBuilderStore.activeQueryId == undefined) {
modalStore.openModal(
markRaw(
defineAsyncComponent(() => import("@/components/admin/settings/queryStore/CreateQueryStoreModal.vue"))
)
);
} else {
const abilityStore = useAbilityStore();
if (queryBuilderStore.activeQueryId != undefined && abilityStore.can("update", "settings", "query_store")) {
modalStore.openModal(
markRaw(
defineAsyncComponent(() => import("@/components/admin/settings/queryStore/UpdateQueryStoreModal.vue"))
),
queryBuilderStore.activeQueryId
);
} else {
modalStore.openModal(
markRaw(
defineAsyncComponent(() => import("@/components/admin/settings/queryStore/CreateQueryStoreModal.vue"))
)
);
}
},
async createQueryStore(query: CreateQueryViewModel): Promise<AxiosResponse<any, any>> {