From 1e4c13915b88b99fe92e39ebdfe5490cc1b4a85c Mon Sep 17 00:00:00 2001 From: Alex Roehm Date: Tue, 13 Dec 2022 14:55:51 +0100 Subject: [PATCH] external menu feature (ccf) --- .kanbn/index.md | 3 +- .kanbn/tasks/analytics.md | 3 +- ...jecting-menu-for-integration-in-website.md | 9 + app.vue | 119 ++--- base/Menu.ts | 119 +++++ base/types/IMenuItemBase.ts | 6 + base/types/IMenuSection.ts | 7 +- base/types/IPageMenuItem.ts | 9 - components/EpisodesList.vue | 6 +- components/NavBar.vue | 410 ++++++++++++------ components/SubMenu.vue | 3 +- composables/settingsdata.ts | 6 +- composables/useAuth.ts | 4 +- nuxt.config.ts | 53 ++- package.json | 4 +- pages/admin/index.vue | 65 +++ pages/index.vue | 4 +- pages/podcasts.vue | 20 +- pages/serie/index.vue | 17 +- public/app.settings.json | 3 +- public/menu-ex.json | 73 ++++ public/menu.json | 277 ++++++++++++ server/api/menu.ts | 5 + server/menu.ts | 6 + tests/components/NavBar.test.ts | 9 +- 25 files changed, 955 insertions(+), 285 deletions(-) create mode 100644 .kanbn/tasks/injecting-menu-for-integration-in-website.md create mode 100644 base/Menu.ts create mode 100644 base/types/IMenuItemBase.ts delete mode 100644 base/types/IPageMenuItem.ts create mode 100644 pages/admin/index.vue create mode 100644 public/menu-ex.json create mode 100644 public/menu.json create mode 100644 server/api/menu.ts create mode 100644 server/menu.ts diff --git a/.kanbn/index.md b/.kanbn/index.md index 71a8b76..e090f1b 100644 --- a/.kanbn/index.md +++ b/.kanbn/index.md @@ -21,13 +21,14 @@ sprints: ## Todo -- [analytics](tasks/analytics.md) +- [injecting-menu-for-integration-in-website](tasks/injecting-menu-for-integration-in-website.md) ## In Progress ## Done - [login-passwort-change](tasks/login-passwort-change.md) +- [analytics](tasks/analytics.md) - [refresh-bug](tasks/refresh-bug.md) - [admin-als-super-admin-delete-podcast-und-import](tasks/admin-als-super-admin-delete-podcast-und-import.md) - [bibelstelle-video-editierbar](tasks/bibelstelle-video-editierbar.md) diff --git a/.kanbn/tasks/analytics.md b/.kanbn/tasks/analytics.md index 0eb5fd8..86cfcde 100644 --- a/.kanbn/tasks/analytics.md +++ b/.kanbn/tasks/analytics.md @@ -1,9 +1,10 @@ --- created: 2022-11-29T10:53:22.296Z -updated: 2022-12-03T20:26:57.445Z +updated: 2022-12-12T09:35:30.491Z assigned: "" progress: 0 tags: [] +completed: 2022-12-12T09:35:30.491Z --- # Analytics diff --git a/.kanbn/tasks/injecting-menu-for-integration-in-website.md b/.kanbn/tasks/injecting-menu-for-integration-in-website.md new file mode 100644 index 0000000..d1dbb39 --- /dev/null +++ b/.kanbn/tasks/injecting-menu-for-integration-in-website.md @@ -0,0 +1,9 @@ +--- +created: 2022-12-12T09:35:44.246Z +updated: 2022-12-12T09:36:14.510Z +assigned: "" +progress: 0 +tags: [] +--- + +# Injecting Menu for integration in website diff --git a/app.vue b/app.vue index 5641251..4e0c39f 100644 --- a/app.vue +++ b/app.vue @@ -1,113 +1,50 @@ diff --git a/base/Menu.ts b/base/Menu.ts new file mode 100644 index 0000000..5381a01 --- /dev/null +++ b/base/Menu.ts @@ -0,0 +1,119 @@ +import IMenuSection from '~~/base/types/IMenuSection'; + +export function initDefaultMenu(): Object { + var id = 0; + const menuResult = { + defaultBase: '/', + keys: [ + { + order: id++, + name: 'menu.admin', + description: 'menu.adminsub', + entries: [ + { + order: id++, + slug: 'admin/login', + name: 'menu.login', + onlyNotLoggedIn: '', + }, + { + order: id++, + slug: '#logout', + name: 'menu.logout', + onlyLoggedIn: '', + }, + { + order: id++, + slug: 'admin/setpassword', + name: 'menu.changepassword', + onlyLoggedIn: '', + }, + { + order: id++, + slug: 'admin/invitation', + name: 'menu.invitataion', + onlyAdmin: '', + }, + { + order: id++, + slug: 'admin/import', + name: 'menu.import', + onlyAdmin: '', + }, + ], + }, + { + order: id++, + name: 'menu.podcasts', + description: 'menu.podcastsub', + entries: [ + { + order: id++, + slug: 'podcasts', + name: 'menu.list', + }, + { + order: id++, + slug: 'recent', + name: 'menu.recent', + }, + { + order: id++, + slug: 'serie', + name: 'menu.series', + }, + { + order: id++, + slug: 'admin/new-podcast', + name: 'menu.new', + onlyLoggedIn: '', + }, + { + order: id++, + slug: 'admin/new-serie', + name: 'menu.newseries', + onlyLoggedIn: '', + }, + ], + }, + ] + } + return menuResult; +} + +export function getDefaultMenu( + menudata: Object, + username: string +): Object { + const loggin = username.length > 0; + const admin = username.startsWith('admin'); + const menuResult = { + defaultBase: menudata.defaultBase, + keys: menudata.keys.map((section) => { + return { + order: section.order, + name: section.name, + description: section.description, + entries: section.entries.filter( + (entry) => + (entry.hasOwnProperty('onlyLoggedIn') && loggin) || + (entry.hasOwnProperty('onlyNotLoggedIn') && !loggin) || + (entry.hasOwnProperty('onlyAdmin') && admin) || + !( + entry.hasOwnProperty('onlyLoggedIn') || + entry.hasOwnProperty('onlyNotLoggedIn') || + entry.hasOwnProperty('onlyAdmin') + ) + ), + } + }) + } + return menuResult; +} + +export async function getMenu( + url: string, +): Promise { + const menudata = await $fetch(url); + return menudata; +} diff --git a/base/types/IMenuItemBase.ts b/base/types/IMenuItemBase.ts new file mode 100644 index 0000000..8826b2c --- /dev/null +++ b/base/types/IMenuItemBase.ts @@ -0,0 +1,6 @@ +export default interface IMenuItemBase { + name: string; + order: number; + slug: string; + baseUrl?: string; +} \ No newline at end of file diff --git a/base/types/IMenuSection.ts b/base/types/IMenuSection.ts index 78c7dbf..6ec3105 100644 --- a/base/types/IMenuSection.ts +++ b/base/types/IMenuSection.ts @@ -1,8 +1,7 @@ -import IPageMenuItem from "./IPageMenuItem"; +import IMenuItemBase from "./IMenuItemBase"; -export default interface IMenuSection { - id: number; +export default interface IMenuSectionBase { description: string; name: string; - entries: Array; + entries: Array; } \ No newline at end of file diff --git a/base/types/IPageMenuItem.ts b/base/types/IPageMenuItem.ts deleted file mode 100644 index c1884cb..0000000 --- a/base/types/IPageMenuItem.ts +++ /dev/null @@ -1,9 +0,0 @@ -export default interface IPageMenuItem -{ - id: number; - name: string; - order?: number; - slug: string; - layout?: string; - locale?: string; -} \ No newline at end of file diff --git a/components/EpisodesList.vue b/components/EpisodesList.vue index f76a93a..232a6cd 100644 --- a/components/EpisodesList.vue +++ b/components/EpisodesList.vue @@ -20,7 +20,7 @@ v-for="(episode, index) in sortedFilteredList" :key="index" > - +
@@ -77,6 +77,7 @@ export default { name: 'EpisodesList', setup(props) { const dateformat = (input: Date): string => input.toLocaleDateString(); + const localePath = useLocalePath(); const search = ref("") const searchHiden = ref(true) const itemsperpage = ref(NUM_ITEMS_PER_PAGE) @@ -127,7 +128,8 @@ export default { search, itemsperpage, page, - max + max, + localePath }; }, }; diff --git a/components/NavBar.vue b/components/NavBar.vue index 56b4164..16e7873 100644 --- a/components/NavBar.vue +++ b/components/NavBar.vue @@ -1,50 +1,193 @@ \ No newline at end of file + return { + showMenu, + showDropdown, + menuSections, + locale, + locales, + setLocale, + localePath, + localeName, + toggle, + hide, + navelement, + baseUrl, + menuItemClicked, + localeChanged, + getExternalLink, + hasI18nKeysMenue, + homeLink + }; + }, +}); + diff --git a/components/SubMenu.vue b/components/SubMenu.vue index 71f824b..3d842fe 100644 --- a/components/SubMenu.vue +++ b/components/SubMenu.vue @@ -15,7 +15,7 @@
{{ $t(item.name) }}
- +