Add button to copy last week's availability

master
John Montagu, the 4th Earl of Sandvich 2024-11-10 02:46:16 -08:00
parent 9b9b86171f
commit ae6f5e8884
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
2 changed files with 19 additions and 6 deletions

View File

@ -11,7 +11,7 @@ const dateStart = computed(() => model.value.format("L"));
const dateEnd = computed(() => model.value.clone().add(6, "days").format("L"));
function incrementDate(delta: number) {
model.value = model.value.clone().add(delta, "days");
model.value = model.value.clone().add(delta, "weeks");
//let newDate = new Date(model.value);
//newDate.setDate(newDate.getDate() + delta);
//model.value = newDate;
@ -20,11 +20,11 @@ function incrementDate(delta: number) {
<template>
<div class="scroll-box">
<button class="transparent eq" @click="incrementDate(-7)" :disabled="isDisabled">
<button class="transparent eq" @click="incrementDate(-1)" :disabled="isDisabled">
<i class="bi bi-caret-left-fill"></i>
</button>
<span class="date-range">{{ dateStart }} &ndash; {{ dateEnd }}</span>
<button class="transparent eq" @click="incrementDate(7)" :disabled="isDisabled">
<button class="transparent eq" @click="incrementDate(1)" :disabled="isDisabled">
<i class="bi bi-caret-right-fill"></i>
</button>
</div>

View File

@ -41,6 +41,14 @@ function saveSchedule() {
});
}
function copyPreviousWeek() {
schedule.fetchSchedule(schedule.dateStart.clone().add(-7, "days"))
.then((response) => {
schedule.saveSchedule();
return response;
});
}
onMounted(() => {
teamsStore.fetchTeams()
.then((teamsList) => {
@ -111,9 +119,14 @@ onMounted(() => {
<i class="bi bi-check-circle-fill"></i>
</button>
</template>
<button v-else class="accent" @click="isEditing = true">
<i class="bi bi-pencil-fill"></i>
</button>
<template v-else>
<button @click="copyPreviousWeek">
Copy previous week
</button>
<button class="accent" @click="isEditing = true">
<i class="bi bi-pencil-fill"></i>
</button>
</template>
</div>
</div>
</div>