From 7dcb28ae35c0ad055e01bca0fb51df865960c7ac Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Wed, 24 Apr 2024 15:38:22 -0300 Subject: [PATCH] defaults: Reuse default widget manager vars definition where possible --- src/assets/defaults.ts | 4 ++-- src/components/EditMenu.vue | 7 ++----- src/stores/widgetManager.ts | 13 ++----------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/assets/defaults.ts b/src/assets/defaults.ts index b1514f4db..8788fb1bd 100644 --- a/src/assets/defaults.ts +++ b/src/assets/defaults.ts @@ -1,7 +1,7 @@ import { type MiniWidgetProfile, MiniWidgetType } from '@/types/miniWidgets' import { type Profile, WidgetType } from '@/types/widgets' -const defaultWidgetManagerVars = { +export const defaultWidgetManagerVars = { timesMounted: 0, configMenuOpen: false, allowMoving: false, @@ -12,7 +12,7 @@ const defaultWidgetManagerVars = { highlighted: false, } -const defaultMiniWidgetManagerVars = { +export const defaultMiniWidgetManagerVars = { timesMounted: 0, configMenuOpen: false, highlighted: false, diff --git a/src/components/EditMenu.vue b/src/components/EditMenu.vue index baa9eb105..e29ca8bf2 100644 --- a/src/components/EditMenu.vue +++ b/src/components/EditMenu.vue @@ -281,6 +281,7 @@ import { computed, onMounted, ref, toRefs, watch } from 'vue' import { nextTick } from 'vue' import { type UseDraggableOptions, useDraggable, VueDraggable } from 'vue-draggable-plus' +import { defaultMiniWidgetManagerVars } from '@/assets/defaults' import { isHorizontalScroll } from '@/libs/utils' import { useWidgetManagerStore } from '@/stores/widgetManager' import { MiniWidgetType } from '@/types/miniWidgets' @@ -313,11 +314,7 @@ const availableMiniWidgetTypes = computed(() => name: widgetType, options: {}, hash: uuid(), - managerVars: { - timesMounted: 0, - configMenuOpen: false, - highlighted: false, - }, + managerVars: defaultMiniWidgetManagerVars, })) ) diff --git a/src/stores/widgetManager.ts b/src/stores/widgetManager.ts index 68f95506d..41b4d201e 100644 --- a/src/stores/widgetManager.ts +++ b/src/stores/widgetManager.ts @@ -7,7 +7,7 @@ import Swal from 'sweetalert2' import { v4 as uuid4 } from 'uuid' import { computed, onBeforeMount, onBeforeUnmount, ref, watch } from 'vue' -import { widgetProfiles } from '@/assets/defaults' +import { defaultWidgetManagerVars, widgetProfiles } from '@/assets/defaults' import { miniWidgetsProfile } from '@/assets/defaults' import { getKeyDataFromCockpitVehicleStorage, setKeyDataOnCockpitVehicleStorage } from '@/libs/blueos' import * as Words from '@/libs/funny-name/words' @@ -378,16 +378,7 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => { position: { x: 0.4, y: 0.32 }, size: { width: 0.2, height: 0.36 }, options: {}, - managerVars: { - timesMounted: 0, - configMenuOpen: false, - allowMoving: true, - lastNonMaximizedX: 0.4, - lastNonMaximizedY: 0.32, - lastNonMaximizedWidth: 0.2, - lastNonMaximizedHeight: 0.36, - highlighted: false, - }, + managerVars: { ...defaultWidgetManagerVars, ...{ allowMoving: true } }, }) }