Make sure fqdn generation works with single values
All checks were successful
Tests / test (push) Successful in 27s
All checks were successful
Tests / test (push) Successful in 27s
This commit is contained in:
parent
4097261efe
commit
3f9fdd0e48
1 changed files with 26 additions and 8 deletions
|
|
@ -1,9 +1,21 @@
|
||||||
|
|
||||||
const initializeFqdnGeneration = (prefix) => {
|
const initializeFqdnGeneration = (prefix) => {
|
||||||
const nameField = document.querySelector(`input#id_${prefix}-name`);
|
const nameField = document.querySelector(`input#id_${prefix}-name`);
|
||||||
|
if (!nameField) return
|
||||||
|
|
||||||
|
// Try to find array input first (DynamicArrayWidget), then fallback to regular text input
|
||||||
const fqdnFieldContainer = document.getElementById(`${prefix}-spec.parameters.service.fqdn_container`)
|
const fqdnFieldContainer = document.getElementById(`${prefix}-spec.parameters.service.fqdn_container`)
|
||||||
if (!nameField || !fqdnFieldContainer) return
|
let fqdnField = null;
|
||||||
const fqdnField = fqdnFieldContainer.querySelector('input.array-item-input');
|
let isArrayField = true;
|
||||||
|
|
||||||
|
if (fqdnFieldContainer) {
|
||||||
|
let fqdnField = fqdnFieldContainer.querySelector('input.array-item-input');
|
||||||
|
} else {
|
||||||
|
fqdnField = document.getElementById(`id_${prefix}-spec.parameters.service.fqdn`);
|
||||||
|
isArrayField = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fqdnField) return
|
||||||
|
|
||||||
if (nameField && fqdnField) {
|
if (nameField && fqdnField) {
|
||||||
const generateFqdn = (instanceName) => {
|
const generateFqdn = (instanceName) => {
|
||||||
|
|
@ -14,11 +26,14 @@ const initializeFqdnGeneration = (prefix) => {
|
||||||
nameField.addEventListener('input', function() {
|
nameField.addEventListener('input', function() {
|
||||||
if (!fqdnField.dataset.manuallyEdited) {
|
if (!fqdnField.dataset.manuallyEdited) {
|
||||||
fqdnField.value = generateFqdn(this.value);
|
fqdnField.value = generateFqdn(this.value);
|
||||||
|
if (isArrayField) {
|
||||||
|
// Update hidden input for array fields
|
||||||
const container = fqdnField.closest('.dynamic-array-widget');
|
const container = fqdnField.closest('.dynamic-array-widget');
|
||||||
if (container && window.updateHiddenInput) {
|
if (container && window.updateHiddenInput) {
|
||||||
window.updateHiddenInput(container);
|
window.updateHiddenInput(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
fqdnField.addEventListener('input', function() {
|
fqdnField.addEventListener('input', function() {
|
||||||
|
|
@ -27,6 +42,8 @@ const initializeFqdnGeneration = (prefix) => {
|
||||||
|
|
||||||
if (nameField.value && !fqdnField.value) {
|
if (nameField.value && !fqdnField.value) {
|
||||||
fqdnField.value = generateFqdn(nameField.value);
|
fqdnField.value = generateFqdn(nameField.value);
|
||||||
|
if (isArrayField) {
|
||||||
|
// Update hidden input for array fields
|
||||||
const container = fqdnField.closest('.dynamic-array-widget');
|
const container = fqdnField.closest('.dynamic-array-widget');
|
||||||
if (container && window.updateHiddenInput) {
|
if (container && window.updateHiddenInput) {
|
||||||
window.updateHiddenInput(container);
|
window.updateHiddenInput(container);
|
||||||
|
|
@ -34,6 +51,7 @@ const initializeFqdnGeneration = (prefix) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {initializeFqdnGeneration("custom"), initializeFqdnGeneration("expert")});
|
document.addEventListener('DOMContentLoaded', () => {initializeFqdnGeneration("custom"), initializeFqdnGeneration("expert")});
|
||||||
document.body.addEventListener('htmx:afterSwap', function(event) {
|
document.body.addEventListener('htmx:afterSwap', function(event) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue