View | Details | Raw Unified | Return to bug 34417
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js (+4 lines)
Lines 25-30 export class ERMAPIClient extends HttpClient { Link Here
25
                        "x-koha-embed":
25
                        "x-koha-embed":
26
                            "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents,agreement_packages,agreement_packages.package,vendor",
26
                            "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents,agreement_packages,agreement_packages.package,vendor",
27
                    },
27
                    },
28
                    class: 'agreement'
28
                }),
29
                }),
29
            getAll: query =>
30
            getAll: query =>
30
                this.getAll({
31
                this.getAll({
Lines 67-72 export class ERMAPIClient extends HttpClient { Link Here
67
                        "x-koha-embed":
68
                        "x-koha-embed":
68
                            "user_roles,user_roles.patron,vendor,documents",
69
                            "user_roles,user_roles.patron,vendor,documents",
69
                    },
70
                    },
71
                    class: 'license'
70
                }),
72
                }),
71
            getAll: query =>
73
            getAll: query =>
72
                this.getAll({
74
                this.getAll({
Lines 112-117 export class ERMAPIClient extends HttpClient { Link Here
112
                        "x-koha-embed":
114
                        "x-koha-embed":
113
                            "package_agreements,package_agreements.agreement,resources+count,vendor",
115
                            "package_agreements,package_agreements.agreement,resources+count,vendor",
114
                    },
116
                    },
117
                    class: 'local_package'
115
                }),
118
                }),
116
            getAll: query =>
119
            getAll: query =>
117
                this.getAll({
120
                this.getAll({
Lines 156-161 export class ERMAPIClient extends HttpClient { Link Here
156
                    headers: {
159
                    headers: {
157
                        "x-koha-embed": "resources,resources.package",
160
                        "x-koha-embed": "resources,resources.package",
158
                    },
161
                    },
162
                    class: 'local_title'
159
                }),
163
                }),
160
            delete: id =>
164
            delete: id =>
161
                this.delete({
165
                this.delete({
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js (-14 / +18 lines)
Lines 42-67 class HttpClient { Link Here
42
42
43
        if (error) throw Error(error);
43
        if (error) throw Error(error);
44
44
45
        const navigationStore = useNavigationStore()
46
        const { current } = navigationStore
47
        current.forEach(route => {
48
            const { title, path } = route.meta.self
49
            if(title && title.dynamic && res[title.identifier]) {
50
                navigationStore.setBreadcrumbParameter({
51
                    breadcrumbText: res[title.identifier],
52
                    path: path
53
                })
54
            }
55
        })
56
57
        return res;
45
        return res;
58
    }
46
    }
59
47
60
    get(params = {}) {
48
    async get(params = {}) {
61
        return this._fetchJSON(params.endpoint, params.headers, {
49
        const res = await this._fetchJSON(params.endpoint, params.headers, {
62
            ...params.options,
50
            ...params.options,
63
            method: "GET",
51
            method: "GET",
64
        });
52
        });
53
54
        const navigationStore = useNavigationStore()
55
        const { current } = navigationStore
56
        if(current && current.slice(-1)[0].routeClass === params.class) {
57
            current.forEach(route => {
58
                const { title, path } = route.meta.self
59
                if(title && title.dynamic && res[title.identifier]) {
60
                    navigationStore.setBreadcrumbParameter({
61
                        breadcrumbText: res[title.identifier],
62
                        path: path
63
                    })
64
                }
65
            })
66
        }
67
68
        return res
65
    }
69
    }
66
70
67
    getAll(params = {}) {
71
    getAll(params = {}) {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts (-2 / +21 lines)
Lines 60-66 app.mount("#erm"); Link Here
60
60
61
const { removeMessages } = mainStore;
61
const { removeMessages } = mainStore;
62
router.beforeEach((to, from) => {
62
router.beforeEach((to, from) => {
63
    navigationStore.setCurrent(to.matched)
63
    let matchedRoutes = []
64
    if (to.path.match(/\/erm\/agreements/)) {
65
        matchedRoutes = _setRouteClass(to.matched, 'agreement')
66
    } else if (to.path.match(/\/erm\/licenses/)) {
67
        matchedRoutes = _setRouteClass(to.matched, 'license')
68
    } else if (to.path.match(/\/erm\/eholdings\/local\/packages/)) {
69
        matchedRoutes = _setRouteClass(to.matched, 'local_package')
70
    } else if (to.path.match(/\/erm\/eholdings\/local\/titles/)) {
71
        matchedRoutes = _setRouteClass(to.matched, 'local_title')
72
    }
73
    navigationStore.setCurrent(matchedRoutes)
64
    navigationStore.setParams(to.params || {})
74
    navigationStore.setParams(to.params || {})
65
    navigationStore.setBreadcrumbParameter({})
75
    navigationStore.setBreadcrumbParameter({})
66
    removeMessages(); // This will actually flag the messages as displayed already
76
    removeMessages(); // This will actually flag the messages as displayed already
Lines 81-83 router.afterEach((to, from) => { Link Here
81
        node.click();
91
        node.click();
82
    }
92
    }
83
});
93
});
84
- 
94
95
const _setRouteClass = (routes: Array<Object>, routeClass: string) => {
96
    const classedRoutes = routes.map(route => {
97
        return {
98
            ...route,
99
            routeClass
100
        }
101
    })
102
    return classedRoutes
103
}

Return to bug 34417