removal method

EditResult removal(
  1. Set<String> ids
)

Whether ids and everything removed with them can be deleted. Locks are admission's to decide.

Implementation

EditResult removal(Set<String> ids) {
  if (ids.isEmpty) {
    return const EditResult.denied(
      code: DiagramDenialCode.invalidSelection,
      reason: 'No objects selected',
    );
  }
  for (final id in ids) {
    if (store.scene.elementById(id) == null) {
      return EditResult.denied(
        code: DiagramDenialCode.unavailableTarget,
        reason: 'Missing element $id',
      );
    }
  }
  for (final id in diagramRemovalClosure(store.state.document, ids)) {
    if (store.scene.elementById(id)
        case ResolvedFramedElement(:final behavior)
        when !behavior.deletable) {
      return EditResult.denied(
        code: DiagramDenialCode.unsupportedOperation,
        reason: 'Element $id is not deletable',
      );
    }
  }
  return const EditResult.allow();
}