PasskeyCreateDialog.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template lang="pug">
  2. q-dialog(ref='dialogRef', @hide='onDialogHide', persistent)
  3. q-card(style='min-width: 650px;')
  4. q-card-section.card-header
  5. q-icon(name='img:/_assets/icons/fluent-add-key.svg', left, size='sm')
  6. span {{t(`profile.passkeysAdd`)}}
  7. .q-py-sm
  8. .text-body2.q-px-md.q-py-sm {{t(`profile.passkeysNameHint`)}}
  9. q-item
  10. blueprint-icon(icon='key')
  11. q-item-section
  12. q-input(
  13. outlined
  14. v-model='state.name'
  15. dense
  16. hide-bottom-space
  17. :label='t(`profile.passkeysName`)'
  18. :aria-label='t(`profile.passkeysName`)'
  19. autofocus
  20. @keyup.enter='save'
  21. )
  22. q-card-actions.card-actions
  23. q-space
  24. q-btn.acrylic-btn(
  25. flat
  26. :label='t(`common.actions.cancel`)'
  27. color='grey'
  28. padding='xs md'
  29. @click='onDialogCancel'
  30. )
  31. q-btn(
  32. unelevated
  33. :label='t(`common.actions.save`)'
  34. color='primary'
  35. padding='xs md'
  36. @click='save'
  37. )
  38. </template>
  39. <script setup>
  40. import { useI18n } from 'vue-i18n'
  41. import { useDialogPluginComponent, useQuasar } from 'quasar'
  42. import { reactive } from 'vue'
  43. // EMITS
  44. defineEmits([
  45. ...useDialogPluginComponent.emits
  46. ])
  47. // QUASAR
  48. const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent()
  49. const $q = useQuasar()
  50. // I18N
  51. const { t } = useI18n()
  52. // DATA
  53. const state = reactive({
  54. name: ''
  55. })
  56. // METHODS
  57. async function save () {
  58. try {
  59. if (!state.name || state.name.trim().length < 1 || state.name.length > 255) {
  60. throw new Error(t('profile.passkeysInvalidName'))
  61. }
  62. onDialogOK({
  63. name: state.name
  64. })
  65. } catch (err) {
  66. $q.notify({
  67. type: 'negative',
  68. message: err.message
  69. })
  70. }
  71. }
  72. </script>