Add.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. :loading="loadingState"
  30. @click.native="addNewCollection"
  31. />
  32. <ButtonSecondary
  33. :label="$t('action.cancel')"
  34. @click.native="hideModal"
  35. />
  36. </span>
  37. </template>
  38. </SmartModal>
  39. </template>
  40. <script>
  41. import { defineComponent } from "@nuxtjs/composition-api"
  42. export default defineComponent({
  43. props: {
  44. show: Boolean,
  45. loadingState: Boolean,
  46. },
  47. data() {
  48. return {
  49. name: null,
  50. }
  51. },
  52. methods: {
  53. addNewCollection() {
  54. if (!this.name) {
  55. this.$toast.error(this.$t("collection.invalid_name"))
  56. return
  57. }
  58. this.$emit("submit", this.name)
  59. },
  60. hideModal() {
  61. this.name = null
  62. this.$emit("hide-modal")
  63. },
  64. },
  65. })
  66. </script>