Add.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <SmartModal v-if="show" :title="$t('collection.new')" @close="hideModal">
  3. <template #body>
  4. <div class="flex flex-col px-2">
  5. <input
  6. id="selectLabelAdd"
  7. v-model="name"
  8. v-focus
  9. class="input floating-input"
  10. placeholder=" "
  11. type="text"
  12. autocomplete="off"
  13. @keyup.enter="addNewCollection"
  14. />
  15. <label for="selectLabelAdd">
  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="addNewCollection"
  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. },
  40. data() {
  41. return {
  42. name: null,
  43. }
  44. },
  45. methods: {
  46. addNewCollection() {
  47. if (!this.name) {
  48. this.$toast.error(this.$t("collection.invalid_name"), {
  49. icon: "error_outline",
  50. })
  51. return
  52. }
  53. this.$emit("submit", this.name)
  54. this.hideModal()
  55. },
  56. hideModal() {
  57. this.name = null
  58. this.$emit("hide-modal")
  59. },
  60. },
  61. })
  62. </script>