Implement new features for svg components + improve form properties (#25)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
- Make Dimension an actual svg line - Implement XPositionReference - Select the container above after delete - Remove DimensionLayer - Improve form properties Reviewed-on: https://git.siklos-chaneru.duckdns.org/Siklos/svg-layout-designer-react/pulls/25
This commit is contained in:
parent
d11dfec22b
commit
faa058e57d
11 changed files with 119 additions and 113 deletions
|
@ -55,7 +55,9 @@ export function DeleteContainer(
|
|||
throw new Error(`[DeleteContainer] Tried to delete a container that is not present in the main container: ${containerId}`);
|
||||
}
|
||||
|
||||
if (container === mainContainerClone) {
|
||||
if (container === mainContainerClone ||
|
||||
container.parent === undefined ||
|
||||
container.parent === null) {
|
||||
// TODO: Implement alert
|
||||
throw new Error('[DeleteContainer] Tried to delete the main container! Deleting the main container is not allowed!');
|
||||
}
|
||||
|
@ -64,18 +66,25 @@ export function DeleteContainer(
|
|||
throw new Error('[DeleteContainer] Container model was not found among children of the main container!');
|
||||
}
|
||||
|
||||
if (container.parent != null) {
|
||||
const index = container.parent.children.indexOf(container);
|
||||
if (index > -1) {
|
||||
container.parent.children.splice(index, 1);
|
||||
}
|
||||
const index = container.parent.children.indexOf(container);
|
||||
if (index > -1) {
|
||||
container.parent.children.splice(index, 1);
|
||||
} else {
|
||||
throw new Error('[DeleteContainer] Could not find container among parent\'s children');
|
||||
}
|
||||
|
||||
// Select the previous container
|
||||
// or select the one above
|
||||
const SelectedContainer = findContainerById(mainContainerClone, current.SelectedContainerId) ??
|
||||
container.parent.children.at(index - 1) ??
|
||||
container.parent;
|
||||
const SelectedContainerId = SelectedContainer.properties.id;
|
||||
|
||||
setHistory(history.concat([{
|
||||
LastAction: `Delete container ${containerId}`,
|
||||
MainContainer: mainContainerClone,
|
||||
SelectedContainer: null,
|
||||
SelectedContainerId: '',
|
||||
SelectedContainer,
|
||||
SelectedContainerId,
|
||||
TypeCounters: Object.assign({}, current.TypeCounters)
|
||||
}]));
|
||||
setHistoryCurrentStep(history.length);
|
||||
|
@ -182,6 +191,7 @@ export function AddContainer(
|
|||
width: properties?.Width,
|
||||
height: parentClone.properties.height,
|
||||
isRigidBody: false,
|
||||
XPositionReference: properties.XPositionReference,
|
||||
...properties.Style
|
||||
},
|
||||
[],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue