AddFolder.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. // TODO: Blocking when name is null ?
  52. this.$emit("add-folder", {
  53. name: this.name,
  54. path: this.folderPath || `${this.collectionIndex}`,
  55. })
  56. this.hideModal()
  57. },
  58. hideModal() {
  59. this.name = null
  60. this.$emit("hide-modal")
  61. },
  62. },
  63. })
  64. </script>