Edit.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <SmartModal v-if="show" :title="$t('collection.edit')" @close="hideModal">
  3. <template #body>
  4. <div class="flex flex-col px-2">
  5. <input
  6. id="selectLabelEdit"
  7. v-model="name"
  8. v-focus
  9. class="input floating-input"
  10. placeholder=" "
  11. type="text"
  12. autocomplete="off"
  13. @keyup.enter="saveCollection"
  14. />
  15. <label for="selectLabelEdit">
  16. {{ $t("action.label") }}
  17. </label>
  18. </div>
  19. </template>
  20. <template #footer>
  21. <span>
  22. <ButtonPrimary
  23. :label="$t('action.save')"
  24. @click.native="saveCollection"
  25. />
  26. <ButtonSecondary
  27. :label="$t('action.cancel')"
  28. @click.native="hideModal"
  29. />
  30. </span>
  31. </template>
  32. </SmartModal>
  33. </template>
  34. <script>
  35. import { defineComponent } from "@nuxtjs/composition-api"
  36. export default defineComponent({
  37. props: {
  38. show: Boolean,
  39. placeholderCollName: { type: String, default: null },
  40. },
  41. data() {
  42. return {
  43. name: null,
  44. }
  45. },
  46. methods: {
  47. saveCollection() {
  48. if (!this.name) {
  49. this.$toast.error(this.$t("collection.invalid_name"), {
  50. icon: "error_outline",
  51. })
  52. return
  53. }
  54. this.$emit("submit", this.name)
  55. this.hideModal()
  56. },
  57. hideModal() {
  58. this.name = null
  59. this.$emit("hide-modal")
  60. },
  61. },
  62. })
  63. </script>