Merge pull request 'Fix generated FQDN not being submitted' (#249) from 241-fqdn-saving into main
Some checks failed
Tests / test (push) Waiting to run
Build and Deploy Staging / build (push) Has been cancelled
Build and Deploy Staging / deploy (push) Has been cancelled

Reviewed-on: #249
This commit is contained in:
Tobias Brunner 2025-10-24 13:55:12 +00:00
commit 3b97d4a1b6
2 changed files with 11 additions and 1 deletions

View file

@ -129,6 +129,8 @@ const updateRemoveButtonVisibility = (container) => {
}) })
} }
window.updateHiddenInput = updateHiddenInput
document.addEventListener('DOMContentLoaded', initDynamicArrayWidget) document.addEventListener('DOMContentLoaded', initDynamicArrayWidget)
document.addEventListener('htmx:afterSwap', initDynamicArrayWidget) document.addEventListener('htmx:afterSwap', initDynamicArrayWidget)
document.addEventListener('htmx:afterSettle', initDynamicArrayWidget) document.addEventListener('htmx:afterSettle', initDynamicArrayWidget)

View file

@ -1,6 +1,6 @@
const initializeFqdnGeneration = () => { const initializeFqdnGeneration = () => {
const nameField = document.querySelector('input[name="name"]'); const nameField = document.querySelector('input#id_name');
const fqdnField = document.querySelector('label[for="id_spec.parameters.service.fqdn"] + div input.array-item-input'); const fqdnField = document.querySelector('label[for="id_spec.parameters.service.fqdn"] + div input.array-item-input');
if (nameField && fqdnField) { if (nameField && fqdnField) {
@ -17,6 +17,10 @@ const initializeFqdnGeneration = () => {
newNameField.addEventListener('input', function() { newNameField.addEventListener('input', function() {
if (!newFqdnField.dataset.manuallyEdited) { if (!newFqdnField.dataset.manuallyEdited) {
newFqdnField.value = generateFqdn(this.value); newFqdnField.value = generateFqdn(this.value);
const container = newFqdnField.closest('.dynamic-array-widget');
if (container && window.updateHiddenInput) {
window.updateHiddenInput(container);
}
} }
}); });
@ -26,6 +30,10 @@ const initializeFqdnGeneration = () => {
if (newNameField.value && !newFqdnField.value) { if (newNameField.value && !newFqdnField.value) {
newFqdnField.value = generateFqdn(newNameField.value); newFqdnField.value = generateFqdn(newNameField.value);
const container = newFqdnField.closest('.dynamic-array-widget');
if (container && window.updateHiddenInput) {
window.updateHiddenInput(container);
}
} }
} }
} }