Skip to content

Commit

Permalink
Assign landmark IDs upon fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley committed Oct 25, 2023
1 parent 27b701f commit 7b2f8a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 3 additions & 8 deletions web/shapeworks/src/components/InfoTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
selectedDataObjects,
allDataObjectsInDataset,
currentLandmarkPlacement,
reassignLandmarkIDsByIndex,
reassignLandmarkNumSetValues,
} from '@/store';
import { computed, onMounted, ref, watch } from 'vue';
Expand Down Expand Up @@ -109,12 +110,6 @@ export default {
landmarkInfo.value = [...landmarkInfo.value]
}
function reassignIDsByIndex() {
landmarkInfo.value = landmarkInfo.value.map((info, index) => {
return Object.assign(info, {id: index})
})
}
function deleteLandmark(landmarkIndex, landmarkDomain) {
const indexForDomain = landmarkInfo.value.filter(
(i) => i.domain === landmarkDomain
Expand All @@ -132,7 +127,7 @@ export default {
([, locations]) => locations.length
)
)
reassignIDsByIndex()
reassignLandmarkIDsByIndex()
dialogs.value = []
expandedRows.value = []
changesMade.value = true
Expand Down Expand Up @@ -161,7 +156,7 @@ export default {
} else {
landmarkInfo.value = [landmark]
}
reassignIDsByIndex()
reassignLandmarkIDsByIndex()
expandedRows.value = [landmark]
selectedProject.value.landmarks = [
...selectedProject.value.landmarks,
Expand Down
7 changes: 7 additions & 0 deletions web/shapeworks/src/store/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@ export async function cacheAllComparisons(comparisons: CacheComparison[][]) {
}
}

export function reassignLandmarkIDsByIndex() {
landmarkInfo.value = landmarkInfo.value.map((info, index) => {
return Object.assign(info, {id: index})
})
}

export function reassignLandmarkNumSetValues() {
const setLandmarksPerDomain = {}
if (allSetLandmarks.value){
Expand Down Expand Up @@ -452,6 +458,7 @@ export async function getLandmarks() {
}
// reassign store var for listeners
allSetLandmarks.value = Object.assign({}, allSetLandmarks.value)
reassignLandmarkIDsByIndex();
reassignLandmarkNumSetValues();
}
}

0 comments on commit 7b2f8a5

Please sign in to comment.