-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gsoc'24): Implemented LayoutElements Panel vue component (#317)
* feat(gsoc'24): Implemented LayoutElements Panel vue component * fixed syntax err * codeclimate issue fix * codeclimate issue * updated default import * updated naming for indexes * i18n and img not rendering fixed * Update LayoutElementsPanel.vue * layout image url corrected * updated * dropdown added for layoutmode
- Loading branch information
1 parent
129048f
commit 051c32a
Showing
8 changed files
with
144 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/components/Panels/LayoutElementsPanel/LayoutElementsPanel.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<template> | ||
<div class="noSelect defaultCursor layoutElementPanel draggable-panel draggable-panel-css" | ||
ref="layoutElementPanelRef"> | ||
<div class="panel-header"> | ||
{{ $t('simulator.layout.layout_elements') }} | ||
<span class="fas fa-minus-square minimize"></span> | ||
<span class="fas fa-external-link-square-alt maximize"></span> | ||
</div> | ||
<div class="panel-body"> | ||
<v-expansion-panels id="menu" class="accordion" variant="accordion"> | ||
<v-expansion-panel v-for="(group, groupIndex) in SimulatorState.subCircuitElementList" :key="groupIndex"> | ||
<v-expansion-panel-title> | ||
{{ group.type }}s | ||
</v-expansion-panel-title> | ||
<v-expansion-panel-text eager> | ||
<div class="panel customScroll"> | ||
<div v-for="(element, elementIndex) in group.elements" class="icon subcircuitModule" | ||
:key="`${groupIndex}-${elementIndex}`" :id="`${group.type}-${elementIndex}`" | ||
:data-element-id="elementIndex" :data-element-name="group.type" | ||
@mousedown="dragElement(group.type, element, elementIndex)"> | ||
<div class="icon-image"> | ||
<img :src="getImgUrl(group.type)" /> | ||
<p class="img__description"> | ||
{{ element.label !== '' ? element.label : $t('simulator.unlabeled') }} | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</v-expansion-panel-text> | ||
</v-expansion-panel> | ||
</v-expansion-panels> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { useState } from '#/store/SimulatorStore/state' | ||
import { simulationArea } from '#/simulator/src/simulationArea' | ||
import { useLayoutStore } from '#/store/layoutStore'; | ||
import { ref, onMounted } from 'vue'; | ||
const layoutStore = useLayoutStore() | ||
const layoutElementPanelRef = ref<HTMLElement | null>(null); | ||
onMounted(() => { | ||
layoutStore.layoutElementPanelRef = layoutElementPanelRef.value | ||
}) | ||
const SimulatorState = useState(); | ||
const dragElement = (groupType: string, element: any, index: number) => { | ||
element.subcircuitMetadata.showInSubcircuit = true | ||
element.newElement = true | ||
simulationArea.lastSelected = element | ||
// Remove the element from subCircuitElementList | ||
SimulatorState.subCircuitElementList.forEach((typeGroup) => { | ||
typeGroup.elements = typeGroup.elements.filter( | ||
(_, elementIndex) => { | ||
if(typeGroup.type === groupType && index === elementIndex) | ||
return false | ||
return true; | ||
} | ||
) | ||
}) | ||
// Remove the type group if its elements array is empty | ||
SimulatorState.subCircuitElementList = | ||
SimulatorState.subCircuitElementList.filter( | ||
(typeGroup) => typeGroup.elements.length > 0 | ||
) | ||
} | ||
function getImgUrl(elementName: string) { | ||
const elementImg = new URL( | ||
`../../../simulator/src/img/${elementName}.svg`, | ||
import.meta.url | ||
).href; | ||
return elementImg; | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.layoutElementPanel { | ||
width: 220px; | ||
font: inherit; | ||
display: none; | ||
top: 90px; | ||
left: 10px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters