diff --git a/packages/plugins/src/wizards/connectedap.ts b/packages/plugins/src/wizards/connectedap.ts index 124e81ed92..1ed0494686 100644 --- a/packages/plugins/src/wizards/connectedap.ts +++ b/packages/plugins/src/wizards/connectedap.ts @@ -329,18 +329,36 @@ export function createTypeRestrictionCheckbox( `; } +function getIpsInSubnetwork(element: Element): string[] { + const subnetwork = element.parentElement; // SubNetwork is the parent of ConnectedAP + if (!subnetwork) return []; + + return Array.from(subnetwork.querySelectorAll(':scope > ConnectedAP > Address > P[type="IP"]')) + .map(p => p.textContent?.trim() ?? '') + .filter(ip => ip !== ''); +} + export function createPTextField( element: Element, pType: string ): TemplateResult { + const currentValue = + element.querySelector(`:scope > Address > P[type="${pType}"]`)?.textContent?.trim() ?? + null; + + let reservedIPs: string[] = []; + if (pType === 'IP') { + reservedIPs = getIpsInSubnetwork(element).filter(ip => ip !== currentValue); + } + return oscdHtml` Address > P[type="${pType}"]`) - ?.innerHTML ?? null} + .maybeValue=${currentValue} maxLength="${ifDefined(typeMaxLength[pType])}" + .reservedValues=${reservedIPs} >`; }