Budget fixes! (pre new budget)
All checks were successful
continuous-integration/drone/push Build is passing
@@ -125,28 +125,52 @@ body {
|
||||
|
||||
.budget-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 24px;
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
gap:10px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
|
||||
.budget-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: 350px;
|
||||
position: relative;
|
||||
overflow-x: hidden;
|
||||
overflow-y: visible;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 12px;
|
||||
background-color: var(--bg-card);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.item-list {
|
||||
flex: 1 1 auto;
|
||||
flex-grow: 1;
|
||||
overflow-y: auto;
|
||||
padding: 8px 12px;
|
||||
background: rgba(255, 0, 0, 0.05); /* tillfällig bakgrund för felsökning */
|
||||
padding: 2px 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
|
||||
.item-row:last-child {
|
||||
margin-bottom: 5px;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
.card-header {
|
||||
border-radius: 12px 12px 0 0;
|
||||
}
|
||||
.total-row {
|
||||
padding: 2px 8px;
|
||||
font-weight: bold;
|
||||
font-size: 13px;
|
||||
background: #f1f5f9;
|
||||
border-top: 1px solid var(--border-color);
|
||||
border-radius: 0 0 12px 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
position: sticky;
|
||||
@@ -188,22 +212,51 @@ body {
|
||||
flex-wrap: nowrap;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 0px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.item-list::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.item-row input[type="text"],
|
||||
.item-row input[type="number"] {
|
||||
flex: 1;
|
||||
padding: 5px 6px;
|
||||
font-size: 13px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
background-color: #ffffff;
|
||||
color: var(--text-main);
|
||||
font-weight: 500;
|
||||
min-width: 120px;
|
||||
}
|
||||
.item-list::-webkit-scrollbar-thumb {
|
||||
background-color: rgba(100, 116, 139, 0.2);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.item-list::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* === För Firefox === */
|
||||
.item-list {
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: rgba(100, 116, 139, 0.2) transparent;
|
||||
}
|
||||
|
||||
|
||||
.item-row input[type="text"] {
|
||||
flex: 1;
|
||||
padding: 5px 6px;
|
||||
font-size: 13px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
background-color: #ffffff;
|
||||
color: var(--text-main);
|
||||
font-weight: 500;
|
||||
min-width: 70px;
|
||||
}
|
||||
.item-row input[type="number"] {
|
||||
flex: 1;
|
||||
padding: 5px 6px;
|
||||
font-size: 13px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
background-color: #ffffff;
|
||||
color: var(--text-main);
|
||||
font-weight: 500;
|
||||
max-width: 60px;
|
||||
}
|
||||
|
||||
.amount {
|
||||
min-width: 70px;
|
||||
@@ -211,17 +264,6 @@ body {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.total-row {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
padding: 8px 12px;
|
||||
font-weight: bold;
|
||||
font-size: 13px;
|
||||
background: var(--bg-card);
|
||||
border-top: 1px solid var(--border-color);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.icon-button {
|
||||
@@ -232,26 +274,21 @@ body {
|
||||
padding: 4px;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.icon-button:hover {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.icon-button.danger {
|
||||
.icon-button:hover {
|
||||
color: #000000;
|
||||
}
|
||||
.icon-button.danger {
|
||||
color: var(--btn-delete);
|
||||
}
|
||||
|
||||
.icon-button.danger:hover {
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
.icon-button.edit {
|
||||
color: var(--btn-edit);
|
||||
}
|
||||
|
||||
.icon-button.confirm {
|
||||
color: var(--btn-check);
|
||||
}
|
||||
.icon-button.danger:hover {
|
||||
color: #b91c1c;
|
||||
}
|
||||
.icon-button.edit {
|
||||
color: var(--btn-edit);
|
||||
}
|
||||
.icon-button.confirm {
|
||||
color: var(--btn-check);
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
position: absolute;
|
||||
@@ -284,7 +321,7 @@ body {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.dropdown-menu button:hover {
|
||||
.dropdown-menu button:hover {
|
||||
background-color: #e5e7eb;
|
||||
}
|
||||
|
||||
@@ -315,38 +352,75 @@ body {
|
||||
z-index: 9999;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.toast.show {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.toast.error {
|
||||
background: #ef4444;
|
||||
}
|
||||
.toast.show {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
.toast.error {
|
||||
background: #ef4444;
|
||||
}
|
||||
|
||||
|
||||
/* === Dropzones === */
|
||||
|
||||
.drop-placeholder {
|
||||
height: 12px;
|
||||
transition: background-color 0.2s ease;
|
||||
background-color: transparent;
|
||||
height: 0px;
|
||||
transition: all 0.2s ease;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.drop-placeholder.drag-over {
|
||||
border-top: 3px solid #3B82F6; /* blå rand */
|
||||
background-color: rgba(59, 130, 246, 0.15); /* ljusblå fyllning */
|
||||
height: 12px;
|
||||
border-top: 3px solid #3B82F6;
|
||||
height: 40px; /* gör det mer tydligt när man drar */
|
||||
transition: height 0.2s ease;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Gör att man ser var man kan släppa */
|
||||
.drop-zone.active-drop-target {
|
||||
background-color: rgba(34, 197, 94, 0.15); /* svagt grön basfärg */
|
||||
height: 12px;
|
||||
background-color: rgba(22, 163, 74, 0.1); /* svagt grön basfärg */
|
||||
}
|
||||
|
||||
.drop-zone.drag-over {
|
||||
border: 2px dashed #16a34a; /* grön */
|
||||
background-color: rgba(22, 163, 74, 0.1);
|
||||
}
|
||||
|
||||
|
||||
.item-floating-menu {
|
||||
position: fixed !important; /* viktig för att den inte ska följa DOM-flödet */
|
||||
z-index: 9999 !important; /* se till att inget annat ligger över */
|
||||
background: #1F2C3C;
|
||||
color: #fff;
|
||||
border: 1px solid #444;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
||||
padding: 4px 0px 4px 0;
|
||||
min-width: 20px;
|
||||
max-width: 130px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
.item-floating-menu button {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #fff;
|
||||
text-align: left;
|
||||
padding: 8px 16px;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.item-floating-menu button:hover {
|
||||
background: #333;
|
||||
}
|
||||
|
||||
.item-floating-menu button.disabled {
|
||||
color: #aaa;
|
||||
pointer-events: none;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
181
Aberwyn/wwwroot/css/pizza-admin.css
Normal file
@@ -0,0 +1,181 @@
|
||||
.admin-grid {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
align-items: flex-start;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.main-orders {
|
||||
flex: 3;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.available-pizzas {
|
||||
flex: 1;
|
||||
background-color: #f1f5f9;
|
||||
padding: 16px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 1px 4px rgba(0,0,0,0.1);
|
||||
min-width: 280px;
|
||||
}
|
||||
|
||||
.card {
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
|
||||
background: #f9fafb; /* Ljus bakgrund generellt */
|
||||
overflow: hidden;
|
||||
min-width: 220px;
|
||||
max-width: 260px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: 1px solid #dee2e6;
|
||||
transition: box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.card.border-info {
|
||||
border-left: 6px solid #0dcaf0;
|
||||
background-color: #e6f9fd; /* ljusblå ton */
|
||||
}
|
||||
|
||||
.card.border-warning {
|
||||
border-left: 6px solid #ffc107;
|
||||
background-color: #fff9e6; /* ljusgul ton */
|
||||
}
|
||||
|
||||
.card.border-success {
|
||||
border-left: 6px solid #28a745;
|
||||
background-color: #e6f9ec; /* ljusgrön ton */
|
||||
}
|
||||
|
||||
.card.border-inprogress {
|
||||
border-left: 6px solid #fd7e14;
|
||||
background-color: #fff3e6; /* ljusorange ton */
|
||||
}
|
||||
|
||||
.card-header {
|
||||
font-weight: 700;
|
||||
font-size: 0.95rem;
|
||||
background-color: rgba(0, 0, 0, 0.05); /* fallback */
|
||||
padding: 10px 12px;
|
||||
color: #1a202c;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.border-info .card-header {
|
||||
background-color: #0dcaf0;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.border-warning .card-header {
|
||||
background-color: #ffc107;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.border-success .card-header {
|
||||
background-color: #28a745;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.border-inprogress .card-header {
|
||||
background-color: #fd7e14;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.card-header .pizza-name {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 10px 12px;
|
||||
font-size: 0.85rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.card-body ul {
|
||||
margin: 0;
|
||||
padding-left: 1.2rem;
|
||||
list-style: disc;
|
||||
}
|
||||
|
||||
.card .btn {
|
||||
font-size: 0.8rem;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
|
||||
/* Klara beställningar – smalare liststil */
|
||||
#ordersContainer ul.list-group {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
#ordersContainer ul.list-group li {
|
||||
background: #ffffff;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 6px;
|
||||
padding: 8px 12px;
|
||||
font-size: 0.9rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#ordersContainer ul.list-group li form {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Responsiv */
|
||||
@media only screen and (max-width: 900px) {
|
||||
.admin-grid {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.available-pizzas {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.completed-orders-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.completed-order-box {
|
||||
background-color: #e2e8f0;
|
||||
border-radius: 8px;
|
||||
padding: 8px 10px;
|
||||
font-size: 0.85rem;
|
||||
min-width: 160px;
|
||||
max-width: 180px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.completed-order-box strong {
|
||||
font-weight: 600;
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.restore-form {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
right: 6px;
|
||||
}
|
||||
|
||||
.restore-form button {
|
||||
padding: 2px 6px;
|
||||
font-size: 0.75rem;
|
||||
line-height: 1;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
@@ -9,51 +9,53 @@ app.directive('draggableItem', function () {
|
||||
onItemDrop: '&'
|
||||
},
|
||||
link: function (scope, element) {
|
||||
const row = element[0];
|
||||
const handle = row.querySelector('.drag-handle');
|
||||
|
||||
function isEditing() {
|
||||
return scope.category && scope.category.editing;
|
||||
}
|
||||
|
||||
function updateDraggableAttr() {
|
||||
element[0].setAttribute('draggable', isEditing() ? 'true' : 'false');
|
||||
element[0].classList.toggle('draggable-enabled', isEditing());
|
||||
// Gör handtaget till draggable om editing är aktivt
|
||||
scope.$watch('category.editing', function (editing) {
|
||||
if (handle) handle.setAttribute('draggable', editing ? 'true' : 'false');
|
||||
});
|
||||
|
||||
if (handle) {
|
||||
handle.addEventListener('dragstart', function (e) {
|
||||
if (!isEditing()) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
e.dataTransfer.setData('text/plain', JSON.stringify({
|
||||
type: 'item',
|
||||
itemId: scope.item.id,
|
||||
fromCategoryId: scope.category.id
|
||||
}));
|
||||
|
||||
const ghost = row.cloneNode(true);
|
||||
ghost.style.position = 'absolute';
|
||||
ghost.style.top = '-9999px';
|
||||
ghost.style.left = '-9999px';
|
||||
ghost.style.width = `${row.offsetWidth}px`;
|
||||
ghost.style.opacity = '0.7';
|
||||
document.body.appendChild(ghost);
|
||||
e.dataTransfer.setDragImage(ghost, 0, 0);
|
||||
setTimeout(() => document.body.removeChild(ghost), 0);
|
||||
|
||||
document.querySelectorAll('.drop-zone').forEach(el => el.classList.add('active-drop-target'));
|
||||
});
|
||||
|
||||
handle.addEventListener('dragend', function () {
|
||||
document.querySelectorAll('.drop-zone').forEach(el => el.classList.remove('active-drop-target'));
|
||||
});
|
||||
}
|
||||
|
||||
updateDraggableAttr();
|
||||
scope.$watch('category.editing', updateDraggableAttr);
|
||||
|
||||
element[0].addEventListener('dragstart', function (e) {
|
||||
if (!isEditing()) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
e.dataTransfer.setData('text/plain', JSON.stringify({
|
||||
type: 'item',
|
||||
fromCategoryId: scope.category.id,
|
||||
itemId: scope.item.id
|
||||
}));
|
||||
|
||||
const ghost = element[0].cloneNode(true);
|
||||
ghost.style.position = 'absolute';
|
||||
ghost.style.top = '-9999px';
|
||||
ghost.style.left = '-9999px';
|
||||
ghost.style.width = element[0].offsetWidth + 'px';
|
||||
ghost.style.opacity = '0.7';
|
||||
document.body.appendChild(ghost);
|
||||
e.dataTransfer.setDragImage(ghost, 0, 0);
|
||||
|
||||
setTimeout(() => document.body.removeChild(ghost), 0);
|
||||
|
||||
document.querySelectorAll('.drop-zone').forEach(el => el.classList.add('active-drop-target'));
|
||||
});
|
||||
|
||||
element[0].addEventListener('dragend', function () {
|
||||
document.querySelectorAll('.drop-zone').forEach(el => el.classList.remove('active-drop-target'));
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
app.directive('dropPlaceholder', function () {
|
||||
return {
|
||||
restrict: 'A',
|
||||
@@ -85,36 +87,30 @@ app.directive('dropPlaceholder', function () {
|
||||
|
||||
e.preventDefault();
|
||||
element[0].classList.add('drag-over');
|
||||
label.style.display = 'block';
|
||||
});
|
||||
|
||||
element[0].addEventListener('dragleave', function () {
|
||||
element[0].classList.remove('drag-over');
|
||||
label.style.display = 'none';
|
||||
});
|
||||
|
||||
element[0].addEventListener('drop', function (e) {
|
||||
if (!isEditing()) return;
|
||||
e.preventDefault();
|
||||
element[0].classList.remove('drag-over');
|
||||
label.style.display = 'none';
|
||||
|
||||
const dataText = e.dataTransfer.getData('text/plain');
|
||||
try {
|
||||
const data = JSON.parse(dataText);
|
||||
if (data.type !== 'item') return;
|
||||
const data = JSON.parse(dataText);
|
||||
if (data.type !== 'item') return;
|
||||
|
||||
scope.$apply(() => {
|
||||
scope.onDropItem({
|
||||
data: data,
|
||||
targetCategory: scope.category,
|
||||
targetIndex: scope.index
|
||||
});
|
||||
scope.$apply(() => {
|
||||
scope.onDropItem({
|
||||
data: data,
|
||||
targetCategory: scope.category,
|
||||
targetIndex: scope.index
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("Error parsing drop data:", err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -181,22 +177,49 @@ app.directive('draggableCategory', function () {
|
||||
const header = element[0].querySelector('.card-header');
|
||||
if (!header) return;
|
||||
|
||||
function updateDraggableAttr() {
|
||||
header.setAttribute('draggable', scope.category.allowDrag ? 'true' : 'false');
|
||||
function isDragEnabled() {
|
||||
return scope.category && scope.category.editing && scope.category.allowDrag;
|
||||
}
|
||||
|
||||
scope.$watch('category.allowDrag', updateDraggableAttr);
|
||||
function updateDraggableAttr() {
|
||||
header.setAttribute('draggable', isDragEnabled() ? 'true' : 'false');
|
||||
}
|
||||
|
||||
scope.$watchGroup(['category.editing', 'category.allowDrag'], updateDraggableAttr);
|
||||
updateDraggableAttr();
|
||||
|
||||
header.addEventListener('dragstart', function (e) {
|
||||
if (!scope.category.allowDrag) {
|
||||
if (!isDragEnabled()) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// Endast tillåt drag från just headern, inte från t.ex. knappar
|
||||
if (e.target !== header) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
e.dataTransfer.setData('text/plain', JSON.stringify({
|
||||
type: 'category',
|
||||
categoryId: scope.category.id
|
||||
}));
|
||||
|
||||
const ghost = element[0].cloneNode(true);
|
||||
ghost.style.position = 'absolute';
|
||||
ghost.style.top = '-9999px';
|
||||
ghost.style.left = '-9999px';
|
||||
ghost.style.width = element[0].offsetWidth + 'px';
|
||||
ghost.style.opacity = '0.7';
|
||||
document.body.appendChild(ghost);
|
||||
e.dataTransfer.setDragImage(ghost, 0, 0);
|
||||
setTimeout(() => document.body.removeChild(ghost), 0);
|
||||
|
||||
document.querySelectorAll('.drop-zone').forEach(el => el.classList.add('active-drop-target'));
|
||||
});
|
||||
|
||||
header.addEventListener('dragend', function () {
|
||||
document.querySelectorAll('.drop-zone').forEach(el => el.classList.remove('active-drop-target'));
|
||||
});
|
||||
|
||||
element[0].addEventListener('dragover', function (e) {
|
||||
@@ -206,6 +229,7 @@ app.directive('draggableCategory', function () {
|
||||
element[0].addEventListener('drop', function (e) {
|
||||
e.preventDefault();
|
||||
element[0].classList.remove('drag-over');
|
||||
|
||||
const data = JSON.parse(e.dataTransfer.getData('text/plain'));
|
||||
if (data.type !== 'category') return;
|
||||
|
||||
|
||||
@@ -24,6 +24,50 @@ app.controller('BudgetController', function ($scope, $http) {
|
||||
e.stopPropagation();
|
||||
$scope.menuOpen = !$scope.menuOpen;
|
||||
};
|
||||
$scope.menuVisible = false;
|
||||
$scope.menuItem = null;
|
||||
$scope.menuStyle = {};
|
||||
|
||||
$scope.openItemMenu = function ($event, item) {
|
||||
const rect = $event.currentTarget.getBoundingClientRect();
|
||||
console.log("Menu position:", rect);
|
||||
|
||||
$scope.menuItem = item;
|
||||
$scope.menuItem.category = $scope.budget.categories.find(c => c.items.includes(item));
|
||||
|
||||
$scope.menuStyle = {
|
||||
top: `${rect.bottom + 4}px`,
|
||||
left: `${rect.left}px`
|
||||
};
|
||||
$scope.menuVisible = true;
|
||||
};
|
||||
|
||||
$scope.setItemType = function (item, type) {
|
||||
if (type === 'expense') {
|
||||
item.isExpense = true;
|
||||
item.includeInSummary = true;
|
||||
} else if (type === 'income') {
|
||||
item.isExpense = false;
|
||||
item.includeInSummary = true;
|
||||
} else if (type === 'saving') {
|
||||
item.isExpense = false;
|
||||
item.includeInSummary = false;
|
||||
}
|
||||
$scope.menuVisible = false;
|
||||
};
|
||||
|
||||
// Klick utanför stänger popup
|
||||
document.addEventListener('click', function (e) {
|
||||
const menu = document.querySelector('.item-floating-menu');
|
||||
if (menu && !$scope.menuVisible) return;
|
||||
|
||||
const isInside = menu?.contains(e.target);
|
||||
const isButton = e.target.closest('.icon-button');
|
||||
|
||||
if (!isInside && !isButton) {
|
||||
$scope.$apply(() => $scope.menuVisible = false);
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('click', function () {
|
||||
$scope.$apply(() => {
|
||||
@@ -117,8 +161,6 @@ app.controller('BudgetController', function ($scope, $http) {
|
||||
});
|
||||
}
|
||||
|
||||
category.editing = false;
|
||||
|
||||
const payload = {
|
||||
id: category.id,
|
||||
name: category.name,
|
||||
@@ -135,8 +177,13 @@ app.controller('BudgetController', function ($scope, $http) {
|
||||
};
|
||||
|
||||
$http.put(`/api/budget/category/${category.id}`, payload)
|
||||
.then(() => $scope.showToast("Kategori sparad!"))
|
||||
.catch(() => $scope.showToast("Fel vid sparande av kategori", true));
|
||||
.then(() => {
|
||||
$scope.showToast("Kategori sparad!");
|
||||
category.editing = false; // ✅ flytta hit
|
||||
})
|
||||
.catch(() => {
|
||||
$scope.showToast("Fel vid sparande av kategori", true);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.deleteCategory = function (category) {
|
||||
@@ -390,6 +437,30 @@ app.controller('BudgetController', function ($scope, $http) {
|
||||
$scope.showToast("Fel vid omplacering", true);
|
||||
});
|
||||
};
|
||||
$scope.updateItemType = function (item) {
|
||||
if (item.type === 'income') {
|
||||
item.isExpense = false;
|
||||
item.includeInSummary = true;
|
||||
} else if (item.type === 'expense') {
|
||||
item.isExpense = true;
|
||||
item.includeInSummary = true;
|
||||
} else if (item.type === 'saving') {
|
||||
item.isExpense = false;
|
||||
item.includeInSummary = false;
|
||||
}
|
||||
};
|
||||
$scope.setItemType = function (item, type) {
|
||||
if (type === 'income') {
|
||||
item.isExpense = false;
|
||||
item.includeInSummary = true;
|
||||
} else if (type === 'expense') {
|
||||
item.isExpense = true;
|
||||
item.includeInSummary = true;
|
||||
} else if (type === 'saving') {
|
||||
item.isExpense = false;
|
||||
item.includeInSummary = false;
|
||||
}
|
||||
};
|
||||
$scope.createNewCategory = function () {
|
||||
const defaultName = "Ny kategori";
|
||||
const newOrder = $scope.budget.categories.length; // sist i listan
|
||||
@@ -424,6 +495,68 @@ app.controller('BudgetController', function ($scope, $http) {
|
||||
$scope.showToast("Fel vid skapande av kategori", true);
|
||||
});
|
||||
};
|
||||
$scope.addItem = function (category) {
|
||||
if (!category.newItemName || !category.newItemAmount) return;
|
||||
|
||||
const tempId = `temp-${Date.now()}-${Math.random()}`; // temporärt ID
|
||||
|
||||
const newItem = {
|
||||
id: tempId,
|
||||
name: category.newItemName,
|
||||
amount: parseFloat(category.newItemAmount),
|
||||
isExpense: true,
|
||||
includeInSummary: true,
|
||||
budgetCategoryId: category.id
|
||||
};
|
||||
|
||||
category.items.push(newItem);
|
||||
category.newItemName = "";
|
||||
category.newItemAmount = "";
|
||||
};
|
||||
$scope.deleteItem = function (category, item) {
|
||||
console.log("Försöker ta bort:", item);
|
||||
|
||||
if (!item.id || item.id.toString().startsWith("temp-")) {
|
||||
// Ta bort direkt om det är ett nytt (osparat) item
|
||||
category.items = category.items.filter(i => i !== item);
|
||||
$scope.showToast("Ospard post togs bort");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm("Vill du ta bort denna post?")) return;
|
||||
|
||||
$http.delete(`/api/budget/item/${item.id}`)
|
||||
.then(() => {
|
||||
category.items = category.items.filter(i => i.id !== item.id);
|
||||
$scope.showToast("Post borttagen!");
|
||||
})
|
||||
.catch(err => {
|
||||
console.error("Fel vid borttagning av item:", err);
|
||||
$scope.showToast("Kunde inte ta bort posten", true);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.handleItemDrop = function (event, data, targetCategory) {
|
||||
console.log("Item drop received:", data, "to", targetCategory);
|
||||
// Hitta källkategorin
|
||||
const sourceCat = $scope.budget.categories.find(c => c.id === data.fromCategoryId);
|
||||
if (!sourceCat) return;
|
||||
const itemIndex = sourceCat.items.findIndex(i => i.id === data.itemId);
|
||||
if (itemIndex === -1) return;
|
||||
const [movedItem] = sourceCat.items.splice(itemIndex, 1);
|
||||
targetCategory.items.push(movedItem);
|
||||
$scope.$applyAsync();
|
||||
};
|
||||
$scope.handleItemPreciseDrop = function (data, targetCategory, targetIndex) {
|
||||
console.log("Precise drop at index", targetIndex);
|
||||
const sourceCat = $scope.budget.categories.find(c => c.id === data.fromCategoryId);
|
||||
if (!sourceCat) return;
|
||||
const itemIndex = sourceCat.items.findIndex(i => i.id === data.itemId);
|
||||
if (itemIndex === -1) return;
|
||||
const [movedItem] = sourceCat.items.splice(itemIndex, 1);
|
||||
targetCategory.items.splice(targetIndex, 0, movedItem);
|
||||
$scope.$applyAsync();
|
||||
};
|
||||
|
||||
|
||||
$scope.loadBudget();
|
||||
|
||||
@@ -7,7 +7,8 @@ angular.module('mealMenuApp', ['ngSanitize'])
|
||||
.controller('MealMenuController', function ($scope, $http, $sce) {
|
||||
console.log("Controller initierad");
|
||||
|
||||
$scope.viewMode = 'list';
|
||||
const savedView = localStorage.getItem('mealViewMode');
|
||||
$scope.viewMode = savedView === 'card' || savedView === 'list' ? savedView : 'card';
|
||||
$scope.tooltip = {};
|
||||
$scope.meals = [];
|
||||
$scope.menu = {};
|
||||
@@ -15,10 +16,6 @@ angular.module('mealMenuApp', ['ngSanitize'])
|
||||
$scope.selectedWeek = getWeek(today);
|
||||
$scope.selectedYear = today.getFullYear();
|
||||
$scope.daysOfWeek = ["Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag", "Söndag"];
|
||||
const savedViewMode = localStorage.getItem('mealViewMode');
|
||||
if (savedViewMode === 'list' || savedViewMode === 'card') {
|
||||
$scope.viewMode = savedViewMode;
|
||||
}
|
||||
|
||||
$scope.loadMeals = function () {
|
||||
console.log("Hämtar måltider...");
|
||||
@@ -131,12 +128,11 @@ angular.module('mealMenuApp', ['ngSanitize'])
|
||||
$scope.viewMode = $scope.viewMode === 'list' ? 'card' : 'list';
|
||||
localStorage.setItem('mealViewMode', $scope.viewMode); // ← spara läget
|
||||
|
||||
setTimeout(() => {
|
||||
const btn = document.getElementById('toggle-view');
|
||||
if (btn) {
|
||||
btn.textContent = $scope.getViewIcon();
|
||||
}
|
||||
$timeout(() => {
|
||||
const viewBtn = document.getElementById('toggle-view');
|
||||
if (viewBtn) viewBtn.textContent = $scope.getViewIcon();
|
||||
}, 0);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -174,8 +170,5 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
}
|
||||
|
||||
// Initiera ikon för vy
|
||||
const scope = angular.element(document.body).scope();
|
||||
if (viewBtn && scope) {
|
||||
viewBtn.textContent = scope.viewMode === 'list' ? '🗒️' : '▣';
|
||||
}
|
||||
|
||||
});
|
||||
|
||||