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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Breadcrumbs.vue (+43 lines)
Line 0 Link Here
1
<template>
2
    <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
3
        <ol>
4
            <template v-for="(item, idx) in breadcrumbs" v-bind:key="idx">
5
                <NavigationItem
6
                    v-if="idx < breadcrumbs.length - 1"
7
                    :item="item"
8
                ></NavigationItem>
9
                <NavigationItem
10
                    v-else
11
                    :item="{ ...item, path: undefined, href: undefined }"
12
                ></NavigationItem>
13
            </template>
14
        </ol>
15
    </nav>
16
</template>
17
18
<script>
19
import { inject } from "vue"
20
import { storeToRefs } from "pinia"
21
import NavigationItem from "./NavigationItem.vue"
22
export default {
23
    name: "Breadcrumbs",
24
    setup: () => {
25
        const navigationStore = inject("navigationStore")
26
        const { breadcrumbs } = storeToRefs(navigationStore)
27
        return {
28
            breadcrumbs,
29
        }
30
    },
31
    components: {
32
        NavigationItem,
33
    },
34
}
35
</script>
36
37
<style>
38
#breadcrumbs ol li a.disabled {
39
    color: #666;
40
    pointer-events: none;
41
    font-weight: 700;
42
}
43
</style>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue (-98 / +23 lines)
Lines 1-6 Link Here
1
<template>
1
<template>
2
    <div v-if="ERMModule">
2
    <div v-if="ERMModule">
3
        <Breadcrumb />
3
        <Breadcrumbs />
4
        <div class="main container-fluid">
4
        <div class="main container-fluid">
5
            <div class="row">
5
            <div class="row">
6
                <div class="col-sm-10 col-sm-push-2">
6
                <div class="col-sm-10 col-sm-push-2">
Lines 11-110 Link Here
11
                </div>
11
                </div>
12
12
13
                <div class="col-sm-2 col-sm-pull-10">
13
                <div class="col-sm-2 col-sm-pull-10">
14
                    <aside>
14
                    <LeftMenu
15
                        <div id="navmenu">
15
                        :title="$__('E-resource management')"
16
                            <div id="navmenulist">
16
                        :condition="filterProviders"
17
                                <h5>{{ $__("E-resource management") }}</h5>
17
                    ></LeftMenu>
18
                                <ul>
19
                                    <li>
20
                                        <router-link
21
                                            to="/cgi-bin/koha/erm/agreements"
22
                                        >
23
                                            <i class="fa fa-check-circle-o"></i>
24
                                            {{ $__("Agreements") }}</router-link
25
                                        >
26
                                    </li>
27
                                    <li>
28
                                        <router-link
29
                                            to="/cgi-bin/koha/erm/licenses"
30
                                        >
31
                                            <i class="fa fa-gavel"></i>
32
                                            {{ $__("Licenses") }}</router-link
33
                                        >
34
                                    </li>
35
                                    <li>
36
                                        <router-link
37
                                            to="/cgi-bin/koha/erm/eholdings"
38
                                            class="disabled"
39
                                        >
40
                                            <i class="fa fa-crosshairs"></i>
41
                                            {{ $__("eHoldings") }}
42
                                        </router-link>
43
                                    </li>
44
45
                                    <li>
46
                                        <ul>
47
                                            <li
48
                                                v-for="provider in erm_providers"
49
                                                :key="provider"
50
                                            >
51
                                                <router-link
52
                                                    v-if="provider == 'local'"
53
                                                    :to="`/cgi-bin/koha/erm/eholdings/local`"
54
                                                    class="disabled"
55
                                                >
56
                                                    <i
57
                                                        class="fa fa-map-marker"
58
                                                    ></i>
59
                                                    {{
60
                                                        $__("Local")
61
                                                    }}</router-link
62
                                                >
63
                                                <router-link
64
                                                    v-else-if="
65
                                                        provider == 'ebsco'
66
                                                    "
67
                                                    :to="`/cgi-bin/koha/erm/eholdings/ebsco`"
68
                                                    class="disabled"
69
                                                >
70
                                                    <i class="fa fa-globe"></i>
71
                                                    {{
72
                                                        $__("EBSCO")
73
                                                    }}</router-link
74
                                                >
75
                                                <ul>
76
                                                    <li>
77
                                                        <router-link
78
                                                            :to="`/cgi-bin/koha/erm/eholdings/${provider}/packages`"
79
                                                        >
80
                                                            <i
81
                                                                class="fa fa-archive"
82
                                                            ></i>
83
                                                            {{
84
                                                                $__("Packages")
85
                                                            }}</router-link
86
                                                        >
87
                                                    </li>
88
                                                    <li>
89
                                                        <router-link
90
                                                            :to="`/cgi-bin/koha/erm/eholdings/${provider}/titles`"
91
                                                        >
