feat: add thematic code input to location form and add null checks for modal elements
This commit is contained in:
parent
1df0c1b8c1
commit
a364b6161d
2 changed files with 18 additions and 7 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -337,6 +337,7 @@
|
|||
<div class="modal-dialog modal-lg modal-dialog-scrollable">
|
||||
<form id="unifiedAddLocationForm" class="modal-content">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="thematic_code" id="unified-add-location-thematic-code">
|
||||
<input type="hidden" id="unified-add-location-type" name="location_type">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="unifiedAddLocationModalLabel">{% translate "Créer une localisation" %}</h5>
|
||||
|
|
|
|||
Loading…
Reference in a new issue