Skip to content

Commit

Permalink
Mini-widget-container: Remove VeryGenericIndicator variable from logg…
Browse files Browse the repository at this point in the history
…ing on drag-to-trash

Signed-off-by: Arturo Manzoli <[email protected]>
  • Loading branch information
ArturoManzoli committed Apr 25, 2024
1 parent b7d6135 commit 5f6d4b6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/components/MiniWidgetContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<div
v-for="miniWidget in container.widgets"
:key="miniWidget.hash"
:data-widget-hash="miniWidget.hash"
class="rounded-md"
:class="{ 'cursor-grab': allowEditing, 'bg-slate-400': miniWidget.managerVars.highlighted }"
@mouseover="miniWidget.managerVars.highlighted = allowEditing"
Expand Down Expand Up @@ -44,7 +45,7 @@
:animation="150"
group="generalGroup"
class="flex flex-wrap items-center justify-center w-full h-full gap-2"
@add="trashList = []"
@add="handleDeleteWidget"
>
<div v-for="miniWidget in trashList" :key="miniWidget.hash">
<div class="pointer-events-none select-none">
Expand All @@ -64,7 +65,8 @@ import { ref, toRefs } from 'vue'
import { computed } from 'vue'
import { VueDraggable } from 'vue-draggable-plus'
import type { MiniWidget, MiniWidgetContainer } from '@/types/miniWidgets'
import { CurrentlyLoggedVariables } from '@/libs/sensors-logging'
import type { DraggableEvent, MiniWidget, MiniWidgetContainer } from '@/types/miniWidgets'
import MiniWidgetInstantiator from './MiniWidgetInstantiator.vue'
Expand Down Expand Up @@ -115,4 +117,15 @@ const refreshWidgetsHashs = (): void => {
const showWidgetTrashArea = ref(false)
const trashList = ref<MiniWidget[]>([])
const handleDeleteWidget = (event: DraggableEvent): void => {
const widgetData = container.value.widgets.find((w) => w.hash === event.item.dataset.widgetHash)
// Remove VeryGenericIndicator from Logged variables list
if (widgetData?.component === 'VeryGenericIndicator') {
CurrentlyLoggedVariables.removeVariable(widgetData.options.displayName)
}
trashList.value = []
}
</script>
7 changes: 7 additions & 0 deletions src/types/miniWidgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,10 @@ export type MiniWidgetProfile = {
*/
name: string
}

export type DraggableEvent = {
/**
* The HTML item that is being dragged
*/
item: HTMLElement
}

0 comments on commit 5f6d4b6

Please sign in to comment.