Add.vue 1.3 KB

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