Koha/koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts
Jonathan Druart f5c581b0ad
Bug 30708: Rebase - Use a dedicated 'config' endpoint
To retrieve the sysprefs, instead of using the svc script. See bug
33606.

Signed-off-by: Laurence Rault <laurence.rault@biblibre.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-10-18 15:42:00 -03:00

75 lines
2 KiB
TypeScript

import { createApp } from "vue";
import { createWebHistory, createRouter } from "vue-router";
import { createPinia } from "pinia";
import { library } from "@fortawesome/fontawesome-svg-core";
import {
faPlus,
faMinus,
faPencil,
faTrash,
faSpinner,
faClose,
faPaperPlane,
faInbox,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import vSelect from "vue-select";
library.add(
faPlus,
faMinus,
faPencil,
faTrash,
faSpinner,
faClose,
faPaperPlane,
faInbox
);
import App from "../components/Preservation/Main.vue";
import { routes as routesDef } from "../routes/preservation";
import { useMainStore } from "../stores/main";
import { useAVStore } from "../stores/authorised-values";
import { usePreservationStore } from "../stores/preservation";
import { useNavigationStore } from "../stores/navigation";
import i18n from "../i18n";
const pinia = createPinia();
const mainStore = useMainStore(pinia);
const AVStore = useAVStore(pinia);
const navigationStore = useNavigationStore(pinia);
const routes = navigationStore.setRoutes(routesDef);
const router = createRouter({
history: createWebHistory(),
linkExactActiveClass: "current",
routes,
});
const app = createApp(App);
const rootComponent = app
.use(i18n)
.use(pinia)
.use(router)
.component("font-awesome-icon", FontAwesomeIcon)
.component("v-select", vSelect);
app.config.unwrapInjectedRef = true;
app.provide("mainStore", mainStore);
app.provide("AVStore", useAVStore(pinia));
app.provide("navigationStore", navigationStore);
const PreservationStore = usePreservationStore(pinia);
app.provide("PreservationStore", PreservationStore);
app.mount("#preservation");
const { removeMessages } = mainStore;
router.beforeEach((to, from) => {
navigationStore.$patch({ current: to.matched, params: to.params || {} });
removeMessages(); // This will actually flag the messages as displayed already
});