Compare commits

...

1 Commits

Author SHA1 Message Date
Dogukan Karatas 685a137531 Merge pull request #204 from specklesystems/dogukan/cnx-2103-filtering-from-other-visuals-doesnt-work-when-conditional
Build and deploy Connector and Visual / build-connector (push) Has been cancelled
Build and deploy Connector and Visual / build-visual (push) Has been cancelled
Build and deploy Connector and Visual / deploy-installers (push) Has been cancelled
fix (visual): remove forcing conditional formatted objects always be visible
2025-09-17 20:30:53 +03:00
2 changed files with 38 additions and 5 deletions
+31 -4
View File
@@ -139,6 +139,23 @@ export const useVisualStore = defineStore('visualStore', () => {
}
}
const filterColorByIdsForSelection = (colorByIds: ColorBy[] | null | undefined, selectedIds: string[]): ColorBy[] => {
return colorByIds?.filter(colorGroup => {
const filteredObjectIds = colorGroup.objectIds.filter(objId =>
selectedIds.includes(objId)
)
if (filteredObjectIds.length > 0) {
return { ...colorGroup, objectIds: filteredObjectIds }
}
return false
}).map(colorGroup => ({
...colorGroup,
objectIds: colorGroup.objectIds.filter(objId =>
selectedIds.includes(objId)
)
})) || []
}
const clearLoadingProgress = () => {
loadingProgress.value = undefined
}
@@ -195,6 +212,10 @@ export const useVisualStore = defineStore('visualStore', () => {
if (dataInput.value.selectedIds.length > 0) {
isFilterActive.value = true
viewerEmit.value('filterSelection', dataInput.value.selectedIds, isGhostActive.value, isZoomOnFilterActive.value)
// When filtering, only apply colors to the selected/isolated objects
const filteredColorByIds = filterColorByIdsForSelection(dataInput.value.colorByIds, dataInput.value.selectedIds)
viewerEmit.value('colorObjectsByGroup', filteredColorByIds)
} else {
isFilterActive.value = false
latestColorBy.value = dataInput.value.colorByIds
@@ -205,8 +226,9 @@ export const useVisualStore = defineStore('visualStore', () => {
// No object IDs provided - show all objects without any filtering
viewerEmit.value('unIsolateObjects')
}
// When not filtering, apply all colors including conditional formatting
viewerEmit.value('colorObjectsByGroup', dataInput.value.colorByIds)
}
viewerEmit.value('colorObjectsByGroup', dataInput.value.colorByIds)
}
const writeObjectsToFile = (modelObjects: object[][]) => {
@@ -452,6 +474,7 @@ export const useVisualStore = defineStore('visualStore', () => {
// No object IDs provided - show all objects without any filtering
viewerEmit.value('unIsolateObjects')
}
// When resetting filters, apply all colors including conditional formatting
if (latestColorBy.value !== null) {
viewerEmit.value('colorObjectsByGroup', latestColorBy.value)
}
@@ -477,6 +500,10 @@ export const useVisualStore = defineStore('visualStore', () => {
if (dataInput.value.selectedIds.length > 0) {
isFilterActive.value = true
viewerEmit.value('filterSelection', dataInput.value.selectedIds, isGhostActive.value, isZoomOnFilterActive.value)
// When filtering, only apply colors to the selected/isolated objects
const filteredColorByIds = filterColorByIdsForSelection(dataInput.value.colorByIds, dataInput.value.selectedIds)
viewerEmit.value('colorObjectsByGroup', filteredColorByIds)
} else {
isFilterActive.value = false
latestColorBy.value = dataInput.value.colorByIds
@@ -487,10 +514,10 @@ export const useVisualStore = defineStore('visualStore', () => {
// No object IDs provided - show all objects without any filtering
viewerEmit.value('unIsolateObjects')
}
// Restore color grouping for all objects when not filtering
viewerEmit.value('colorObjectsByGroup', dataInput.value.colorByIds)
}
// Restore color grouping
viewerEmit.value('colorObjectsByGroup', dataInput.value.colorByIds)
}
// Trigger host data refresh to synchronize with Power BI
@@ -131,7 +131,8 @@ function processObjectNode(
console.log('⚠️ HAS objects', color)
if (color) {
res.color = color
res.shouldColor = true
// Don't override shouldColor for conditional formatting - keep the selection state
// res.shouldColor = true // REMOVED: This was overriding cross-filter selection state
}
}
return res
@@ -474,6 +475,7 @@ export async function processMatrixView(
localMatrixView.forEach((obj) => {
const processedObjectIdLevels = processObjectIdLevel(obj, host, matrixView)
// Apply conditional formatting color if present, regardless of selection state
if (processedObjectIdLevels.color) {
let group = colorByIds.find((g) => g.color === processedObjectIdLevels.color)
if (!group) {
@@ -483,7 +485,11 @@ export async function processMatrixView(
}
colorByIds.push(group)
}
// Always add to color group if color is specified (conditional formatting)
group.objectIds.push(processedObjectIdLevels.id)
} else if (processedObjectIdLevels.shouldColor) {
// Only use shouldColor flag when there's no conditional formatting
// This preserves the original cross-filter coloring behavior
}
objectIds.push(processedObjectIdLevels.id)