ActivationSwitch.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div>
  3. <v-switch
  4. :model-value="modelValue"
  5. :label="$t('activateOpentalentSiteWeb')"
  6. inset
  7. :color="color"
  8. :base-color="color"
  9. false-icon="fas fa-xmark"
  10. true-icon="fas fa-check"
  11. hide-details
  12. @update:model-value="onUpdate"
  13. />
  14. <LazyLayoutDialog :show="showWebsiteDeactivationDialog" theme="warning">
  15. <template #dialogTitle>
  16. {{ $t('please_confirm') }}
  17. </template>
  18. <template #dialogText>
  19. <v-col>
  20. <div>
  21. {{
  22. $t('yourOpentalentWebsiteWillBeDeactivatedOnceYouLlHaveSaved')
  23. }}.
  24. </div>
  25. <span>{{ $t('doYouWantToContinue') }} ?</span>
  26. </v-col>
  27. </template>
  28. <template #dialogBtn>
  29. <v-btn class="theme-neutral-soft mr-4" @click="onDialogNoBtnClick">
  30. {{ $t('cancel') }}
  31. </v-btn>
  32. <v-btn class="theme-primary" @click="onDialogYesBtnClick">
  33. {{ $t('yes') }}
  34. </v-btn>
  35. </template>
  36. </LazyLayoutDialog>
  37. </div>
  38. </template>
  39. <script setup lang="ts">
  40. import { useTheme } from 'vuetify'
  41. import type { Ref } from 'vue'
  42. const theme = useTheme()
  43. const emit = defineEmits(['update:modelValue'])
  44. const i18n = useI18n()
  45. const props = defineProps({
  46. modelValue: {
  47. type: Boolean,
  48. required: true,
  49. },
  50. })
  51. const color = computed(() =>
  52. props.modelValue
  53. ? theme.current.value.colors.success
  54. : theme.current.value.colors.danger,
  55. )
  56. const showWebsiteDeactivationDialog: Ref<boolean> = ref(false)
  57. const onUpdate = (value: boolean) => {
  58. if (!value) {
  59. showWebsiteDeactivationDialog.value = true
  60. } else {
  61. emit('update:modelValue', value)
  62. }
  63. }
  64. const onDialogYesBtnClick = () => {
  65. showWebsiteDeactivationDialog.value = false
  66. emit('update:modelValue', false)
  67. }
  68. const onDialogNoBtnClick = () => {
  69. showWebsiteDeactivationDialog.value = false
  70. emit('update:modelValue', true)
  71. }
  72. </script>
  73. <style scoped lang="scss"></style>