Fix behaviors not apply on sibling when deleting a container + Fix container not able to move because sort is done after

This commit is contained in:
Eric NGUYEN 2022-09-21 16:46:42 +02:00
parent d875e33f93
commit 4bb92e219d
2 changed files with 41 additions and 5 deletions

View file

@ -84,3 +84,38 @@ export function ApplyBehaviorsOnSiblingsChildren(newContainer: IContainerModel,
}
});
}
/**
* Iterate over the siblings of newContainer and apply the behaviors
* @param newContainer
* @param symbols
* @returns
*/
export function ApplyBehaviorsOnSiblings(newContainer: IContainerModel, symbols: Map<string, ISymbolModel>): void {
if (newContainer.parent === null || newContainer.parent === undefined) {
return;
}
newContainer.parent.children
.forEach((container: IContainerModel) => {
ApplyBehaviors(container, symbols);
if (container.parent != null) {
const overlappingContainers = GetOverlappingContainers(container, container.parent.children);
if (overlappingContainers.length > 0) {
container.properties.warning = `There are overlapping containers: ${overlappingContainers.map(c => c.properties.id).join(' ')}`;
} else {
container.properties.warning = '';
}
}
if (container === newContainer) {
return;
}
for (const child of container.children) {
ApplyBehaviors(child, symbols);
}
});
}