diff --git a/app/modules/sag/templates/detail.html b/app/modules/sag/templates/detail.html index 9246c37..0e7a77d 100644 --- a/app/modules/sag/templates/detail.html +++ b/app/modules/sag/templates/detail.html @@ -4190,7 +4190,21 @@ // Set default context for keyboard shortcuts (Option+Shift+T) if (window.setTagPickerContext) { - window.setTagPickerContext('case', {{ case.id }}, () => syncCaseTagsUi()); + window.setTagPickerContext('case', {{ case.id }}, (tag, addResult) => { + syncCaseTagsUi(); + + const actionType = addResult && addResult.action ? addResult.action.type : null; + const shouldOpenTemplateModal = actionType === 'open_task_template_modal' + || String((tag && tag.name) || '').toLowerCase() === 'opgave_template'; + + if (shouldOpenTemplateModal && typeof window.openTaskTemplateSelectorModal === 'function') { + window.openTaskTemplateSelectorModal({ + action: addResult ? addResult.action : null, + entity_type: 'case', + entity_id: caseId, + }); + } + }); } // Load Hardware & Locations @@ -5381,7 +5395,7 @@ return normalizeLegacyTags(legacyTags); }; - const response = await fetch(`/api/v1/tags/entity/case/${caseId}`); + const response = await fetch(`/api/v1/tags/entity/case/${caseId}`, { credentials: 'include' }); if (response.ok) { const genericTags = await response.json(); tags = Array.isArray(genericTags) ? genericTags : []; @@ -5434,7 +5448,7 @@ if (!suggestionsContainer) return; try { - const response = await fetch(`/api/v1/tags/entity/case/${caseId}/suggestions`); + const response = await fetch(`/api/v1/tags/entity/case/${caseId}/suggestions`, { credentials: 'include' }); if (!response.ok) throw new Error('Kunne ikke hente forslag'); const suggestions = await response.json(); @@ -5470,6 +5484,7 @@ const response = await fetch('/api/v1/tags/entity', { method: 'POST', headers: { 'Content-Type': 'application/json' }, + credentials: 'include', body: JSON.stringify({ entity_type: 'case', entity_id: caseId, tag_id: tagId }) }); @@ -5478,6 +5493,17 @@ throw new Error(error.detail || 'Kunne ikke tilfoeje tag'); } + const addResult = await response.json().catch(() => ({})); + if (addResult && addResult.action) { + window.dispatchEvent(new CustomEvent('hub:tag-action', { + detail: { + action: addResult.action, + entity_type: 'case', + entity_id: caseId, + } + })); + } + await syncCaseTagsUi(); if (typeof showNotification === 'function') { showNotification('Tag tilfoejet', 'success'); @@ -5520,6 +5546,8 @@ await loadCaseTagSuggestions(); } + window.syncCaseTagsUi = syncCaseTagsUi; + let todoUserId = null; function getTodoUserId() { @@ -6152,14 +6180,22 @@
TAGS
-
Indlaeser tags...
+ {% if tags and tags|length > 0 %} + {% for tag in tags %} + + {{ tag.tag_navn or tag.name or 'Tag' }} + + {% endfor %} + {% else %} +
Ingen tags paa sagen endnu
+ {% endif %}
Forslag (brand/type)
@@ -15509,6 +15545,127 @@ })(); + + + + + + + + + +