diff --git a/src/assets/defaults.ts b/src/assets/defaults.ts index 293d2b3a1..be27164fa 100644 --- a/src/assets/defaults.ts +++ b/src/assets/defaults.ts @@ -26,6 +26,7 @@ export const widgetProfiles: Profile[] = [ hash: 'eddd8e53-88c3-46a9-9e50-909227661f38', name: 'Video View', showBottomBarOnBoot: true, + visible: true, widgets: [ { hash: '80e785e1-31e2-4bfe-85d4-99fee6ca3f76', @@ -332,6 +333,7 @@ export const widgetProfiles: Profile[] = [ }, ], showBottomBarOnBoot: true, + visible: true, }, { hash: '795c3c97-c3f6-4a2d-b38f-d4ac8219bac0', @@ -512,6 +514,7 @@ export const widgetProfiles: Profile[] = [ }, ], showBottomBarOnBoot: true, + visible: true, }, ], }, @@ -523,6 +526,7 @@ export const widgetProfiles: Profile[] = [ hash: 'f8a76470-9122-44f7-97f7-4555a59ee9c4', name: 'Map view', showBottomBarOnBoot: true, + visible: true, widgets: [ { hash: '6439e791-3031-4928-aff2-8bd9af713798', diff --git a/src/components/EditMenu.vue b/src/components/EditMenu.vue index 84a92ffbf..47c4781e4 100644 --- a/src/components/EditMenu.vue +++ b/src/components/EditMenu.vue @@ -76,6 +76,11 @@ >

{{ view.name }}

+
@@ -347,6 +352,14 @@ const renameView = (view: View): void => { viewRenameDialogRevealed.value = true } +const toggleViewVisibility = (view: View): void => { + if (view.visible && view === store.currentView) { + Swal.fire({ text: 'You cannot hide the current view.', icon: 'error' }) + return + } + view.visible = !view.visible +} + const renameProfile = (profile: Profile): void => { profileBeingRenamed.value = profile newProfileName.value = profile.name diff --git a/src/components/mini-widgets/ViewSelector.vue b/src/components/mini-widgets/ViewSelector.vue index bdcf1f494..731cef3d8 100644 --- a/src/components/mini-widgets/ViewSelector.vue +++ b/src/components/mini-widgets/ViewSelector.vue @@ -3,7 +3,7 @@ diff --git a/src/stores/widgetManager.ts b/src/stores/widgetManager.ts index adca2a0df..f62d34a41 100644 --- a/src/stores/widgetManager.ts +++ b/src/stores/widgetManager.ts @@ -66,7 +66,7 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => { const viewsOnShowOrder = currentProfile.value.views.slice() viewsOnShowOrder.splice(currentViewIndex.value, 1) viewsOnShowOrder.push(currentProfile.value.views[currentViewIndex.value]) - return viewsOnShowOrder + return viewsOnShowOrder.filter((v) => v.visible) }) const miniWidgetContainersInCurrentView = computed(() => { @@ -203,6 +203,7 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => { { name: 'Bottom-right container', widgets: [] }, ], showBottomBarOnBoot: true, + visible: true, }) currentViewIndex.value = 0 } @@ -297,6 +298,10 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => { * @param { View } view - View */ const selectView = (view: View): void => { + if (!view.visible) { + Swal.fire({ icon: 'error', text: 'Cannot select a view that is not visible.', timer: 5000 }) + return + } const index = currentProfile.value.views.indexOf(view) currentViewIndex.value = index } @@ -308,6 +313,7 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => { widgets: view.widgets, miniWidgetContainers: view.miniWidgetContainers, showBottomBarOnBoot: view.showBottomBarOnBoot, + visible: view.visible, }) currentViewIndex.value = 0 } @@ -497,9 +503,8 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => { onBeforeMount(() => { savedProfiles.value.forEach((p) => p.views.forEach((v) => { - if (v.showBottomBarOnBoot === undefined) { - v.showBottomBarOnBoot = true - } + v.showBottomBarOnBoot = v.showBottomBarOnBoot ?? true + v.visible = v.visible ?? true }) ) }) diff --git a/src/types/widgets.ts b/src/types/widgets.ts index 6680da03c..3c43fff11 100644 --- a/src/types/widgets.ts +++ b/src/types/widgets.ts @@ -101,6 +101,10 @@ export type View = { * To show or not the bottom bar on boot. */ showBottomBarOnBoot: boolean + /** + * To show or not the view. + */ + visible: boolean } export type Profile = {