AddFolder.vue 1.5 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="selectLabelGqlAddFolder"
  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="selectLabelGqlAddFolder">
  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 lang="ts">
  37. import { defineComponent } from "@nuxtjs/composition-api"
  38. export default defineComponent({
  39. props: {
  40. show: Boolean,
  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.name_length_insufficient")}`)
  53. return
  54. }
  55. this.$emit("add-folder", {
  56. name: this.name,
  57. path: this.folderPath || `${this.collectionIndex}`,
  58. })
  59. this.hideModal()
  60. },
  61. hideModal() {
  62. this.name = null
  63. this.$emit("hide-modal")
  64. },
  65. },
  66. })
  67. </script>