AddFolder.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 :label="$t('action.save')" @click.native="addFolder" />
  28. <ButtonSecondary
  29. :label="$t('action.cancel')"
  30. @click.native="hideModal"
  31. />
  32. </span>
  33. </template>
  34. </SmartModal>
  35. </template>
  36. <script>
  37. import { defineComponent } from "@nuxtjs/composition-api"
  38. export default defineComponent({
  39. props: {
  40. show: Boolean,
  41. folder: { type: Object, default: () => {} },
  42. folderPath: { type: String, default: null },
  43. collectionIndex: { type: Number, default: null },
  44. },
  45. data() {
  46. return {
  47. name: null,
  48. }
  49. },
  50. methods: {
  51. addFolder() {
  52. if (!this.name) {
  53. this.$toast.error(this.$t("folder.invalid_name"))
  54. return
  55. }
  56. this.$emit("add-folder", {
  57. name: this.name,
  58. folder: this.folder,
  59. path: this.folderPath || `${this.collectionIndex}`,
  60. })
  61. this.hideModal()
  62. },
  63. hideModal() {
  64. this.name = null
  65. this.$emit("hide-modal")
  66. },
  67. },
  68. })
  69. </script>