api-client/components/collections/graphql/EditRequest.vue

67 lines
1.7 KiB
Vue
Raw Normal View History

2021-03-18 14:55:12 +00:00
<template>
<SmartModal v-if="show" @close="hideModal">
<template #header>
<h3 class="heading">{{ $t("edit_request") }}</h3>
2021-08-07 03:37:26 +00:00
<ButtonSecondary icon="close" @click.native="hideModal" />
</template>
<template #body>
2021-07-17 17:40:28 +00:00
<div class="flex flex-col px-2">
<label for="selectLabelGqlEditReq" class="font-semibold px-4 pb-4">
2021-07-09 17:19:45 +00:00
{{ $t("label") }}
</label>
<input
id="selectLabelGqlEditReq"
v-model="requestUpdateData.name"
class="input"
type="text"
:placeholder="request.name"
@keyup.enter="saveRequest"
/>
</div>
</template>
<template #footer>
<span>
2021-07-03 13:14:58 +00:00
<ButtonPrimary :label="$t('save')" @click.native="saveRequest" />
2021-07-09 17:19:45 +00:00
<ButtonSecondary :label="$t('cancel')" @click.native="hideModal" />
</span>
</template>
2021-03-18 14:55:12 +00:00
</SmartModal>
</template>
<script lang="ts">
import Vue from "vue"
import { editGraphqlRequest } from "~/newstore/collections"
2021-03-18 14:55:12 +00:00
export default Vue.extend({
2021-03-18 14:55:12 +00:00
props: {
show: Boolean,
folderPath: { type: String, default: null },
2021-05-18 16:09:55 +00:00
request: { type: Object, default: () => {} },
requestIndex: { type: Number, default: null },
2021-03-18 14:55:12 +00:00
},
data() {
return {
requestUpdateData: {
name: null as any | null,
2021-03-18 14:55:12 +00:00
},
}
},
methods: {
saveRequest() {
const requestUpdated = {
...this.$props.request,
name: this.$data.requestUpdateData.name || this.$props.request.name,
}
editGraphqlRequest(this.folderPath, this.requestIndex, requestUpdated)
this.hideModal()
2021-03-18 14:55:12 +00:00
},
hideModal() {
this.requestUpdateData = { name: null }
2021-03-18 14:55:12 +00:00
this.$emit("hide-modal")
},
},
})
2021-03-18 14:55:12 +00:00
</script>