Edit.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <form-wrapper :title="$t('auth.webauthn.rename_device')">
  3. <form @submit.prevent="updateCredential" @keydown="form.onKeydown($event)">
  4. <form-field :form="form" fieldName="name" inputType="text" :label="$t('commons.new_name')" autofocus />
  5. <div class="field is-grouped">
  6. <div class="control">
  7. <v-button :isLoading="form.isBusy">{{ $t('commons.save') }}</v-button>
  8. </div>
  9. <div class="control">
  10. <button type="button" class="button is-text" @click="cancelCreation">{{ $t('commons.cancel') }}</button>
  11. </div>
  12. </div>
  13. </form>
  14. </form-wrapper>
  15. </template>
  16. <script>
  17. import Form from './../../../components/Form'
  18. export default {
  19. data() {
  20. return {
  21. form: new Form({
  22. name: this.name,
  23. })
  24. }
  25. },
  26. props: ['id', 'name'],
  27. methods: {
  28. async updateCredential() {
  29. await this.form.patch('/webauthn/credentials/' + this.id + '/name')
  30. if( this.form.errors.any() === false ) {
  31. this.$router.push({name: 'settings.webauthn', params: { toRefresh: true }})
  32. }
  33. },
  34. cancelCreation: function() {
  35. this.$router.push({ name: 'settings.webauthn' });
  36. },
  37. },
  38. }
  39. </script>