Pedro Amorim
7e87e39040
Test plan: 1) Visit /cgi-bin/koha/erm/agreements/add 2) Notice the "Agreements" menu item is not active 3) Apply the tests patch only 4) Run tests, watch them fail 5) Apply this patch, restart yarn js:watch and hard refresh browser 6) Repeat steps 1) and 2) Verify it's now active 7) Run tests, watch them pass Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
81 lines
2.3 KiB
TypeScript
81 lines
2.3 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,
|
|
} from "@fortawesome/free-solid-svg-icons";
|
|
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
|
import vSelect from "vue-select";
|
|
|
|
library.add(faPlus, faMinus, faPencil, faTrash, faSpinner);
|
|
|
|
import App from "../components/ERM/Main.vue";
|
|
|
|
import { routes as routesDef } from "../routes/erm";
|
|
|
|
import { useMainStore } from "../stores/main";
|
|
import { useVendorStore } from "../stores/vendors";
|
|
import { useAVStore } from "../stores/authorised-values";
|
|
import { useERMStore } from "../stores/erm";
|
|
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(),
|
|
linkActiveClass: "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("vendorStore", useVendorStore(pinia));
|
|
app.provide("mainStore", mainStore);
|
|
app.provide("AVStore", AVStore);
|
|
app.provide("navigationStore", navigationStore);
|
|
const ERMStore = useERMStore(pinia);
|
|
app.provide("ERMStore", ERMStore);
|
|
|
|
app.mount("#erm");
|
|
|
|
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
|
|
});
|
|
router.afterEach((to, from) => {
|
|
let tab_id = "agreement"; // Agreements
|
|
|
|
if (to.path.match(/\/erm\/licenses/)) {
|
|
tab_id = "license";
|
|
} else if (to.path.match(/\/erm\/eholdings\/local\/packages/)) {
|
|
tab_id = "package";
|
|
} else if (to.path.match(/\/erm\/eholdings\/local\/titles/)) {
|
|
tab_id = "title";
|
|
}
|
|
let node = document.getElementById(`${tab_id}_search_tab`);
|
|
|
|
if (node) {
|
|
node.click();
|
|
}
|
|
});
|