Koha/koha-tmpl/intranet-tmpl/prog/js/vue/main-erm.ts
Jonathan Druart c564c8a696
Bug 32728: ERM - Update search header depending on navigation
Search header should change to match the section you are in.

Default is "agreement". If you are in "local titles" or "local
packages", the header will be positionned on the relevant tab.

To replicate:

1. Enable the ERM module: ERMModule system preference.
2. Go to the ERM module: Home > E-resource management.
3. Select the options from the sidebar menu (Agreements, Packages and Titles),
   and note that the ERM search header options don't change.
4. Add a minimal agreement, package and title.
5. Change the search header to another option, for example 'Search titles',
   then perform a search. Note that:
   - the appropriate sidebar menu option is highlighted, for example: 'Titles'
   - the search header changes back to 'Agreement search'
6. Apply patch, run yarn build
7. Verify the search options are now switched when moving between pages

Signed-off-by: Jonathan Field <jonathan.field@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-02-24 16:40:37 -03:00

71 lines
1.9 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/ERMMain.vue";
import { routes } from "./routes";
const router = createRouter({
history: createWebHistory(),
linkExactActiveClass: "current",
routes,
});
import { useMainStore } from "./stores/main";
import { useVendorStore } from "./stores/vendors";
import { useAVStore } from "./stores/authorised_values";
const pinia = createPinia();
const i18n = {
install: (app, options) => {
app.config.globalProperties.$__ = (key) => {
return window["__"](key);
};
},
};
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));
const mainStore = useMainStore(pinia);
app.provide("mainStore", mainStore);
app.provide("AVStore", useAVStore(pinia));
app.mount("#erm");
const { removeMessages } = mainStore;
router.beforeEach((to, from) => {
removeMessages(); // This will actually flag the messages as displayed already
});
router.afterEach((to, from) => {
let tab_id = 1; // Agreements
if ( to.path.match(/\/erm\/eholdings\/local\/titles/)){
tab_id = 2;
} else if ( to.path.match(/\/erm\/eholdings\/local\/packages/)){
tab_id = 3;
}
document.getElementById('ui-id-' + tab_id).click();
})