ActivationSwitch.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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:modelValue="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(
  23. 'yourOpentalentWebsiteWillBeDeactivatedOnceYouLlHaveSaved',
  24. )
  25. }}.
  26. </div>
  27. <span>{{ $t('doYouWantToContinue') }} ?</span>
  28. </v-col>
  29. </template>
  30. <template #dialogBtn>
  31. <v-btn
  32. class="theme-neutral-soft mr-4"
  33. @click="onDialogNoBtnClick"
  34. >
  35. {{ $t('cancel') }}
  36. </v-btn>
  37. <v-btn class="theme-primary" @click="onDialogYesBtnClick">
  38. {{ $t('yes') }}
  39. </v-btn>
  40. </template>
  41. </LazyLayoutDialog>
  42. </div>
  43. </template>
  44. <script setup lang="ts">
  45. import {useTheme} from 'vuetify';
  46. import type {Ref} from 'vue';
  47. const theme = useTheme()
  48. const emit = defineEmits(['update:modelValue'])
  49. const i18n = useI18n()
  50. const props = defineProps({
  51. modelValue: {
  52. type: Boolean,
  53. required: true,
  54. }
  55. })
  56. const color = computed(() => props.modelValue ?
  57. theme.current.value.colors['success'] :
  58. theme.current.value.colors['danger']
  59. )
  60. const showWebsiteDeactivationDialog: Ref<boolean> = ref(false)
  61. const onUpdate = (value: boolean) => {
  62. if (!value) {
  63. showWebsiteDeactivationDialog.value = true
  64. } else {
  65. emit('update:modelValue', value)
  66. }
  67. }
  68. const onDialogYesBtnClick = () => {
  69. showWebsiteDeactivationDialog.value = false
  70. emit('update:modelValue', false)
  71. }
  72. const onDialogNoBtnClick = () => {
  73. showWebsiteDeactivationDialog.value = false
  74. props.modelValue = true
  75. }
  76. </script>
  77. <style scoped lang="scss">
  78. </style>