Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions packages/plugins/src/wizards/connectedap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,36 @@ export function createTypeRestrictionCheckbox(
</mwc-formfield>`;
}

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`<wizard-textfield
required
label="${pType}"
pattern="${ifDefined(typePattern[pType])}"
?nullable=${typeNullable[pType]}
.maybeValue=${element.querySelector(`:scope > Address > P[type="${pType}"]`)
?.innerHTML ?? null}
.maybeValue=${currentValue}
maxLength="${ifDefined(typeMaxLength[pType])}"
.reservedValues=${reservedIPs}
></wizard-textfield>`;
}

Expand Down
Loading