Merged PR 226: Implement associated container and default X, Y position for Symbol
Implement associated container and default X, Y position for Symbol Related work items: #7537, #7540
This commit is contained in:
parent
0a664752e9
commit
4ff2e0b7fb
9 changed files with 136 additions and 48 deletions
|
@ -12,7 +12,7 @@ import { ISymbolModel } from '../../../Interfaces/ISymbolModel';
|
|||
import { Orientation } from '../../../Enums/Orientation';
|
||||
import { GetDefaultContainerProps } from '../../../utils/default';
|
||||
import { FindContainerById } from '../../../utils/itertools';
|
||||
import { ApplyMargin, RestoreX, RestoreY, TransformX } from '../../../utils/svg';
|
||||
import { ApplyMargin, RestoreX, RestoreY } from '../../../utils/svg';
|
||||
import { ApplyBehaviors, ApplyBehaviorsOnSiblingsChildren } from '../Behaviors/Behaviors';
|
||||
import { GetCurrentHistory, UpdateCounters } from '../Editor';
|
||||
import { SortChildren } from './ContainerOperations';
|
||||
|
@ -59,7 +59,10 @@ export function AddContainers(
|
|||
configuration: IConfiguration,
|
||||
fullHistory: IHistoryState[],
|
||||
historyCurrentStep: number
|
||||
): IHistoryState[] {
|
||||
): {
|
||||
history: IHistoryState[]
|
||||
newContainers: IContainerModel[]
|
||||
} {
|
||||
const history = GetCurrentHistory(fullHistory, historyCurrentStep);
|
||||
const current = history[history.length - 1];
|
||||
|
||||
|
@ -77,18 +80,27 @@ export function AddContainers(
|
|||
// Deep clone the counters
|
||||
const newCounters = Object.assign({}, current.typeCounters);
|
||||
|
||||
// containerIds is used for logging purpose (see setHistory below)
|
||||
const containerIds: string[] = [];
|
||||
|
||||
// Iterate over the containers
|
||||
const newContainers: IContainerModel[] = [];
|
||||
availableContainers.forEach((availableContainer, typeIndex) => {
|
||||
// Get the preset properties from the API
|
||||
AddNewContainerToParent(availableContainer, configuration, containers, parentClone, index, typeIndex, newCounters, current.symbols, containerIds);
|
||||
const newContainer = AddNewContainerToParent(
|
||||
availableContainer,
|
||||
configuration,
|
||||
containers,
|
||||
parentClone,
|
||||
index,
|
||||
typeIndex,
|
||||
newCounters,
|
||||
current.symbols
|
||||
);
|
||||
newContainers.push(newContainer);
|
||||
});
|
||||
|
||||
// Update the state
|
||||
const containersIds = newContainers.map(container => container.properties.id);
|
||||
history.push({
|
||||
lastAction: `Add [${containerIds.join(', ')}] in ${parentClone.properties.id}`,
|
||||
lastAction: `Add [${containersIds.join(', ')}] in ${parentClone.properties.id}`,
|
||||
mainContainer: current.mainContainer,
|
||||
selectedContainerId: parentClone.properties.id,
|
||||
containers,
|
||||
|
@ -97,7 +109,10 @@ export function AddContainers(
|
|||
selectedSymbolId: current.selectedSymbolId
|
||||
});
|
||||
|
||||
return history;
|
||||
return {
|
||||
history,
|
||||
newContainers
|
||||
};
|
||||
}
|
||||
|
||||
function AddNewContainerToParent(
|
||||
|
@ -109,7 +124,6 @@ function AddNewContainerToParent(
|
|||
typeIndex: number,
|
||||
newCounters: Record<string, number>,
|
||||
symbols: Map<string, ISymbolModel>,
|
||||
containerIds: string[] = [],
|
||||
initChilds: boolean = true
|
||||
): ContainerModel {
|
||||
const type = availableContainer.Type;
|
||||
|
@ -207,9 +221,6 @@ function AddNewContainerToParent(
|
|||
}
|
||||
}
|
||||
|
||||
// Add to the list of container id for logging purpose
|
||||
containerIds.push(newContainer.properties.id);
|
||||
|
||||
return newContainer;
|
||||
}
|
||||
|
||||
|
@ -234,7 +245,7 @@ export function AddContainer(
|
|||
historyCurrentStep: number
|
||||
): IHistoryState[] {
|
||||
// just call AddContainers with an array on a single element
|
||||
return AddContainers(
|
||||
const { history } = AddContainers(
|
||||
index,
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
[{ Type: type }],
|
||||
|
@ -243,6 +254,7 @@ export function AddContainer(
|
|||
fullHistory,
|
||||
historyCurrentStep
|
||||
);
|
||||
return history;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -432,7 +444,6 @@ function AddContainerInLevel(
|
|||
0, 0,
|
||||
newCounters,
|
||||
symbols,
|
||||
undefined,
|
||||
false
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue