Closed danyill closed 5 months ago
Currently, this does not remove empty SubNetwork elements if we are removing the last ConnectedAP.
I guess we could do something like the following but I worry about over-reach. And I guess we could make it an option. Perhaps we could just wait until it's a problem for someone :wink:
function removeWithIedName(ied: Element, iedName: string): Remove[] {
const selector = elementsToRemove
.map((iedNameElement) => `${iedNameElement}[iedName="${iedName}"]`)
.join(",");
return Array.from(ied.ownerDocument.querySelectorAll(selector))
.filter(isPublic)
.map((element) => {
if (
element.tagName === "ConnectedAP" &&
element.parentElement!.querySelectorAll("ConnectedAP").length === 1
) {
return { node: <Element>element.parentElement };
}
return { node: element };
});
}
I think an issue marking the fact that the removeIed
does not clean the DataTypeTemplates
section would also be nice. I don't think we should have that from the beginning, but a reminder is nice to have.
Thank you for this review, I have made some updates.
Closes #91
As always, I would be very grateful for a review.
I'm not removing supervisions using the inbuild unsubscribe functionality because it's implemented "the wrong way" (removal of LNs or DOIs when I want removal of the GoCBRef/SvCBRef > Val's text content). I hope that's acceptable for now.
While I could mostly reuse the test structure for the
updateIED
code (thank you!), I have redone the test files as I needed the subscriptions and supervisions to be more realistic.Once we have this right, I'd be keen for a new release as I have a menu plugin that I would like to provide in our distribution to allow IED removal.