Skip to content

Commit

Permalink
Fix booking link toggle in schedule creation (#697)
Browse files Browse the repository at this point in the history
* πŸ”¨ Fix booking link toggle in schedule creation

* πŸ”¨ Revert type safe comparison

* βž• Add defaul values to SwitchToggle
  • Loading branch information
devmount authored Oct 1, 2024
1 parent 619cfcd commit 6bb9594
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/ScheduleCreation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ watch(
<switch-toggle
class="my-1 text-sm font-medium text-gray-500 dark:text-gray-300"
name="booking_confirmation"
:active="schedule.booking_confirmation"
:active="scheduleInput.booking_confirmation"
:label="t('label.bookingConfirmation')"
:disabled="!scheduleInput.active"
@changed="toggleBookingConfirmation"
Expand Down
17 changes: 15 additions & 2 deletions frontend/src/tbpro/elements/SwitchToggle.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { ref, onMounted, watch } from 'vue';
import { useI18n } from 'vue-i18n';
// component constants
Expand All @@ -16,7 +16,11 @@ interface Props {
label?: string; // input label
noLegend?: boolean; // hide "on" and "off" labels
}
const props = defineProps<Props>();
const props = withDefaults(defineProps<Props>(), {
disabled: false,
label: null,
noLegend: true,
});
// current state
const state = ref(false);
Expand All @@ -29,6 +33,15 @@ const toggleState = () => {
emit('changed', state.value);
}
};
// Update state if parent changes active prop
// e.g. after initializing async data
watch(
() => props.active,
() => {
state.value = props.active;
}
);
</script>

<template>
Expand Down

0 comments on commit 6bb9594

Please sign in to comment.