AddFolder.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <SmartModal
  3. v-if="show"
  4. dialog
  5. :title="$t('folder.new')"
  6. @close="$emit('hide-modal')"
  7. >
  8. <template #body>
  9. <div class="flex flex-col px-2">
  10. <input
  11. id="selectLabelAddFolder"
  12. v-model="name"
  13. v-focus
  14. class="input floating-input"
  15. placeholder=" "
  16. type="text"
  17. autocomplete="off"
  18. @keyup.enter="addFolder"
  19. />
  20. <label for="selectLabelAddFolder">
  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="addFolder"
  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. folder: { type: Object, default: () => {} },
  46. folderPath: { type: String, default: null },
  47. collectionIndex: { type: Number, default: null },
  48. loadingState: Boolean,
  49. },
  50. data() {
  51. return {
  52. name: null,
  53. }
  54. },
  55. methods: {
  56. addFolder() {
  57. if (!this.name) {
  58. this.$toast.error(this.$t("folder.invalid_name"))
  59. return
  60. }
  61. this.$emit("add-folder", {
  62. name: this.name,
  63. folder: this.folder,
  64. path: this.folderPath || `${this.collectionIndex}`,
  65. })
  66. },
  67. hideModal() {
  68. this.name = null
  69. this.$emit("hide-modal")
  70. },
  71. },
  72. })
  73. </script>