EditFolder.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 :label="$t('action.save')" @click.native="editFolder" />
  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. import { editGraphqlFolder } from "~/newstore/collections"
  38. export default defineComponent({
  39. props: {
  40. show: Boolean,
  41. folder: { type: Object, default: () => {} },
  42. folderPath: { type: String, default: null },
  43. },
  44. data() {
  45. return {
  46. name: "",
  47. }
  48. },
  49. methods: {
  50. editFolder() {
  51. if (!this.name) {
  52. this.$toast.error(this.$t("collection.invalid_name").toString(), {
  53. icon: "error_outline",
  54. })
  55. return
  56. }
  57. editGraphqlFolder(this.folderPath, {
  58. ...(this.folder as any),
  59. name: this.name,
  60. })
  61. this.hideModal()
  62. },
  63. hideModal() {
  64. this.name = ""
  65. this.$emit("hide-modal")
  66. },
  67. },
  68. })
  69. </script>