Skip to content

Commit

Permalink
Merge branch '14-issue' into 'main'
Browse files Browse the repository at this point in the history
Resolve "Broodkruimelpad toevoegen"

Closes #14

See merge request ictu/devops/algoritmeregister/algoritmeregister!14
  • Loading branch information
larsmustersICTU committed Dec 7, 2022
2 parents 6798409 + c3de426 commit 38cd83d
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 21 deletions.
7 changes: 7 additions & 0 deletions backend/app/routers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@ async def get_one(id: str, db: Session = Depends(get_db)):
.filter(models.algoritme.Algoritme.id == id)
.first()
)


@router.get("/algoritme-simple-list/")
async def get_simple_list(db: Session = Depends(get_db)):
return db.query(
models.algoritme.Algoritme.id, models.algoritme.Algoritme.name
).all()
2 changes: 1 addition & 1 deletion frontend/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { t } = useI18n()
</div>
<AppHeader />
<AppContentBar v-if="false" />
<AppBreadcrumb v-if="false" />
<AppBreadcrumb />

<div class="container columns columns--sidebar-left row">
<NuxtPage />
Expand Down
56 changes: 48 additions & 8 deletions frontend/components/views/AppBreadcrumb.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,58 @@
<template>
<div class="row row--page-opener">
<div class="row row--page-opener" v-if="breadcrumbs.length != 0">
<div class="container">
<div class="breadcrumb">
<p>U bent hier:</p>
<p>{{ t('you-are-here') }}:</p>
<ol>
<li>
<a href="#">Zoeken</a>
<li v-for="crumb in breadcrumbsWithLinks">
<a v-if="crumb.routeName != null" :href="`/${crumb.routeName}`">{{
crumb.label
}}</a>
<span v-if="crumb.routeName == null">{{ crumb.label }}</span>
</li>
<li>
<a href="#">Zoekresultaten</a>
</li>
<li>Regeling</li>
<li>{{ pathTail.label }}</li>
</ol>
</div>
</div>
</div>
</template>

<script setup lang="ts">
import { navigationItems } from '@/config/config'
import { useI18n } from 'vue-i18n'
import algoritmeService from '@/services/algoritme'
import { AlgNamesOnly } from '~~/types/algoritme'
const { t } = useI18n()
const currentRoute = useRoute()
const { data } = await algoritmeService.getNames()
let nameList = ref(data.value as AlgNamesOnly[])
const navigationItemsTranslated = computed(() =>
navigationItems.map((item) => {
return { label: t(item.label), routeName: item.routeName }
})
)
const navigationItemsWithoutLink = ['footer']
const breadcrumbs = computed(() => {
const path = currentRoute.path
const breadCrumbs = path != '/' ? path.split('/').slice(1) : []
return breadCrumbs.map((crumb) => {
return {
label:
// translate path parts with a name matching a navigation item
navigationItemsTranslated.value.find((item) => item.routeName == crumb)
?.label || // translate path parts with a name matching an algorithm id
nameList.value.find((alg: any) => alg.id == crumb)?.name ||
crumb,
routeName: navigationItemsWithoutLink.includes(crumb) ? null : crumb,
}
})
})
const breadcrumbsWithLinks = computed(() => breadcrumbs.value.slice(0, -1))
const pathTail = computed(() => breadcrumbs.value.slice(-1)[0])
</script>
6 changes: 1 addition & 5 deletions frontend/components/views/AppHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@

<script setup lang="ts">
import LanguagePicker from '@/components/LanguagePicker.vue'
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
Expand All @@ -75,7 +74,6 @@ const navigationItems = computed(() => [
routeName: 'algoritme',
},
])
const currentRoute = useRoute()
const menuExpanded = ref(false)
Expand All @@ -84,10 +82,8 @@ watch(currentRoute, () => (menuExpanded.value = false))
</script>

<style scoped lang="scss">
.active a {
background-color: $secondary;
color: $primary-darker !important;
}
</style>
</style>
37 changes: 36 additions & 1 deletion frontend/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,39 @@ const keys = {
status: 'status',
}

export { summaryTiles, keys }
const navigationItems = [
{
label: 'navigation.home',
routeName: 'index',
},
{
label: 'navigation.algorithmRegister',
routeName: 'algoritme',
},
{
label: 'navigation.footer',
routeName: 'footer',
},
{
label: 'navigation.over',
routeName: 'over',
},
{
label: 'navigation.contact',
routeName: 'contact',
},
{
label: 'navigation.vragen',
routeName: 'vragen',
},
{
label: 'navigation.privacyverklaring',
routeName: 'privacyverklaring',
},
{
label: 'navigation.toegankelijkheid',
routeName: 'toegankelijkheid',
},
]

export { summaryTiles, keys, navigationItems }
11 changes: 9 additions & 2 deletions frontend/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"english?": "true",
"explanation": "Explanation",
"you-are-here": "You are here",
"Ontbreekt": "Missing",
"locale-en": "English",
"locale-nl": "Dutch",
Expand Down Expand Up @@ -46,7 +47,13 @@
"hideFilters": "Hide filters",
"navigation": {
"home": "Home",
"algorithmRegister": "Algorithms"
"algorithmRegister": "Algorithms",
"footer": "Home",
"over": "About",
"contact": "Contact",
"vragen": "FAQ",
"privacyverklaring": "Privacy",
"toegankelijkheid": "Accessibility"
},
"pagination": {
"goTo": "Go to page {n}"
Expand Down Expand Up @@ -211,4 +218,4 @@
}
}
}
}
}
11 changes: 9 additions & 2 deletions frontend/locales/nl.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"english?": "false",
"explanation": "Uitleg",
"you-are-here": "U bent hier",
"Ontbreekt": "Ontbreekt",
"locale-en": "Engels",
"locale-nl": "Nederlands",
Expand Down Expand Up @@ -46,7 +47,13 @@
"hideFilters": "Verberg filters",
"navigation": {
"home": "Home",
"algorithmRegister": "Algoritmes"
"algorithmRegister": "Algoritmes",
"footer": "Home",
"over": "Over",
"contact": "Contact",
"vragen": "Vaak gestelde vragen",
"privacyverklaring": "Privacyverklaring",
"toegankelijkheid": "Toegankelijkheid"
},
"pagination": {
"goTo": "Ga naar pagina {n}"
Expand Down Expand Up @@ -211,4 +218,4 @@
}
}
}
}
}
9 changes: 7 additions & 2 deletions frontend/services/algoritme.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// import { apiFetch } from '@/utils/fetchApi'
import type { Algoritme } from '@/types/algoritme'
import type { Algoritme, AlgNamesOnly } from '@/types/algoritme'

const getAll = () =>
useFetch<Algoritme[]>('/algoritme/', {
Expand All @@ -11,4 +11,9 @@ const getOne = (id: string) =>
baseURL: useRuntimeConfig().public.apiBaseUrl,
})

export default { getAll, getOne }
const getNames = () =>
useFetch<AlgNamesOnly[]>('/algoritme-simple-list/', {
baseURL: useRuntimeConfig().public.apiBaseUrl,
})

export default { getAll, getOne, getNames }
5 changes: 5 additions & 0 deletions frontend/types/algoritme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ export type AlgoritmeFilter = {
attribute: string
value: string
}

export interface AlgNamesOnly {
id: string
name: string
}

0 comments on commit 38cd83d

Please sign in to comment.