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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Breadcrumbs.vue (-4 / +10 lines)
Lines 8-14 Link Here
8
                ></NavigationItem>
8
                ></NavigationItem>
9
                <NavigationItem
9
                <NavigationItem
10
                    v-else
10
                    v-else
11
                    :item="{ ...item, path: undefined, href: undefined }"
11
                    :item="{
12
                        ...item,
13
                        disabled: true,
14
                        path: undefined,
15
                        href: undefined,
16
                    }"
12
                ></NavigationItem>
17
                ></NavigationItem>
13
            </template>
18
            </template>
14
        </ol>
19
        </ol>
Lines 35-43 export default { Link Here
35
</script>
40
</script>
36
41
37
<style>
42
<style>
38
#breadcrumbs ol li a.disabled {
43
#breadcrumbs .disabled {
39
    color: #666;
44
    padding: 0.6em 0.3em;
45
    text-decoration: none;
46
    color: #000;
40
    pointer-events: none;
47
    pointer-events: none;
41
    font-weight: 700;
42
}
48
}
43
</style>
49
</style>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/NavigationItem.vue (-1 / +1 lines)
Lines 21-27 Link Here
21
                </template>
21
                </template>
22
                <span v-if="item.title">{{ $__(item.title) }}</span>
22
                <span v-if="item.title">{{ $__(item.title) }}</span>
23
            </a>
23
            </a>
24
            <span v-else>
24
            <span v-else :class="{ disabled: item.disabled }">
25
                <template v-if="item.icon">
25
                <template v-if="item.icon">
26
                    <i :class="`fa ${item.icon}`"></i>&nbsp;
26
                    <i :class="`fa ${item.icon}`"></i>&nbsp;
27
                </template>
27
                </template>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/i18n/index.js (+9 lines)
