EditFolder.vue 1.4 KB

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