diff --git a/loko/assets/static/assets/unified_index.js b/loko/assets/static/assets/unified_index.js index 1526274..325f89b 100644 --- a/loko/assets/static/assets/unified_index.js +++ b/loko/assets/static/assets/unified_index.js @@ -295,9 +295,11 @@ async function openUnifiedAssetModal(thematicCode) { if (!thematic) return; unifiedAddAssetThematic = thematic; - document.getElementById('unifiedAddAssetModalLabel').textContent = `${gettext('Créer un asset')} - ${thematic.name}`; + const modalLabel = document.getElementById('unifiedAddAssetModalLabel'); + if (modalLabel) modalLabel.textContent = `${gettext('Créer un asset')} - ${thematic.name}`; resetUnifiedAssetForm(); - document.getElementById('unified-add-asset-thematic-code').value = thematic.code; + const thematicInput = document.getElementById('unified-add-asset-thematic-code'); + if (thematicInput) thematicInput.value = thematic.code; await loadUnifiedAssetCategories(thematic.code); const codeGroup = document.getElementById('unifiedAddAssetCodeGroup'); @@ -314,7 +316,10 @@ async function openUnifiedAssetModal(thematicCode) { } } - bootstrap.Modal.getOrCreateInstance(document.getElementById('unifiedAddAssetModal')).show(); + const modalEl = document.getElementById('unifiedAddAssetModal'); + if (modalEl) { + bootstrap.Modal.getOrCreateInstance(modalEl).show(); + } } function initUnifiedLocationPickerMap() { @@ -468,14 +473,19 @@ async function openUnifiedLocationModal(thematicCode) { if (!thematic) return; unifiedAddLocationThematic = thematic; - document.getElementById('unifiedAddLocationModalLabel').textContent = `${gettext('Créer une localisation')} - ${thematic.name}`; - document.getElementById('unifiedAddLocationMeta').textContent = `${gettext('Type')}: ${thematic.location_label}`; + const modalLabel = document.getElementById('unifiedAddLocationModalLabel'); + if (modalLabel) modalLabel.textContent = `${gettext('Créer une localisation')} - ${thematic.name}`; + const modalMeta = document.getElementById('unifiedAddLocationMeta'); + if (modalMeta) modalMeta.textContent = `${gettext('Type')}: ${thematic.location_label}`; resetUnifiedLocationForm(); - document.getElementById('unified-add-location-thematic-code').value = thematic.code; - document.getElementById('unified-add-location-type').value = thematic.location_type; + const thematicCodeInput = document.getElementById('unified-add-location-thematic-code'); + if (thematicCodeInput) thematicCodeInput.value = thematic.code; + const locationTypeInput = document.getElementById('unified-add-location-type'); + if (locationTypeInput) locationTypeInput.value = thematic.location_type; await loadUnifiedLocationForm(thematic.code, thematic.location_type); const modalEl = document.getElementById('unifiedAddLocationModal'); + if (!modalEl) return; const onShown = () => { initUnifiedLocationPickerMap(); bootstrap.Modal.getOrCreateInstance(modalEl).handleUpdate(); diff --git a/loko/assets/templates/assets/unified_index.html b/loko/assets/templates/assets/unified_index.html index 1658649..0804a3b 100644 --- a/loko/assets/templates/assets/unified_index.html +++ b/loko/assets/templates/assets/unified_index.html @@ -337,6 +337,7 @@