fix: open timer conversion from bottom bar tab

This commit is contained in:
Christian 2026-08-17 20:43:52 +02:00
parent 9ac5b91f6f
commit cabe0395ed
2 changed files with 33 additions and 4 deletions

View File

@ -1578,7 +1578,7 @@ if (bmcOriginalFetch) {
<script src="/static/js/telefoni.js?v=2.4"></script>
<script src="/static/js/sms.js?v=1.1"></script>
<script src="/static/js/bug-report.js?v=1.4"></script>
<script src="/static/js/bottom-bar.js?v=2.61"></script>
<script src="/static/js/bottom-bar.js?v=2.62"></script>
<script>
// Dark Mode Toggle Logic
window.BMC_CAN_CLICK_TO_CALL = true;

View File

@ -2053,20 +2053,49 @@
}
async function openTimeConversion(timeId) {
const timer = (switchCaseState.timers.stopped || []).concat(timerPanelState.rows || []).find(function (row) {
let timer = (switchCaseState.timers.stopped || []).concat(timerPanelState.rows || []).find(function (row) {
return Number((row && (row.time_entry_id || row.id)) || 0) === Number(timeId);
});
if (!timer) return;
if (!timer) {
try {
const timers = await fetchSwitchableTimers();
switchCaseState.timers = timers;
timer = (timers.stopped || []).find(function (row) {
return Number((row && (row.time_entry_id || row.id)) || 0) === Number(timeId);
});
} catch (_) {
// A useful error is shown below when the timer is still absent.
}
}
const modal = getSwitchCaseModal();
if (!modal) {
window.location.href = '/timetracking/registrations';
return;
}
modal.show();
if (!timer) {
switchCaseStatusMessage('<i class="bi bi-exclamation-triangle me-1 text-danger"></i>Timeren kunne ikke findes. Opdatér oversigten og prøv igen.');
return;
}
const panel = byId('bbConvertTimePanel');
const select = byId('bbConvertBillingMethod');
if (!panel || !select) return;
if (!panel || !select) {
switchCaseStatusMessage('<i class="bi bi-exclamation-triangle me-1 text-danger"></i>Konverteringsformularen kunne ikke åbnes.');
return;
}
panel.dataset.timeId = String(timeId);
byId('bbConvertTimeName').textContent = String((timer.sag_navn || timer.title) || ('Sag #' + (timer.sag_id || '')));
byId('bbConvertWorkType').value = timer.work_type || 'support';
byId('bbConvertMinutes').value = Number(timer.fakturerbar_tid_min != null ? timer.fakturerbar_tid_min : (timer.faktisk_tid_min || 0));
select.innerHTML = '<option>Henter muligheder...</option>';
panel.classList.remove('d-none');
switchCaseStatusMessage('<i class="bi bi-arrow-repeat me-1 text-primary"></i>Registrér den afsluttede timer som faktura, klippekort, abonnement eller intern tid.');
window.requestAnimationFrame(function () {
panel.scrollIntoView({ behavior: 'smooth', block: 'start' });
});
try {
const response = await fetch('/api/v1/timetracking/time/' + Number(timeId) + '/settlement-options', { credentials: 'include' });