From 7d22e1ab07c48dc9a837fc53156c90ca1d684ed6 Mon Sep 17 00:00:00 2001 From: Igor Manjencic Date: Tue, 7 Nov 2023 16:18:34 +0100 Subject: [PATCH] feat(ZMS-817): disable plus minus button --- frontend/src/components/ServiceFinder.vue | 20 +++++++++++++++++++ .../src/store/modules/formData/mutations.js | 1 - 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/ServiceFinder.vue b/frontend/src/components/ServiceFinder.vue index 956e271..15a9a57 100644 --- a/frontend/src/components/ServiceFinder.vue +++ b/frontend/src/components/ServiceFinder.vue @@ -68,6 +68,7 @@ class="appointment-count-button button-down" :aria-label="`Anzahl der Dienstleistung verringern auf ` + (appointmentCounts[$store.state.data.service.id] - 1)" :aria-describedby="`appointment-count-name-` + $store.state.data.service.id" + :disabled="!canDecreaseAppointments($store.state.data.service)" fab @click="decreaseAppointments($store.state.data.service)" > @@ -87,6 +88,7 @@ class="appointment-count-button" :aria-label="`Anzahl der Dienstleistung erhöhen auf` + (appointmentCounts[$store.state.data.service.id] + 1)" :aria-describedby="`appointment-count-name-` + $store.state.data.service.id" + :disabled="!canIncreaseAppointments($store.state.data.service)" fab @click="increaseAppointments($store.state.data.service)" > @@ -109,6 +111,7 @@ class="appointment-count-button button-down" :aria-label="`Anzahl der Dienstleistung verringern auf ` + (appointmentCounts[subService.id] - 1)" :aria-describedby="`appointment-count-name-` + subService.id" + :disabled="!canDecreaseAppointments(subService)" fab @click="decreaseAppointments(subService)" > @@ -127,6 +130,7 @@ class="appointment-count-button" :aria-label="`Anzahl der Dienstleistung erhöhen auf ` + (appointmentCounts[subService.id] + 1)" :aria-describedby="`appointment-count-name-` + subService.id" + :disabled="!canIncreaseAppointments(subService)" fab @click="increaseAppointments(subService)" > @@ -215,6 +219,22 @@ export default { this.$store.commit('data/decreaseAppointmentCount', service.id) this.appointmentCountTriggered++ }, + canIncreaseAppointments(service) { + if (this.$store.state.data.appointmentCounts[service.id] + 1 + > this.$store.state.data.servicesById[service.id].maxQuantity + ) { + return false + } + + return true + }, + canDecreaseAppointments(service) { + if (this.$store.state.data.appointmentCounts[service.id] - 1 < 0) { + return false + } + + return true + }, onChange(value) { if (!value) { return diff --git a/frontend/src/store/modules/formData/mutations.js b/frontend/src/store/modules/formData/mutations.js index 2c19d69..074d5a3 100644 --- a/frontend/src/store/modules/formData/mutations.js +++ b/frontend/src/store/modules/formData/mutations.js @@ -4,7 +4,6 @@ const checkMaxSlots = (state) => { let minSlots = 0 for (var selectedServiceId in state.appointmentCounts) { minSlots += state.appointmentCounts[selectedServiceId] * state.servicesById[selectedServiceId].minSlots - console.log(minSlots) } if (minSlots > MAX_SLOTS) {