Line 0 Link Here
1
export const $__ = (key) => {
2
    return window["__"](key);
3
};
4
5
export default {
6
    install: (app, options) => {
7
        app.config.globalProperties.$__ = $__
8
    },
9
};
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts (-8 / +1 lines)
Lines 23-39 import { useMainStore } from "../stores/main"; Link Here
23
import { useVendorStore } from "../stores/vendors";
23
import { useVendorStore } from "../stores/vendors";
24
import { useAVStore } from "../stores/authorised-values";
24
import { useAVStore } from "../stores/authorised-values";
25
import { useNavigationStore } from "../stores/navigation";
25
import { useNavigationStore } from "../stores/navigation";
26
import i18n from "../i18n";
26
27
27
const pinia = createPinia();
28
const pinia = createPinia();
28
29
29
const i18n = {
30
    install: (app, options) => {
31
        app.config.globalProperties.$__ = (key) => {
32
            return window["__"](key);
33
        };
34
    },
35
};
36
37
const mainStore = useMainStore(pinia);
30
const mainStore = useMainStore(pinia);
38
const AVStore = useAVStore(pinia);
31
const AVStore = useAVStore(pinia);
39
const navigationStore = useNavigationStore(pinia);
32
const navigationStore = useNavigationStore(pinia);
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/erm.js (-52 / +55 lines)
Lines 1-3 Link Here
1
import { markRaw } from "vue";
2
1
import Home from "../components/ERM/Home.vue";
3
import Home from "../components/ERM/Home.vue";
2
import AgreementsList from "../components/ERM/AgreementsList.vue";
4
import AgreementsList from "../components/ERM/AgreementsList.vue";
3
import AgreementsShow from "../components/ERM/AgreementsShow.vue";
5
import AgreementsShow from "../components/ERM/AgreementsShow.vue";
Lines 19-24 import LicensesList from "../components/ERM/LicensesList.vue"; Link Here
19
import LicensesShow from "../components/ERM/LicensesShow.vue";
21
import LicensesShow from "../components/ERM/LicensesShow.vue";
20
import LicensesFormAdd from "../components/ERM/LicensesFormAdd.vue";
22
import LicensesFormAdd from "../components/ERM/LicensesFormAdd.vue";
21
23
24
import { $__ } from "../i18n";
25
22
export const routes = [
26
export const routes = [
23
    {
27
    {
24
        path: "/cgi-bin/koha/admin/background_jobs/:id",
28
        path: "/cgi-bin/koha/admin/background_jobs/:id",
Lines 31-173 export const routes = [ Link Here
31
    },
35
    },
32
    {
36
    {
33
        path: "/cgi-bin/koha/erm/erm.pl",
37
        path: "/cgi-bin/koha/erm/erm.pl",
34
        component: {template: '<router-view />'},
35
        is_default: true,
38
        is_default: true,
36
        is_base: true,
39
        is_base: true,
37
        title: 'E-resource management',
40
        title: $__('E-resource management'),
38
        children: [
41
        children: [
39
            {
42
            {
40
                path: "",
43
                path: "",
41
                component: Home,
44
                component: markRaw(Home),
42
                is_navigation_item: false,
45
                is_navigation_item: false,
43
            },
46
            },
44
            {
47
            {
45
                path: "/cgi-bin/koha/erm/agreements",
48
                path: "/cgi-bin/koha/erm/agreements",
46
                title: 'Agreements',
49
                title: $__('Agreements'),
47
                icon: 'fa-check-circle-o',
50
                icon: 'fa-check-circle-o',
48
                is_end_node: true,
51
                is_end_node: true,
49
                children: [
52
                children: [
50
                    {
53
                    {
51
                        path: "",
54
                        path: "",
52
                        component: AgreementsList,
55
                        component: markRaw(AgreementsList),
53
                    },
56
                    },
54
                    {
57
                    {
55
                        path: ":agreement_id",
58
                        path: ":agreement_id",
56
                        component: AgreementsShow,
59
                        component: markRaw(AgreementsShow),
57
                        title: "Show agreement",
60
                        title: $__('Show agreement'),
58
                    },
61
                    },
59
                    {
62
                    {
60
                        path: "add",
63
                        path: "add",
61
                        component: AgreementsFormAdd,
64
                        component: markRaw(AgreementsFormAdd),
62
                        title: "Add agreement",
65
                        title: $__('Add agreement'),
63
                    },
66
                    },
64
                    {
67
                    {
65
                        path: "edit/:agreement_id",
68
                        path: "edit/:agreement_id",
66
                        component: AgreementsFormAdd,
69
                        component: markRaw(AgreementsFormAdd),
67
                        title: "Edit agreement",
70
                        title: $__('Edit agreement'),
68
                    },
71
                    },
69
                ],
72
                ],
70
            },
73
            },
71
            {
74
            {
72
                path: "/cgi-bin/koha/erm/licenses",
75
                path: "/cgi-bin/koha/erm/licenses",
73
                title: "Licenses",
76
                title: $__('Licenses'),
74
                icon: "fa-gavel",
77
                icon: "fa-gavel",
75
                is_end_node: true,
78
                is_end_node: true,
76
                children: [
79
                children: [
77
                    {
80
                    {
78
                        path: "",
81
                        path: "",
79
                        component: LicensesList,
82
                        component: markRaw(LicensesList),
80
                    },
83
                    },
81
                    {
84
                    {
82
                        path: ":license_id",
85
                        path: ":license_id",
83
                        component: LicensesShow,
86
                        component: markRaw(LicensesShow),
84
                        title: "Show license",
87
                        title: $__('Show license'),
85
                    },
88
                    },
86
                    {
89
                    {
87
                        path: "add",
90
                        path: "add",
88
                        component: LicensesFormAdd,
91
                        component: markRaw(LicensesFormAdd),
89
                        title: "Add license",
92
                        title: $__('Add license'),
90
                    },
93
                    },
91
                    {
94
                    {
92
                        path: "edit/:license_id",
95
                        path: "edit/:license_id",
93
                        component: LicensesFormAdd,
96
                        component: markRaw(LicensesFormAdd),
94
                        title: "Edit license",
97
                        title: $__('Edit license'),
95
                    },
98
                    },
96
                ],
99
                ],
97
            },
100
            },
98
            {
101
            {
99
                path: "/cgi-bin/koha/erm/eholdings",
102
                path: "/cgi-bin/koha/erm/eholdings",
100
                title: "eHoldings",
103
                title: $__('eHoldings'),
101
                icon: 'fa-crosshairs',
104
                icon: 'fa-crosshairs',
102
                disabled: true,
105
                disabled: true,
103
                children: [
106
                children: [
104
                    {
107
                    {
105
                        path: "local",
108
                        path: "local",
106
                        title: "Local",
109
                        title: $__('Local'),
107
                        icon: "fa-map-marker",
110
                        icon: "fa-map-marker",
108
                        disabled: true,
111
                        disabled: true,
109
                        children: [
112
                        children: [
110
                            {
113
                            {
111
                                path: "packages",
114
                                path: "packages",
112
                                title: "Packages",
115
                                title: $__('Packages'),
113
                                icon: "fa-archive",
116
                                icon: "fa-archive",
114
                                is_end_node: true,
117
                                is_end_node: true,
115
                                children: [
118
                                children: [
116
                                    {
119
                                    {
117
                                        path: "",
120
                                        path: "",
118
                                        component: EHoldingsLocalPackagesList,
121
                                        component: markRaw(EHoldingsLocalPackagesList),
119
                                    },
122
                                    },
120
                                    {
123
                                    {
121
                                        path: ":package_id",
124
                                        path: ":package_id",
122
                                        component: EHoldingsLocalPackagesShow,
125
                                        component: markRaw(EHoldingsLocalPackagesShow),
123
                                        title: "Show package",
126
                                        title: $__('Show package'),
124
                                    },
127
                                    },
125
                                    {
128
                                    {
126
                                        path: "add",
129
                                        path: "add",
127
                                        component: EHoldingsLocalPackagesFormAdd,
130
                                        component: markRaw(EHoldingsLocalPackagesFormAdd),
128
                                        title: "Add package",
131
                                        title: $__('Add package'),
129
                                    },
132
                                    },
130
                                    {
133
                                    {
131
                                        path: "edit/:package_id",
134
                                        path: "edit/:package_id",
132
                                        component: EHoldingsLocalPackagesFormAdd,
135
                                        component: markRaw(EHoldingsLocalPackagesFormAdd),
133
                                        title: "Edit package",
136
                                        title: $__('Edit package'),
134
                                    },
137
                                    },
135
                                ],
138
                                ],
136
                            },
139
                            },
137
                            {
140
                            {
138
                                path: "titles",
141
                                path: "titles",
139
                                title: "Titles",
142
                                title: $__('Titles'),
140
                                icon: "fa-sort-alpha-asc",
143
                                icon: "fa-sort-alpha-asc",
141
                                is_end_node: true,
144
                                is_end_node: true,
142
                                children: [
145
                                children: [
143
                                    {
146
                                    {
144
                                        path: "",
147
                                        path: "",
145
                                        component: EHoldingsLocalTitlesList,
148
                                        component: markRaw(EHoldingsLocalTitlesList),
146
                                    },
149
                                    },
147
                                    {
150
                                    {
148
                                        path: ":title_id",
151
                                        path: ":title_id",
149
                                        component: EHoldingsLocalTitlesShow,
152
                                        component: markRaw(EHoldingsLocalTitlesShow),
150
                                        title: "Show title",
153
                                        title: $__('Show title'),
151
                                    },
154
                                    },
152
                                    {
155
                                    {
153
                                        path: "add",
156
                                        path: "add",
154
                                        component: EHoldingsLocalTitlesFormAdd,
157
                                        component: markRaw(EHoldingsLocalTitlesFormAdd),
155
                                        title: "Add title",
158
                                        title: $__('Add title'),
156
                                    },
159
                                    },
157
                                    {
160
                                    {
158
                                        path: "edit/:title_id",
161
                                        path: "edit/:title_id",
159
                                        component: EHoldingsLocalTitlesFormAdd,
162
                                        component: markRaw(EHoldingsLocalTitlesFormAdd),
160
                                        title: "Edit title",
163
                                        title: $__('Edit title'),
161
                                    },
164
                                    },
162
                                    {
165
                                    {
163
                                        path: "import",
166
                                        path: "import",
164
                                        component: EHoldingsLocalTitlesFormImport,
167
                                        component: markRaw(EHoldingsLocalTitlesFormImport),
165
                                        title: "Import from a list",
168
                                        title: $__('Import from a list'),
166
                                    },
169
                                    },
167
                                    {
170
                                    {
168
                                        path: "/cgi-bin/koha/erm/eholdings/local/resources/:resource_id",
171
                                        path: "/cgi-bin/koha/erm/eholdings/local/resources/:resource_id",
169
                                        component: EHoldingsLocalResourcesShow,
172
                                        component: markRaw(EHoldingsLocalResourcesShow),
170
                                        title: "Resource",
173
                                        title: $__('Resource'),
171
                                    },
174
                                    },
172
                                ],
175
                                ],
173
                            },
176
                            },
Lines 175-220 export const routes = [ Link Here
175
                    },
178
                    },
176
                    {
179
                    {
177
                        path: "ebsco",
180
                        path: "ebsco",
178
                        title: "EBSCO",
181
                        title: $__('EBSCO'),
179
                        icon: 'fa-globe',
182
                        icon: 'fa-globe',
180
                        disabled: true,
183
                        disabled: true,
181
                        children: [
184
                        children: [
182
                            {
185
                            {
183
                                path: "packages",
186
                                path: "packages",
184
                                title: "Packages",
187
                                title: $__('Packages'),
185
                                icon: "fa-archive",
188
                                icon: "fa-archive",
186
                                is_end_node: true,
189
                                is_end_node: true,
187
                                children: [
190
                                children: [
188
                                    {
191
                                    {
189
                                        path: "",
192
                                        path: "",
190
                                        component: EHoldingsEBSCOPackagesList,
193
                                        component: markRaw(EHoldingsEBSCOPackagesList),
191
                                    },
194
                                    },
192
                                    {
195
                                    {
193
                                        path: ":package_id",
196
                                        path: ":package_id",
194
                                        component: EHoldingsEBSCOPackagesShow,
197
                                        component: markRaw(EHoldingsEBSCOPackagesShow),
195
                                        title: "Show package",
198
                                        title: $__('Show package'),
196
                                    },
199
                                    },
197
                                ],
200
                                ],
198
                            },
201
                            },
199
                            {
202
                            {
200
                                path: "titles",
203
                                path: "titles",
201
                                title: "Titles",
204
                                title: $__('Titles'),
202
                                icon: "fa-sort-alpha-asc",
205
                                icon: "fa-sort-alpha-asc",
203
                                is_end_node: true,
206
                                is_end_node: true,
204
                                children: [
207
                                children: [
205
                                    {
208
                                    {
206
                                        path: "",
209
                                        path: "",
207
                                        component: EHoldingsEBSCOTitlesList,
210
                                        component: markRaw(EHoldingsEBSCOTitlesList),
208
                                    },
211
                                    },
209
                                    {
212
                                    {
210
                                        path: ":title_id",
213
                                        path: ":title_id",
211
                                        component: EHoldingsEBSCOTitlesShow,
214
                                        component: markRaw(EHoldingsEBSCOTitlesShow),
212
                                        title: "Show title",
215
                                        title: $__('Show title'),
213
                                    },
216
                                    },
214
                                    {
217
                                    {
215
                                        path: "/cgi-bin/koha/erm/eholdings/ebsco/resources/:resource_id",
218
                                        path: "/cgi-bin/koha/erm/eholdings/ebsco/resources/:resource_id",
216
                                        component: EHoldingsEBSCOResourcesShow,
219
                                        component: markRaw(EHoldingsEBSCOResourcesShow),
217
                                        title: "Resource",
220
                                        title: $__('Resource'),
218
                                        is_navigation_item: false,
221
                                        is_navigation_item: false,
219
                                    },
222
                                    },
220
                                ],
223
                                ],
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/navigation.js (-100 / +204 lines)
Lines 1-106 Link Here
1
import { defineStore } from "pinia";
1
import {
2
    defineStore
3
} from "pinia";
2
4
3
export const useNavigationStore = defineStore("navigation", {
5
export const useNavigationStore = defineStore("navigation", {
4
  state: () => ({
6
    state: () => ({
5
    routeState: {
7
        routeState: {
6
      alt: "Home",
8
            alt: "Home",
7
      href: "/cgi-bin/koha/mainpage.pl",
9
            href: "/cgi-bin/koha/mainpage.pl",
8
      is_navigation_item: false,
10
            is_navigation_item: false,
9
      is_base: true,
11
            is_base: true,
10
      children: []
12
            children: []
11
    },
13
        },
12
    current: null,
14
        current: null,
13
  }),
15
    }),
14
  actions: {
16
    actions: {
15
    setRoutes(routesDef) {
17
        setRoutes(routesDef) {
16
      const _traverse_children = (parent) => {
18
            if (!Array.isArray(routesDef)) {
17
        if(parent.children && parent.children.length) {
19
                routesDef = [routesDef]
18
          parent.children.forEach(child => {
20
            }
19
            child.parent = parent;
21
            this.routeState.children = routesDef
20
            if(child.path !== undefined) {
22
            _traverseChildren(this.routeState)
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
23
72
      return _get_base_elements(this.routeState)
24
            return this.navigationRoutes
73
    },
25
74
    leftNavigation() {
26
            // Function declarations
75
      const _get_navigation_elements = (parent, builtPath = '') => {
27
76
        if (parent.is_base && (!parent.children || !parent.children.length)) return [];
28
            function _traverseChildren(parent) {
77
        if (parent.is_base) return parent.children.filter(child => child.is_base || child.is_navigation_item).map(_get_navigation_elements).flat(Infinity)
29
                if (isParent(parent)) {
78
        let items = []
30
                    parent.children.forEach(child => {
79
        if(builtPath) builtPath = `${builtPath}${/\/$/.test(builtPath)?'':'/'}`
31
                        _setChildDefaults(parent, child);
80
        if(parent.path !== undefined && /^\//.test(parent.path)) {
32
                        _traverseChildren(child)
81
          builtPath = parent.path
33
                    })
82
        } else if (parent.path  !== undefined) {
34
                }
83
          builtPath = `${builtPath}${parent.path}`
35
            }
84
        } else {
36
85
          builtPath = ''
37
            function _setChildDefaults(parent, child) {
86
        }
38
                child.parent = parent;
87
        if (!parent.is_end_node && parent.children && parent.children.length) {
39
                if (isRoutable(child)) {
88
          items = parent.children
40
                    _setMetadata(child);
89
            .filter(child => child.is_navigation_item)
41
                }
90
            .map(child => _get_navigation_elements(child, builtPath))
42
                if (parent.children.length === 1 && parent.is_base) {
43
                    _setBaseAndNavigationDefaults(child, {
44
                        is_base: true,
45
                        is_navigation_item: false
46
                    });
47
                } else {
48
                    _setBaseAndNavigationDefaults(child, {
49
                        is_base: false,
50
                        is_navigation_item: true
51
                    });
52
                }
53
            }
54
55
            function _setBaseAndNavigationDefaults(child, {
56
                is_base,
57
                is_navigation_item
58
            }) {
59
                child.is_base = child.is_base !== undefined ? child.is_base : is_base;
60
                child.is_navigation_item = child.is_navigation_item !== undefined ? child.is_navigation_item : is_navigation_item;
61
            }
62
63
            function _setMetadata(child) {
64
                if (!child.meta)
65
                    child.meta = {};
66
                child.meta.self = child;
67
            }
91
        }
68
        }
92
        return {...parent, path: builtPath ? builtPath : parent.path, children: items}
93
      }
94
      const leftNav = _get_navigation_elements(this.routeState)
95
      return leftNav
96
    },
69
    },
97
    navigationRoutes() {
70
    getters: {
98
      const _to_route = (parent) => {
71
        breadcrumbs() {
99
        if(parent.path === undefined) return parent.children.map(child => _to_route(child)).flat(Infinity)
72
            if (this.current)
100
        return parent
73
                return _traverseParent(this.current)
101
      }
74
102
      let routes = _to_route(this.routeState)
75
            return _getBaseElements(this.routeState)
103
      return Array.isArray(routes) ? routes : [routes]
76
77
            // Function declarations
78
79
            function _getBaseElements(parent) {
80
                if (!parent.is_base) return []
81
                let next = {}
82
                if (isParent(parent)) {
83
                    next = _defineNextElement(parent)
84
                }
85
                return [{
86
                    ...parent,
87
                    children: null
88
                }, ..._getBaseElements(next)]
89
            }
90
91
            function _defineNextElement(parent) {
92
                return parent.children.find(child => child.is_default) || parent.children[0];
93
            }
94
95
            function _traverseParent(child) {
96
                let breadcrumbs = []
97
                let builtPath = child.path
98
                if (child.parent) {
99
                    breadcrumbs = _traverseParent(child.parent)
100
                    builtPath = _buildPath(builtPath, breadcrumbs);
101
                }
102
                if (_isBaseOrNotStub(child)) breadcrumbs.push({
103
                    ...child,
104
                    icon: null,
105
                    path: builtPath,
106
                    children: null
107
                })
108
                return breadcrumbs
109
            }
110
111
            function _isBaseOrNotStub(child) {
112
                return child.is_base || (child.path && child.path !== '');
113
            }
114
115
            function _buildPath(builtPath, breadcrumbs) {
116
                if (!isAbsolutePath(builtPath)) {
117
                    const {
118
                        path: parentPath
119
                    } = breadcrumbs[breadcrumbs.length - 1];
120
                    if (parentPath !== undefined) {
121
                        builtPath = `${parentPath}${addSlashIfNotPresent(parentPath)}${builtPath}`;
122
                    }
123
                }
124
                return builtPath;
125
            }
126
        },
127
        leftNavigation() {
128
            return _getNavigationElements(this.routeState)
129
130
            // Function declarations
131
132
            function _getNavigationElements(parent, prevPath = '') {
133
                if (_isBaseAndNoChildren(parent)) return [];
134
                if (parent.is_base)
135
                    return _buildChildNavigationElements(parent).flat(Infinity)
136
137
                const builtPath = _buildPath(prevPath, parent);
138
139
                let children = []
140
                if (!parent.is_end_node && isParent(parent)) {
141
                    children = _buildChildNavigationElements(parent, builtPath)
142
                }
143
144
                return {
145
                    ...parent,
146
                    path: builtPath ? builtPath : parent.path,
147
                    children
148
                }
149
            }
150
151
            function _buildPath(prevPath, element) {
152
                let builtPath;
153
154
                if (isRoutable(element) && isAbsolutePath(element.path)) {
155
                    builtPath = element.path;
156
                } else {
157
                    if (prevPath)
158
                        builtPath = `${prevPath}${addSlashIfNotPresent(prevPath)}`;
159
                    if (isRoutable(element))
160
                        builtPath = `${builtPath}${element.path}`;
161
                }
162
163
                return builtPath;
164
            }
165
166
            function _buildChildNavigationElements(parent, builtPath) {
167
                return parent.children
168
                    .filter(child => child.is_base || child.is_navigation_item)
169
                    .map(child => _getNavigationElements(child, builtPath));
170
            }
171
172
            function _isBaseAndNoChildren(parent) {
173
                return parent.is_base && (!parent.children || !parent.children.length);
174
            }
175
        },
176
        navigationRoutes() {
177
            let routes = _toRoute(this.routeState)
178
            return Array.isArray(routes) ? routes : [routes]
179
180
            // Function declarations
181
182
            function _toRoute(parent) {
183
                if (!isRoutable(parent))
184
                    return _getRoutableChildren(parent)
185
                return parent
186
            }
187
188
            function _getRoutableChildren(parent) {
189
                return parent.children
190
                    .map(child => _toRoute(child))
191
                    .flat(Infinity);
192
            }
193
        }
104
    }
194
    }
105
  }
106
})
195
})
107
- 
196
197
function addSlashIfNotPresent(path) {
198
    return /\/$/.test(path) ? '' : '/';
199
}
200
201
function isRoutable(element) {
202
    return element.path !== undefined;
203
}
204
205
function isParent(parent) {
206
    return parent.children && parent.children.length;
207
}
208
209
function isAbsolutePath(path) {
210
    return /^\//.test(path);
211
}

Return to bug 33169