EditRequest.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 :label="$t('action.save')" @click.native="saveRequest" />
  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. editingRequestName: { type: String, default: null },
  42. },
  43. data() {
  44. return {
  45. requestUpdateData: {
  46. name: null,
  47. },
  48. }
  49. },
  50. watch: {
  51. editingRequestName(val) {
  52. this.requestUpdateData.name = val
  53. },
  54. },
  55. methods: {
  56. saveRequest() {
  57. if (!this.requestUpdateData.name) {
  58. this.$toast.error(this.$t("request.invalid_name"))
  59. return
  60. }
  61. this.$emit("submit", this.requestUpdateData)
  62. this.hideModal()
  63. },
  64. hideModal() {
  65. this.requestUpdateData = { name: null }
  66. this.$emit("hide-modal")
  67. },
  68. },
  69. })
  70. </script>