EditFolder.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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="selectLabelEditFolder"
  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="selectLabelEditFolder">
  21. {{ $t("action.label") }}
  22. </label>
  23. </div>
  24. </template>
  25. <template #footer>
  26. <span>
  27. <ButtonPrimary
  28. :label="$t('action.save')"
  29. :loading="loadingState"
  30. @click.native="editFolder"
  31. />
  32. <ButtonSecondary
  33. :label="$t('action.cancel')"
  34. @click.native="hideModal"
  35. />
  36. </span>
  37. </template>
  38. </SmartModal>
  39. </template>
  40. <script>
  41. import { defineComponent } from "@nuxtjs/composition-api"
  42. export default defineComponent({
  43. props: {
  44. show: Boolean,
  45. editingFolderName: { type: String, default: null },
  46. loadingState: Boolean,
  47. },
  48. data() {
  49. return {
  50. name: null,
  51. }
  52. },
  53. watch: {
  54. editingFolderName(val) {
  55. this.name = val
  56. },
  57. },
  58. methods: {
  59. editFolder() {
  60. if (!this.name) {
  61. this.$toast.error(this.$t("folder.invalid_name"))
  62. return
  63. }
  64. this.$emit("submit", this.name)
  65. },
  66. hideModal() {
  67. this.name = null
  68. this.$emit("hide-modal")
  69. },
  70. },
  71. })
  72. </script>