EditFolder.vue 1.7 KB

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