92
                                                            <i
93
                                                                class="fa fa-sort-alpha-asc"
94
                                                            ></i>
95
                                                            {{
96
                                                                $__("Titles")
97
                                                            }}</router-link
98
                                                        >
99
                                                    </li>
100
                                                </ul>
101
                                            </li>
102
                                        </ul>
103
                                    </li>
104
                                </ul>
105
                            </div>
106
                        </div>
107
                    </aside>
108
                </div>
18
                </div>
109
            </div>
19
            </div>
110
        </div>
20
        </div>
Lines 116-123 Link Here
116
26
117
<script>
27
<script>
118
import { inject } from "vue"
28
import { inject } from "vue"
119
import Breadcrumb from "../../components/Breadcrumb.vue"
29
import Breadcrumbs from "../Breadcrumbs.vue"
120
import Dialog from "../../components/Dialog.vue"
30
import LeftMenu from "../LeftMenu.vue"
31
import Dialog from "../Dialog.vue"
121
import { APIClient } from "../../fetch/api-client.js"
32
import { APIClient } from "../../fetch/api-client.js"
122
import "vue-select/dist/vue-select.css"
33
import "vue-select/dist/vue-select.css"
123
import { storeToRefs } from "pinia"
34
import { storeToRefs } from "pinia"
Lines 202-210 export default { Link Here
202
            })
113
            })
203
            .then(() => this.loaded())
114
            .then(() => this.loaded())
204
    },
115
    },
116
    methods: {
117
        filterProviders(navigationTree) {
118
            const eHoldings = navigationTree.find(
119
                element => element.path === "/cgi-bin/koha/erm/eholdings"
120
            )
121
            eHoldings.children = eHoldings.children.filter(element =>
122
                this.erm_providers
123
                    .map(provider => `${eHoldings.path}/${provider}`)
124
                    .includes(element.path)
125
            )
126
            return navigationTree
127
        },
128
    },
205
    components: {
129
    components: {
206
        Breadcrumb,
130
        Breadcrumbs,
207
        Dialog,
131
        Dialog,
132
        LeftMenu,
208
    },
133
    },
209
}
134
}
210
</script>
135
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/LeftMenu.vue (+67 lines)
Line 0 Link Here
1
<template>
2
    <aside>
3
        <div id="navmenu">
4
            <div id="navmenulist">
5
                <h5>{{ $__(title) }}</h5>
6
                <ul>
7
                    <NavigationItem
8
                        v-for="(item, key) in navigationTree"
9
                        v-bind:key="key"
10
                        :item="item"
11
                    ></NavigationItem>
12
                </ul>
13
            </div>
14
        </div>
15
    </aside>
16
</template>
17
18
<script>
19
import { inject } from "vue"
20
import NavigationItem from "./NavigationItem.vue"
21
export default {
22
    name: "LeftMenu",
23
    data() {
24
        return {
25
            navigationTree: this.leftNavigation,
26
        }
27
    },
28
    setup: () => {
29
        const navigationStore = inject("navigationStore")
30
        const { leftNavigation } = navigationStore
31
        return {
32
            leftNavigation,
33
        }
34
    },
35
    async beforeMount() {
36
        if (this.condition)
37
            this.navigationTree = this.condition(this.navigationTree)
38
    },
39
    props: {
40
        title: String,
41
        condition: Function,
42
    },
43
    components: {
44
        NavigationItem,
45
    },
46
}
47
</script>
48
49
<style scoped>
50
#navmenulist a.router-link-active {
51
    font-weight: 700;
52
}
53
#menu ul ul,
54
#navmenulist ul ul {
55
    padding-left: 2em;
56
    font-size: 100%;
57
}
58
59
#navmenulist ul li a.disabled {
60
    color: #666;
61
    pointer-events: none;
62
    font-weight: 700;
63
}
64
#navmenulist ul li a.disabled.router-link-active {
65
    color: #000;
66
}
67
</style>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/NavigationItem.vue (+55 lines)
Line 0 Link Here
1
<template>
2
    <li>
3
        <span>
4
            <router-link
5
                v-if="item.path"
6
                :to="item.path"
7
                :class="{ disabled: item.disabled }"
8
            >
9
                <template v-if="item.icon">
10
                    <i :class="`fa ${item.icon}`"></i>&nbsp;
11
                </template>
12
                <span v-if="item.title">{{ $__(item.title) }}</span>
13
            </router-link>
14
            <a
15
                v-else-if="item.href"
16
                :href="item.href"
17
                :class="{ disabled: item.disabled }"
18
            >
19
                <template v-if="item.icon">
20
                    <i :class="`fa ${item.icon}`"></i>&nbsp;
21
                </template>
22
                <span v-if="item.title">{{ $__(item.title) }}</span>
23
            </a>
24
            <span v-else>
