From d9bb76e087f39cd5a84997d2f89f8cd83b620e75 Mon Sep 17 00:00:00 2001 From: Keanu D?lle Date: Tue, 8 Mar 2022 15:56:49 +0100 Subject: [PATCH] FIX: do not show all steps as active if min_billing_states returns 404 error --- resources/js/event_billing.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/resources/js/event_billing.js b/resources/js/event_billing.js index 6c6790c..da5cb9a 100644 --- a/resources/js/event_billing.js +++ b/resources/js/event_billing.js @@ -71,10 +71,12 @@ EventBilling = (function () { if (event.state >= 7) { $(".progress_personnel_billing").addClass("active"); - for (let state of billing_states) { - $(".progress_approve_" + state.entity_id).addClass("active"); - if (state.entity_id === event_min_billing_state) { - break; + if(event_min_billing_state) { + for (let state of billing_states) { + $(".progress_approve_" + state.entity_id).addClass("active"); + if (state.entity_id === event_min_billing_state) { + break; + } } } } @@ -94,7 +96,7 @@ EventBilling = (function () { } }; let load_min_billing_states_for_event = async function (event_id) { - const res = $.ajax({ + const res = await $.ajax({ url: '/api/events/' + event_id + '/billing_states/min', type: 'GET', contentType: 'application/json', @@ -103,7 +105,9 @@ EventBilling = (function () { alert("Es ist ein Fehler aufgetreten!"); } }); - if (is_ok(res)) { + if('error' in res){ + return null; + }else{ return res; } };