AddFolder.vue 1.6 KB

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