EditRequest.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <SmartModal v-if="show" :title="$t('modal.edit_request')" @close="hideModal">
  3. <template #body>
  4. <div class="flex flex-col px-2">
  5. <input
  6. id="selectLabelEditReq"
  7. v-model="requestUpdateData.name"
  8. v-focus
  9. class="input floating-input"
  10. placeholder=" "
  11. type="text"
  12. autocomplete="off"
  13. @keyup.enter="saveRequest"
  14. />
  15. <label for="selectLabelEditReq">
  16. {{ $t("action.label") }}
  17. </label>
  18. </div>
  19. </template>
  20. <template #footer>
  21. <span>
  22. <ButtonPrimary :label="$t('action.save')" @click.native="saveRequest" />
  23. <ButtonSecondary
  24. :label="$t('action.cancel')"
  25. @click.native="hideModal"
  26. />
  27. </span>
  28. </template>
  29. </SmartModal>
  30. </template>
  31. <script>
  32. import { defineComponent } from "@nuxtjs/composition-api"
  33. export default defineComponent({
  34. props: {
  35. show: Boolean,
  36. editingRequestName: { type: String, default: null },
  37. },
  38. data() {
  39. return {
  40. requestUpdateData: {
  41. name: null,
  42. },
  43. }
  44. },
  45. watch: {
  46. editingRequestName(val) {
  47. this.requestUpdateData.name = val
  48. },
  49. },
  50. methods: {
  51. saveRequest() {
  52. if (!this.requestUpdateData.name) {
  53. this.$toast.error(this.$t("request.invalid_name"))
  54. return
  55. }
  56. this.$emit("submit", this.requestUpdateData)
  57. this.hideModal()
  58. },
  59. hideModal() {
  60. this.requestUpdateData = { name: null }
  61. this.$emit("hide-modal")
  62. },
  63. },
  64. })
  65. </script>