Skip to content

Commit

Permalink
#22 fix frontend components
Browse files Browse the repository at this point in the history
  • Loading branch information
scmet committed Oct 26, 2024
1 parent f50beea commit 8f92dd8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 30 deletions.
11 changes: 10 additions & 1 deletion frontend/src/Boards.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default {
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ name: this.boardName }),
body: JSON.stringify(requestBody),
});
if (!response.ok) {
Expand All @@ -154,7 +154,16 @@ export default {
}
},
goToApp(board) {
if (this.timeTracking) {
this.$router.push({
name: 'Board-Time-Tracking',
params: {
userId: this.$route.params.userId,
boardId: board.timekeeping_board_id
}});
} else {
this.$router.push(`/groups/${this.$route.params.groupId}/boards/${board.board_id}`);
}
},
},
}
Expand Down
39 changes: 18 additions & 21 deletions frontend/src/TimeTrackingBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
<Label
v-for="month in months"
:key="month"
ref="monthLabel"
ref="month + 'Label'"
:sectionTitle="month.charAt(0).toUpperCase() + month.slice(1)"
:status="month"
:items="monthItems[month]"
@update:items="monthItems[month] = $event"
@cardMoved="handleCardMoved"
/>
</v-row>
</v-card>
Expand All @@ -56,6 +55,12 @@ export default {
addTimeCard,
},
setup() {
const monthNames = [
'january', 'february', 'march', 'april', 'may', 'june',
'july', 'august', 'september', 'october', 'november', 'december'
];
const monthItems = {
january: [],
february: [],
Expand All @@ -71,18 +76,19 @@ export default {
december:[],
};
const boardName = ref("Kanban Board");
const boardName = ref("Time Tracking");
const quarters = [
['januar', 'february', 'march'],
['january', 'february', 'march'],
['april', 'may', 'june'],
['juli', 'august', 'september'],
['july', 'august', 'september'],
['october', 'november', 'december'],
];
return {
monthNames,
monthItems,
boardName,
quarters
Expand All @@ -92,22 +98,13 @@ export default {
showDialog() {
this.$refs.addTimeCard.showDialog();
},
reloadCardsByMonth(month) {
switch (month) {
case 'january':
this.$refs.janLabel.loadCards();
break;
case 'working_on':
this.$refs.febLabel.loadCards();
break;
case 'review':
this.$refs.marLabel.loadCards();
break;
case 'done':
this.$refs.junLabel.loadCards();
break;
default:
console.error('Invalid status');
reloadCardsByMonth(monthNumber) {
const monthName = this.monthNames[monthNumber - 1];
if (this.$refs[`${monthName}Label`]) {
this.$refs[`${monthName}Label`].loadCards();
} else {
console.error('Invalid month reference:', monthName);
}
},
},
Expand Down
9 changes: 2 additions & 7 deletions frontend/src/components/addTimeCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export default {
const card = {
date: this.date,
start: this.start,
end: this.end,
time: this.calculatedTime,
description: this.cardDescription,
};
Expand All @@ -96,7 +95,7 @@ export default {
throw new Error('Network response was not ok');
}
this.resetForm();
this.$emit('addedMonth',this.date.getMonth+1);
this.$emit('addedMonth',this.date.getMonth()+1);
this.dialog = false;
} catch (error) {
console.error('There was an error!', error);
Expand All @@ -118,11 +117,7 @@ export default {
const endTime = this.parseTime(this.end);
const calculatedTime = (endTime - startTime) / (1000 * 60 * 60); // Berechnung in Stunden
if (calculatedTime > 0) {
this.calculatedTime = calculatedTime.toFixed(2); // Zeit auf zwei Dezimalstellen
} else {
this.calculatedTime = '0.00'; // Setze auf 0, wenn ungültig
}
this.calculatedTime = calculatedTime > 0 ? calculatedTime : 0;
},
resetForm() {
this.start = new Date(new Date().getTime() - 90 * 60 * 1000).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const routes = [
//props: true
},
{
path: '/users/:userId/boards/board:id',
path: '/users/:userId/boards/boardId',
name: 'Board-Time-Tracking',
component:TimeTrackingBoard
}
Expand Down

0 comments on commit 8f92dd8

Please sign in to comment.