Skip to content

Commit

Permalink
fix z-order
Browse files Browse the repository at this point in the history
  • Loading branch information
mki-c2c committed Nov 15, 2024
1 parent eae429f commit 225c586
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/components/draw/draw-panel-features.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ function onToggleFeatureEdit(featureId: String, isEditing: boolean) {
// TODO: continue...
}
function sortFunction(elements: HTMLCollection) {
const featureIds = [...elements].map(val => val.id)
drawStore.reorderFeatures(featureIds)
}
onMounted(() => {
useSortable(<HTMLElement>document.querySelector('.sortable-features'))
useSortable(<HTMLElement>document.querySelector('.sortable-features'), {
onSort: sortFunction,
})
})
</script>

Expand All @@ -38,6 +45,7 @@ onMounted(() => {
<li
class="lux-drawing-item"
v-for="(feature, index) in features"
:id="`f-${getUid(feature)}`"
:key="index"
>
<FeatureItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class StorageFeaturesMapper {
if (!features) return ''
const featuresToEncode = features
.filter(feature => !feature.map_id)
.sort((a, b) => a.display_order - b.display_order)
.map(feature => {
const newFeature = new DrawnFeature(feature) //create new instance to avoid converting ol feature to polygon
// newFeature.set('name', newFeature.label) //is this still needed?
const newFeature = new DrawnFeature(feature) // create new instance to avoid converting ol feature to polygon
return convertCircleFeatureToPolygon(newFeature)
})
return featuresToEncode.length > 0
Expand Down
7 changes: 7 additions & 0 deletions src/stores/draw.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ export const useDrawStore = defineStore('draw', () => {
}
}

function reorderFeatures(featuresId: String[]) {
drawnFeatures.value = drawnFeatures.value.map(f =>
Object.assign(f, { display_order: featuresId.indexOf(`f-${getUid(f)}`) })
)
}

return {
activeFeatureId,
editingFeatureId,
Expand All @@ -90,6 +96,7 @@ export const useDrawStore = defineStore('draw', () => {
drawnFeatures,
featureEditionDocked,
removeFeature,
reorderFeatures,
toggleDrawActiveState,
setDrawActiveState,
setEditActiveState,
Expand Down

0 comments on commit 225c586

Please sign in to comment.