(admin) timesheets overview improvements

This commit is contained in:
Andrea Vos 2023-12-02 15:03:44 +01:00
parent bf1287bdf4
commit b9805d114d
2 changed files with 33 additions and 1 deletions

View File

@ -21,6 +21,12 @@
<li v-for="(_, period) in PERIODS" class="list-inline-item">
<a href="#" @click.prevent="setPeriod(period)" class="btn btn-outline-primary">{{period}}</a>
</li>
<li class="list-inline-item">
<a href="#" @click.prevent="addPeriod({months: -1})" class="btn btn-outline-primary">&lt;</a>
</li>
<li class="list-inline-item">
<a href="#" @click.prevent="addPeriod({months: 1})" class="btn btn-outline-primary">&gt;</a>
</li>
</ul>
<div class="input-group mb-3">
<span class="input-group-text">Start:</span>
@ -62,6 +68,12 @@
</ul>
</td>
</tr>
<tr>
<th>Sum</th>
<td>{{ hoursSumTotal }}</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
@ -99,6 +111,15 @@ export default {
setPeriod(period) {
[this.startYear, this.startMonth, this.endYear, this.endMonth] = PERIODS[period];
},
addPeriod(offset) {
const startTime = DateTime.fromObject({year: this.startYear, month: this.startMonth}).plus(offset);
const endTime = DateTime.fromObject({year: this.endYear, month: this.endMonth}).plus(offset);
this.startYear = startTime.year;
this.startMonth = startTime.month;
this.endYear = endTime.year;
this.endMonth = endTime.month;
},
isInRange(year, month) {
const x = DateTime.local(year, month, 15);
const begin = DateTime.local(this.startYear, this.startMonth, 1).startOf('month');
@ -137,6 +158,13 @@ export default {
}
return sum;
},
hoursSumTotal() {
let sum = 0;
for (let username in this.hoursSummary) {
sum += this.hoursSummary[username];
}
return sum;
},
},
head() {
return head({

View File

@ -1,6 +1,8 @@
import {DateTime} from "luxon";
export const max = DateTime.now();
const now = DateTime.now();
const prevMonth = now.minus({months: 1});
export const max = now;
export const min = DateTime.local(2020, 1, 1);
export const closed = DateTime.now().minus({ months: 1 }).startOf('month');
@ -46,4 +48,6 @@ export const TRANSFER_METHODS = {
export const PERIODS = {
'2020-2022': [2020, 1, 2022, 12],
'2023': [2023, 1, 2023, 12],
'previous month': [now.year, now.month, now.year, now.month],
'current month': [prevMonth.year, prevMonth.month, prevMonth.year, prevMonth.month],
}