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>
This commit is contained in:
Jonathan Druart 2023-01-31 17:20:14 +01:00 committed by Tomas Cohen Arazi
parent 4a28d42959
commit c564c8a696
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -60,3 +60,12 @@ 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();
})