EditRequest.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <SmartModal
  3. v-if="show"
  4. dialog
  5. :title="$t('modal.edit_request')"
  6. @close="hideModal"
  7. >
  8. <template #body>
  9. <div class="flex flex-col px-2">
  10. <input
  11. id="selectLabelEditReq"
  12. v-model="requestUpdateData.name"
  13. v-focus
  14. class="input floating-input"
  15. placeholder=" "
  16. type="text"
  17. autocomplete="off"
  18. @keyup.enter="saveRequest"
  19. />
  20. <label for="selectLabelEditReq">
  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="saveRequest"
  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. editingRequestName: { type: String, default: null },
  46. loadingState: Boolean,
  47. },
  48. data() {
  49. return {
  50. requestUpdateData: {
  51. name: null,
  52. },
  53. }
  54. },
  55. watch: {
  56. editingRequestName(val) {
  57. this.requestUpdateData.name = val
  58. },
  59. },
  60. methods: {
  61. saveRequest() {
  62. if (!this.requestUpdateData.name) {
  63. this.$toast.error(this.$t("request.invalid_name"))
  64. return
  65. }
  66. this.$emit("submit", this.requestUpdateData)
  67. },
  68. hideModal() {
  69. this.requestUpdateData = { name: null }
  70. this.$emit("hide-modal")
  71. },
  72. },
  73. })
  74. </script>