AddFolder.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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="selectLabelGqlAddFolder"
  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="selectLabelGqlAddFolder">
  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 lang="ts">
  36. import { defineComponent } from "@nuxtjs/composition-api"
  37. export default defineComponent({
  38. props: {
  39. show: Boolean,
  40. folderPath: { type: String, default: null },
  41. collectionIndex: { type: Number, default: null },
  42. },
  43. data() {
  44. return {
  45. name: null,
  46. }
  47. },
  48. methods: {
  49. addFolder() {
  50. // TODO: Blocking when name is null ?
  51. this.$emit("add-folder", {
  52. name: this.name,
  53. path: this.folderPath || `${this.collectionIndex}`,
  54. })
  55. this.hideModal()
  56. },
  57. hideModal() {
  58. this.name = null
  59. this.$emit("hide-modal")
  60. },
  61. },
  62. })
  63. </script>