25
                <template v-if="item.icon">
26
                    <i :class="`fa ${item.icon}`"></i>&nbsp;
27
                </template>
28
                <span class="item-last" v-if="item.title">{{
29
                    $__(item.title)
30
                }}</span>
31
            </span>
32
        </span>
33
        <ul v-if="item.children && item.children.length">
34
            <NavigationItem
35
                v-for="(item, key) in item.children"
36
                :item="item"
37
            ></NavigationItem>
38
        </ul>
39
    </li>
40
</template>
41
42
<script>
43
export default {
44
    name: "NavigationItem",
45
    props: {
46
        item: Object,
47
    },
48
}
49
</script>
50
51
<style>
52
span.item-last {
53
    padding: 7px 3px;
54
}
55
</style>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts (-9 / +15 lines)
Lines 17-33 library.add(faPlus, faMinus, faPencil, faTrash, faSpinner); Link Here
17
17
18
import App from "../components/ERM/Main.vue";
18
import App from "../components/ERM/Main.vue";
19
19
20
import { routes } from "../routes/erm";
20
import { routes as routesDef } from "../routes/erm";
21
22
const router = createRouter({
23
    history: createWebHistory(),
24
    linkExactActiveClass: "current",
25
    routes,
26
});
27
21
28
import { useMainStore } from "../stores/main";
22
import { useMainStore } from "../stores/main";
29
import { useVendorStore } from "../stores/vendors";
23
import { useVendorStore } from "../stores/vendors";
30
import { useAVStore } from "../stores/authorised-values";
24
import { useAVStore } from "../stores/authorised-values";
25
import { useNavigationStore } from "../stores/navigation";
31
26
32
const pinia = createPinia();
27
const pinia = createPinia();
33
28
Lines 39-44 const i18n = { Link Here
39
    },
34
    },
