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,
|
due: item.paymentStatus === 1,
|
||||||
paid: item.paymentStatus === 2
|
paid: item.paymentStatus === 2
|
||||||
}"
|
}"
|
||||||
ng-click="ctrlClick($event, item)">
|
ng-click="handleItemInteraction($event, item)">
|
||||||
<i class="fa fa-grip-lines drag-handle"
|
<i class="fa fa-grip-lines drag-handle"
|
||||||
ng-show="cat.editing"
|
ng-show="cat.editing"
|
||||||
style="opacity: 0.5; padding-right: 6px; cursor: grab;"></i>
|
style="opacity: 0.5; padding-right: 6px; cursor: grab;"></i>
|
||||||
|
|||||||
@@ -90,24 +90,36 @@ app.controller('BudgetController', function ($scope, $http) {
|
|||||||
$scope.menuOpen = false;
|
$scope.menuOpen = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$scope.ctrlClick = function (event, item) {
|
let lastTapTime = 0;
|
||||||
if (!event.ctrlKey) return;
|
|
||||||
|
|
||||||
const current = typeof item.paymentStatus === 'number' && !isNaN(item.paymentStatus)
|
$scope.handleItemInteraction = function (event, item) {
|
||||||
? item.paymentStatus
|
const now = new Date().getTime();
|
||||||
: 0;
|
|
||||||
|
|
||||||
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", {
|
$http.put("/api/budget/updatePaymentStatus", {
|
||||||
itemId: item.id,
|
itemId: item.id,
|
||||||
status: item.paymentStatus
|
status: item.paymentStatus
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
$scope.showToast("Betalstatus uppdaterad");
|
$scope.showToast("Betalstatus uppdaterad");
|
||||||
}).catch(err => {
|
|
||||||
console.error("Fel vid uppdatering:", err);
|
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user