Mobile fix for paymentstatus
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user