EditFolder.vue 1.6 KB

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