40
};
35
};
41
36
37
const mainStore = useMainStore(pinia);
38
const AVStore = useAVStore(pinia);
39
const navigationStore = useNavigationStore(pinia);
40
const routes = navigationStore.setRoutes(routesDef);
41
42
const router = createRouter({
43
    history: createWebHistory(),
44
    linkExactActiveClass: "current",
45
    routes,
46
});
47
42
const app = createApp(App);
48
const app = createApp(App);
43
49
44
const rootComponent = app
50
const rootComponent = app
Lines 50-64 const rootComponent = app Link Here
50
56
51
app.config.unwrapInjectedRef = true;
57
app.config.unwrapInjectedRef = true;
52
app.provide("vendorStore", useVendorStore(pinia));
58
app.provide("vendorStore", useVendorStore(pinia));
53
const mainStore = useMainStore(pinia);
54
app.provide("mainStore", mainStore);
59
app.provide("mainStore", mainStore);
55
const AVStore = useAVStore(pinia);
56
app.provide("AVStore", AVStore);
60
app.provide("AVStore", AVStore);
61
app.provide("navigationStore", navigationStore);
57
62
58
app.mount("#erm");
63
app.mount("#erm");
59
64
60
const { removeMessages } = mainStore;
65
const { removeMessages } = mainStore;
61
router.beforeEach((to, from) => {
66
router.beforeEach((to, from) => {
67
    navigationStore.$patch({current: to.meta.self});
62
    removeMessages(); // This will actually flag the messages as displayed already
68
    removeMessages(); // This will actually flag the messages as displayed already
63
});
69
});
64
router.afterEach((to, from) => {
70
router.afterEach((to, from) => {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/erm.js (-410 / +154 lines)
Lines 19-118 import LicensesList from "../components/ERM/LicensesList.vue"; Link Here
19
import LicensesShow from "../components/ERM/LicensesShow.vue";
19
import LicensesShow from "../components/ERM/LicensesShow.vue";
20
import LicensesFormAdd from "../components/ERM/LicensesFormAdd.vue";
20
import LicensesFormAdd from "../components/ERM/LicensesFormAdd.vue";
21
21
22
const breadcrumbs = {
23
    home: {
24
        text: "Home", // $t("Home")
25
        path: "/cgi-bin/koha/mainpage.pl",
26
    },
27
    erm_home: {
28
        text: "E-resource management", // $t("E-resource management")
29
        path: "/cgi-bin/koha/erm/erm.pl",
30
    },
31
    agreements: {
32
        text: "Agreements", // $t("Agreements")
33
        path: "/cgi-bin/koha/erm/agreements",
34
    },
35
    eholdings: {
36
        home: {
37
            text: "eHoldings", // $t("eHoldings")
38
        },
39
        local: {
40
            home: {
41
                text: "Local", // $t("Local")
42
            },
43
            titles: {
44
                text: "Titles", // $t("Titles")
45
                path: "/cgi-bin/koha/erm/eholdings/local/titles",
46
            },
47
            packages: {
48
                text: "Packages", // $t("Packages")
49
                path: "/cgi-bin/koha/erm/eholdings/local/packages",
50
            },
51
        },
52
        ebsco: {
53
            home: {
54
                text: "EBSCO", // $t("EBSCO")
55
            },
56
            titles: {
57
                text: "Titles", // $t("Titles")
58
                path: "/cgi-bin/koha/erm/eholdings/ebsco/titles",
59
            },
60
            packages: {
61
                text: "Packages", // $t("Packages")
62
                path: "/cgi-bin/koha/erm/eholdings/ebsco/packages",
63
            },
64
        },
65
    },
66
    licenses: {
67
        text: "Licenses", // $t("Licenses")
68
        path: "/cgi-bin/koha/erm/licenses",
69
    },
70
};
71
const breadcrumb_paths = {
72
    agreements: [
73
        breadcrumbs.home,
74
        breadcrumbs.erm_home,
75
        breadcrumbs.agreements,
76
    ],
77
    eholdings: [
78
        breadcrumbs.home,
79
        breadcrumbs.erm_home,
80
        breadcrumbs.eholdings.home,
81
    ],
82
    eholdings_local: [
83
        breadcrumbs.home,
84
        breadcrumbs.erm_home,
85
        breadcrumbs.eholdings.home,
86
        breadcrumbs.eholdings.local.home,
87
    ],
88
    eholdings_ebsco: [
89
        breadcrumbs.home,
90
        breadcrumbs.erm_home,
91
        breadcrumbs.eholdings.home,
92
        breadcrumbs.eholdings.ebsco.home,
93
    ],
94
    licenses: [breadcrumbs.home, breadcrumbs.erm_home, breadcrumbs.licenses],
95
};
96
97
function build_breadcrumb(parent_breadcrumb, current) {
98
    let breadcrumb = parent_breadcrumb.flat(Infinity);
99
    if (current) {
100
        breadcrumb.push({
101
            text: current,
102
        });
103
    }
104
    return breadcrumb;
105
}
106
107
export const routes = [
22
export const routes = [
108
    {
109
        path: "/cgi-bin/koha/mainpage.pl",
110
        beforeEnter(to, from, next) {
111
            window.location.href = "/cgi-bin/koha/mainpage.pl";
112
        },
113
    },
114
    {
23
    {
115
        path: "/cgi-bin/koha/admin/background_jobs/:id",
24
        path: "/cgi-bin/koha/admin/background_jobs/:id",
25
        is_base: true,
116
        beforeEnter(to, from, next) {
26
        beforeEnter(to, from, next) {
117
            window.location.href =
27
            window.location.href =
118
                "/cgi-bin/koha/admin/background_jobs.pl?op=view&id=" +
28
                "/cgi-bin/koha/admin/background_jobs.pl?op=view&id=" +
Lines 121-484 export const routes = [ Link Here
121
    },
31
    },
122
    {
32
    {
123
        path: "/cgi-bin/koha/erm/erm.pl",
33
        path: "/cgi-bin/koha/erm/erm.pl",
124
        component: Home,
34
        component: {template: '<router-view />'},
125
        meta: {
35
        is_default: true,
126
            breadcrumb: () => [breadcrumbs.home, breadcrumbs.erm_home],
36
        is_base: true,
127
        },
37
        title: 'E-resource management',
128
    },
129
    {
130
        path: "/cgi-bin/koha/erm/agreements",
131
        children: [
38
        children: [
132
            {
39
            {
133
                path: "",
40
                path: "",
134
                component: AgreementsList,
41
                component: Home,
135
                meta: {
42
                is_navigation_item: false,
136
                    breadcrumb: () => breadcrumb_paths.agreements,
137
                },
138
            },
43
            },
139
            {
44
            {
140
                path: ":agreement_id",
45
                path: "/cgi-bin/koha/erm/agreements",
141
                component: AgreementsShow,
46
                title: 'Agreements',
142
                meta: {
47
                icon: 'fa-check-circle-o',
143
                    breadcrumb: () =>
48
                is_end_node: true,
144
                        build_breadcrumb(
145
                            breadcrumb_paths.agreements,
146
                            "Show agreement" // $t("Show agreement")
147
                        ),
148
                },
149
            },
150
            {
151
                path: "add",
152
                component: AgreementsFormAdd,
153
                meta: {
154
                    breadcrumb: () =>
155
                        build_breadcrumb(
156
                            breadcrumb_paths.agreements,
157
                            "Add agreement" // $t("Add agreement")
158
                        ),
159
                },
160
            },
161
            {
162
                path: "edit/:agreement_id",
163
                component: AgreementsFormAdd,
164
                meta: {
165
                    breadcrumb: () =>
166
                        build_breadcrumb(
167
                            breadcrumb_paths.agreements,
168
                            "Edit agreement" // $t("Edit agreement")
169
                        ),
170
                },
171
            },
172
        ],
173
    },
174
    {
175
        path: "/cgi-bin/koha/erm/eholdings",
176
        meta: {
177
            breadcrumb: () => breadcrumb_paths.eholdings,
178
        },
179
        children: [
180
            {
181
                path: "",
182
                meta: {
183
                    breadcrumb: () => breadcrumb_paths.eholdings,
184
                },
185
            },
186
            {
187
                path: "local",
188
                children: [
49
                children: [
189
                    {
50
                    {
190
                        path: "",
51
                        path: "",
191
                        meta: {
52
                        component: AgreementsList,
192
                            breadcrumb: () => breadcrumb_paths.eholdings_local,
193
                        },
194
                    },
53
                    },
195
                    {
54
                    {
196
                        path: "packages",
55
                        path: ":agreement_id",
197
                        children: [
56
                        component: AgreementsShow,
198
                            {
57
                        title: "Show agreement",
199
                                path: "",
200
                                component: EHoldingsLocalPackagesList,
201
                                meta: {
202
                                    breadcrumb: () =>
203
                                        build_breadcrumb([
204
                                            breadcrumb_paths.eholdings_local,
205
                                            breadcrumbs.eholdings.local
206
                                                .packages,
207
                                        ]),
208
                                },
209
                            },
210
                            {
211
                                path: ":package_id",
212
                                component: EHoldingsLocalPackagesShow,
213
                                meta: {
214
                                    breadcrumb: () =>
215
                                        build_breadcrumb(
216
                                            [
217
                                                breadcrumb_paths.eholdings_local,
218
                                                breadcrumbs.eholdings.local
219
                                                    .packages,
220
                                            ],
221
                                            "Show package" // $t("Show package")
222
                                        ),
223
                                },
224
                            },
225
                            {
226
                                path: "add",
227
                                component: EHoldingsLocalPackagesFormAdd,
228
                                meta: {
229
                                    breadcrumb: () =>
230
                                        build_breadcrumb(
231
                                            [
232
                                                breadcrumb_paths.eholdings_local,
233
                                                breadcrumbs.eholdings.local
234
                                                    .packages,
235
                                            ],
236
                                            "Add package" // $t("Add package")
237
                                        ),
238
                                },
239
                            },
240
                            {
241
                                path: "edit/:package_id",
242
                                component: EHoldingsLocalPackagesFormAdd,
243
                                meta: {
244
                                    breadcrumb: () =>
245
                                        build_breadcrumb(
246
                                            [
247
                                                breadcrumb_paths.eholdings_local,
248
                                                breadcrumbs.eholdings.local
249
                                                    .packages,
250
                                            ],
251
                                            "Edit package" // $t("Edit package")
252
                                        ),
253
                                },
254
                            },
255
                        ],
256
                    },
58
                    },
257
                    {
59
                    {
258
                        path: "titles",
60
                        path: "add",
259
                        children: [
61
                        component: AgreementsFormAdd,
260
                            {
62
                        title: "Add agreement",
261
                                path: "",
262
                                component: EHoldingsLocalTitlesList,
263
                                meta: {
264
                                    breadcrumb: () =>
265
                                        build_breadcrumb([
266
                                            breadcrumb_paths.eholdings_local,
267
                                            breadcrumbs.eholdings.local.titles,
268
                                        ]),
269
                                },
270
                            },
271
                            {
272
                                path: ":title_id",
273
                                component: EHoldingsLocalTitlesShow,
274
                                meta: {
275
                                    breadcrumb: () =>
276
                                        build_breadcrumb(
277
                                            [
278
                                                breadcrumb_paths.eholdings_local,
279
                                                breadcrumbs.eholdings.local
280
                                                    .titles,
281
                                            ],
282
                                            "Show title" // $t("Show title")
283
                                        ),
284
                                },
285
                            },
286
                            {
287
                                path: "add",
288
                                component: EHoldingsLocalTitlesFormAdd,
289
                                meta: {
290
                                    breadcrumb: () =>
291
                                        build_breadcrumb(
292
                                            [
293
                                                breadcrumb_paths.eholdings_local,
294
                                                breadcrumbs.eholdings.local
295
                                                    .titles,
296
                                            ],
297
                                            "Add title" // $t("Add title")
298
                                        ),
299
                                },
300
                            },
301
                            {
302
                                path: "edit/:title_id",
303
                                component: EHoldingsLocalTitlesFormAdd,
304
                                meta: {
305
                                    breadcrumb: () =>
306
                                        build_breadcrumb(
307
                                            [
308
                                                breadcrumb_paths.eholdings_local,
309
                                                breadcrumbs.eholdings.local
310
                                                    .titles,
311
                                            ],
312
                                            "Edit title" // $t("Edit title")
313
                                        ),
314
                                },
315
                            },
316
                            {
317
                                path: "import",
318
                                component: EHoldingsLocalTitlesFormImport,
319
                                meta: {
320
                                    breadcrumb: () =>
321
                                        build_breadcrumb(
322
                                            [
323
                                                breadcrumb_paths.eholdings_local,
324
                                                breadcrumbs.eholdings.local
325
                                                    .titles,
326
                                            ],
327
                                            "Import from a list" // $t("Import from a list")
328
                                        ),
329
                                },
330
                            },
331
                        ],
332
                    },
63
                    },
333
                    {
64
                    {
334
                        path: "resources/:resource_id",
65
                        path: "edit/:agreement_id",
335
                        component: EHoldingsLocalResourcesShow,
66
                        component: AgreementsFormAdd,
336
                        meta: {
67
                        title: "Edit agreement",
337
                            breadcrumb: () =>
338
                                build_breadcrumb(
339
                                    [
340
                                        breadcrumb_paths.eholdings_local,
341
                                        breadcrumbs.eholdings.local.titles,
342
                                    ],
343
                                    "Resource" // $t("Resource")
344
                                ),
345
                        },
346
                    },
68
                    },
347
                ],
69
                ],
348
            },
70
            },
349
            {
71
            {
350
                path: "ebsco",
72
                path: "/cgi-bin/koha/erm/licenses",
73
                title: "Licenses",
74
                icon: "fa-gavel",
75
                is_end_node: true,
351
                children: [
76
                children: [
352
                    {
77
                    {
353
                        path: "",
78
                        path: "",
354
                        meta: {
79
                        component: LicensesList,
355
                            breadcrumb: () => breadcrumb_paths.eholdings_ebsco,
80
                    },
356
                        },
81
                    {
82
                        path: ":license_id",
83
                        component: LicensesShow,
84
                        title: "Show license",
85
                    },
86
                    {
87
                        path: "add",
88
                        component: LicensesFormAdd,
89
                        title: "Add license",
357
                    },
90
                    },
358
                    {
91
                    {
359
                        path: "packages",
92
                        path: "edit/:license_id",
93
                        component: LicensesFormAdd,
94
                        title: "Edit license",
95
                    },
96
                ],
97
            },
98
            {
99
                path: "/cgi-bin/koha/erm/eholdings",
100
                title: "eHoldings",
101
                icon: 'fa-crosshairs',
102
                disabled: true,
103
                children: [
104
                    {
105
                        path: "local",
106
                        title: "Local",
107
                        icon: "fa-map-marker",
108
                        disabled: true,
360
                        children: [
109
                        children: [
361
                            {
110
                            {
362
                                path: "",
111
                                path: "packages",
363
                                component: EHoldingsEBSCOPackagesList,
112
                                title: "Packages",
364
                                meta: {
113
                                icon: "fa-archive",
365
                                    breadcrumb: () =>
114
                                is_end_node: true,
366
                                        build_breadcrumb([
115
                                children: [
367
                                            breadcrumb_paths.eholdings_ebsco,
116
                                    {
368
                                            breadcrumbs.eholdings.ebsco
117
                                        path: "",
369
                                                .packages,
118
                                        component: EHoldingsLocalPackagesList,
370
                                        ]),
119
                                    },
371
                                },
120
                                    {
121
                                        path: ":package_id",
122
                                        component: EHoldingsLocalPackagesShow,
123
                                        title: "Show package",
124
                                    },
125
                                    {
126
                                        path: "add",
127
                                        component: EHoldingsLocalPackagesFormAdd,
128
                                        title: "Add package",
129
                                    },
130
                                    {
131
                                        path: "edit/:package_id",
132
                                        component: EHoldingsLocalPackagesFormAdd,
133
                                        title: "Edit package",
134
                                    },
135
                                ],
372
                            },
136
                            },
373
                            {
137
                            {
374
                                path: ":package_id",
138
                                path: "titles",
375
                                component: EHoldingsEBSCOPackagesShow,
139
                                title: "Titles",
376
                                meta: {
140
                                icon: "fa-sort-alpha-asc",
377
                                    breadcrumb: () =>
141
                                is_end_node: true,
378
                                        build_breadcrumb(
142
                                children: [
379
                                            [
143
                                    {
380
                                                breadcrumb_paths.eholdings_ebsco,
144
                                        path: "",
381
                                                breadcrumbs.eholdings.ebsco
145
                                        component: EHoldingsLocalTitlesList,
382
                                                    .packages,
146
                                    },
383
                                            ],
147
                                    {
384
                                            "Show package" // $t("Show package")
148
                                        path: ":title_id",
385
                                        ),
149
                                        component: EHoldingsLocalTitlesShow,
386
                                },
150
                                        title: "Show title",
151
                                    },
152
                                    {
153
                                        path: "add",
154
                                        component: EHoldingsLocalTitlesFormAdd,
155
                                        title: "Add title",
156
                                    },
157
                                    {
158
                                        path: "edit/:title_id",
159
                                        component: EHoldingsLocalTitlesFormAdd,
160
                                        title: "Edit title",
161
                                    },
162
                                    {
163
                                        path: "import",
164
                                        component: EHoldingsLocalTitlesFormImport,
165
                                        title: "Import from a list",
166
                                    },
167
                                    {
168
                                        path: "/cgi-bin/koha/erm/eholdings/local/resources/:resource_id",
169
                                        component: EHoldingsLocalResourcesShow,
170
                                        title: "Resource",
171
                                    },
172
                                ],
387
                            },
173
                            },
388
                        ],
174
                        ],
389
                    },
175
                    },
390
                    {
176
                    {
391
                        path: "titles",
177
                        path: "ebsco",
178
                        title: "EBSCO",
179
                        icon: 'fa-globe',
180
                        disabled: true,
392
                        children: [
181
                        children: [
393
                            {
182
                            {
394
                                path: "",
183
                                path: "packages",
395
                                component: EHoldingsEBSCOTitlesList,
184
                                title: "Packages",
396
                                meta: {
185
                                icon: "fa-archive",
397
                                    breadcrumb: () =>
186
                                is_end_node: true,
398
                                        build_breadcrumb([
187
                                children: [
399
                                            breadcrumb_paths.eholdings_ebsco,
188
                                    {
400
                                            breadcrumbs.eholdings.ebsco.titles,
189
                                        path: "",
401
                                        ]),
190
                                        component: EHoldingsEBSCOPackagesList,
402
                                },
191
                                    },
192
                                    {
193
                                        path: ":package_id",
194
                                        component: EHoldingsEBSCOPackagesShow,
195
                                        title: "Show package",
196
                                    },
197
                                ],
403
                            },
198
                            },
404
                            {
199
                            {
405
                                path: ":title_id",
200
                                path: "titles",
406
                                component: EHoldingsEBSCOTitlesShow,
201
                                title: "Titles",
407
                                meta: {
202
                                icon: "fa-sort-alpha-asc",
408
                                    breadcrumb: () =>
203
                                is_end_node: true,
409
                                        build_breadcrumb(
204
                                children: [
410
                                            [
205
                                    {
411
                                                breadcrumb_paths.eholdings_ebsco,
206
                                        path: "",
412
                                                breadcrumbs.eholdings.ebsco
207
                                        component: EHoldingsEBSCOTitlesList,
413
                                                    .titles,
208
                                    },
414
                                            ],
209
                                    {
415
                                            "Show title" // $t("Show title")
210
                                        path: ":title_id",
416
                                        ),
211
                                        component: EHoldingsEBSCOTitlesShow,
417
                                },
212
                                        title: "Show title",
213
                                    },
214
                                    {
215
                                        path: "/cgi-bin/koha/erm/eholdings/ebsco/resources/:resource_id",
216
                                        component: EHoldingsEBSCOResourcesShow,
217
                                        title: "Resource",
218
                                        is_navigation_item: false,
219
                                    },
220
                                ],
418
                            },
221
                            },
419
                        ],
222
                        ],
420
                    },
223
                    },
421
                    {
422
                        path: "resources/:resource_id",
423
                        component: EHoldingsEBSCOResourcesShow,
424
                        meta: {
425
                            breadcrumb: () =>
426
                                build_breadcrumb(
427
                                    [
428
                                        breadcrumb_paths.eholdings_ebsco,
429
                                        breadcrumbs.eholdings.ebsco.titles,
430
                                    ],
431
                                    "Resource" // $t("Resource")
432
                                ),
433
                        },
434
                    },
435
                ],
224
                ],
436
            },
225
            },
437
        ],
226
        ]
438
    },
439
    {
440
        path: "/cgi-bin/koha/erm/licenses",
441
        children: [
442
            {
443
                path: "",
444
                component: LicensesList,
445
                meta: {
446
                    breadcrumb: () => breadcrumb_paths.licenses,
447
                },
448
            },
449
            {
450
                path: ":license_id",
451
                component: LicensesShow,
452
                meta: {
453
                    breadcrumb: () =>
454
                        build_breadcrumb(
455
                            breadcrumb_paths.licenses,
456
                            "Show license" // $t("Show license")
457
                        ),
458
                },
459
            },
460
            {
461
                path: "add",
462
                component: LicensesFormAdd,
463
                meta: {
464
                    breadcrumb: () =>
465
                        build_breadcrumb(
466
                            breadcrumb_paths.licenses,
467
                            "Add license" // $t("Add license")
468
                        ),
469
                },
470
            },
471
            {
472
                path: "edit/:license_id",
473
                component: LicensesFormAdd,
474
                meta: {
475
                    breadcrumb: () =>
476
                        build_breadcrumb(
477
                            breadcrumb_paths.licenses,
478
                            "Edit license" // $t("Edit license")
479
                        ),
480
                },
481
            },
482
        ],
483
    },
227
    },
484
];
228
];
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/navigation.js (-1 / +106 lines)
Line 0 Link Here
0
- 
1
import { defineStore } from "pinia";
2
3
export const useNavigationStore = defineStore("navigation", {
4
  state: () => ({
5
    routeState: {
6
      alt: "Home",
7
      href: "/cgi-bin/koha/mainpage.pl",
8
      is_navigation_item: false,
9
      is_base: true,
10
      children: []
11
    },
12
    current: null,
13
  }),
14
  actions: {
15
    setRoutes(routesDef) {
16
      const _traverse_children = (parent) => {
17
        if(parent.children && parent.children.length) {
18
          parent.children.forEach(child => {
19
            child.parent = parent;
20
            if(child.path !== undefined) {
21
              if(!child.meta) child.meta = {};
22
              child.meta.self = child;
23
            }
24
            if(parent.children.length === 1 && parent.is_base) {
25
              child.is_base = child.is_base !== undefined ? child.is_base : true;
26
              child.is_navigation_item = child.is_navigation_item !== undefined ? child.is_navigation_item : false;
27
            } else if (parent.children.length > 1 || !parent.is_base) {
28
              child.is_base = child.is_base !== undefined ? child.is_base : false;
29
              child.is_navigation_item = child.is_navigation_item !== undefined ? child.is_navigation_item : true;
30
            }
31
            _traverse_children(child)
32
          })
33
        }
34
      }
35
      if(!Array.isArray(routesDef)) {
36
        routesDef = [routesDef]
37
      }
38
      this.routeState.children = routesDef
39
      _traverse_children(this.routeState)
40
      return this.navigationRoutes
41
    }
42
  },
43
  getters: {
44
    breadcrumbs() {
45
      const _traverse_parent = (child) => {
46
        let breadcrumbs = []
47
        let builtPath = child.path
48
        if(child.parent) {
49
          breadcrumbs = _traverse_parent(child.parent)
50
          if(builtPath !== undefined && !/^\//.test(builtPath)) {
51
            const {path:parentPath} = breadcrumbs[breadcrumbs.length - 1]
52
            if(parentPath !== undefined) {
53
              builtPath = `${parentPath}${/\/$/.test(parentPath)?'':'/'}${builtPath}`
54
            }
55
          }
56
        }
57
        if (child.is_base || (child.path && child.path !== '')) breadcrumbs.push({...child, icon: null, path: builtPath, children: null})
58
        return breadcrumbs
59
      }
60
      if(this.current)
61
        return _traverse_parent(this.current)
62
63
      const _get_base_elements = (parent) => {
64
        if(!parent.is_base) return []
65
        let next = {}
66
        if(parent.children && parent.children.length) {
67
            next = parent.children.find(child => child.is_default) || parent.children[0]
68
        }
69
        return [{...parent, children: null}, ..._get_base_elements(next)]
70
      }
71
72
      return _get_base_elements(this.routeState)
73
    },
74
    leftNavigation() {
75
      const _get_navigation_elements = (parent, builtPath = '') => {
76
        if (parent.is_base && (!parent.children || !parent.children.length)) return [];
77
        if (parent.is_base) return parent.children.filter(child => child.is_base || child.is_navigation_item).map(_get_navigation_elements).flat(Infinity)
78
        let items = []
79
        if(builtPath) builtPath = `${builtPath}${/\/$/.test(builtPath)?'':'/'}`
80
        if(parent.path !== undefined && /^\//.test(parent.path)) {
81
          builtPath = parent.path
82
        } else if (parent.path  !== undefined) {
83
          builtPath = `${builtPath}${parent.path}`
84
        } else {
85
          builtPath = ''
86
        }
87
        if (!parent.is_end_node && parent.children && parent.children.length) {
88
          items = parent.children
89
            .filter(child => child.is_navigation_item)
90
            .map(child => _get_navigation_elements(child, builtPath))
91
        }
92
        return {...parent, path: builtPath ? builtPath : parent.path, children: items}
93
      }
94
      const leftNav = _get_navigation_elements(this.routeState)
95
      return leftNav
96
    },
97
    navigationRoutes() {
98
      const _to_route = (parent) => {
99
        if(parent.path === undefined) return parent.children.map(child => _to_route(child)).flat(Infinity)
100
        return parent
101
      }
102
      let routes = _to_route(this.routeState)
103
      return Array.isArray(routes) ? routes : [routes]
104
    }
105
  }
106
})

Return to bug 33169