fix: open timer conversion from bottom bar tab
This commit is contained in:
parent
9ac5b91f6f
commit
cabe0395ed
@ -1578,7 +1578,7 @@ if (bmcOriginalFetch) {
|
|||||||
<script src="/static/js/telefoni.js?v=2.4"></script>
|
<script src="/static/js/telefoni.js?v=2.4"></script>
|
||||||
<script src="/static/js/sms.js?v=1.1"></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/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>
|
<script>
|
||||||
// Dark Mode Toggle Logic
|
// Dark Mode Toggle Logic
|
||||||
window.BMC_CAN_CLICK_TO_CALL = true;
|
window.BMC_CAN_CLICK_TO_CALL = true;
|
||||||
|
|||||||
@ -2053,20 +2053,49 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function openTimeConversion(timeId) {
|
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);
|
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 panel = byId('bbConvertTimePanel');
|
||||||
const select = byId('bbConvertBillingMethod');
|
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);
|
panel.dataset.timeId = String(timeId);
|
||||||
byId('bbConvertTimeName').textContent = String((timer.sag_navn || timer.title) || ('Sag #' + (timer.sag_id || '')));
|
byId('bbConvertTimeName').textContent = String((timer.sag_navn || timer.title) || ('Sag #' + (timer.sag_id || '')));
|
||||||
byId('bbConvertWorkType').value = timer.work_type || 'support';
|
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));
|
byId('bbConvertMinutes').value = Number(timer.fakturerbar_tid_min != null ? timer.fakturerbar_tid_min : (timer.faktisk_tid_min || 0));
|
||||||
select.innerHTML = '<option>Henter muligheder...</option>';
|
select.innerHTML = '<option>Henter muligheder...</option>';
|
||||||
panel.classList.remove('d-none');
|
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 {
|
try {
|
||||||
const response = await fetch('/api/v1/timetracking/time/' + Number(timeId) + '/settlement-options', { credentials: 'include' });
|
const response = await fetch('/api/v1/timetracking/time/' + Number(timeId) + '/settlement-options', { credentials: 'include' });
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user