Mobile fix for paymentstatus
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Elias Jansson
2025-06-18 23:35:22 +02:00
parent 871fe3a070
commit 6cb2ebf3c8
2 changed files with 22 additions and 10 deletions

View File

@@ -130,7 +130,7 @@
due: item.paymentStatus === 1,
paid: item.paymentStatus === 2
}"
ng-click="ctrlClick($event, item)">
ng-click="handleItemInteraction($event, item)">
<i class="fa fa-grip-lines drag-handle"
ng-show="cat.editing"
style="opacity: 0.5; padding-right: 6px; cursor: grab;"></i>

View File

@@ -90,24 +90,36 @@ app.controller('BudgetController', function ($scope, $http) {
$scope.menuOpen = false;
});
});
$scope.ctrlClick = function (event, item) {
if (!event.ctrlKey) return;
let lastTapTime = 0;
const current = typeof item.paymentStatus === 'number' && !isNaN(item.paymentStatus)
? item.paymentStatus
: 0;
$scope.handleItemInteraction = function (event, item) {
const now = new Date().getTime();
item.paymentStatus = (current + 1) % 3;
// Ctrl-klick på desktop
if (event.ctrlKey) {
togglePaymentStatus(item);
return;
}
// Dubbeltap på mobil (inom 400ms)
if (now - lastTapTime < 400) {
togglePaymentStatus(item);
event.preventDefault();
}
lastTapTime = now;
};
function togglePaymentStatus(item) {
item.paymentStatus = (item.paymentStatus + 1) % 3;
$http.put("/api/budget/updatePaymentStatus", {
itemId: item.id,
status: item.paymentStatus
}).then(() => {
$scope.showToast("Betalstatus uppdaterad");
}).catch(err => {
console.error("Fel vid uppdatering:", err);
});
};
}