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

66 lines
1.5 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("new_collection") }}</h3>
2021-07-09 17:19:45 +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="selectLabelGqlAdd" class="font-semibold px-4 pb-4">
2021-07-09 17:19:45 +00:00
{{ $t("label") }}
</label>
<input
id="selectLabelGqlAdd"
v-model="name"
class="input"
type="text"
:placeholder="$t('my_new_collection')"
@keyup.enter="addNewCollection"
/>
</div>
</template>
<template #footer>
<span>
2021-07-03 13:14:58 +00:00
<ButtonPrimary :label="$t('save')" @click.native="addNewCollection" />
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 { addGraphqlCollection } 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,
},
data() {
return {
name: null as string | null,
2021-03-18 14:55:12 +00:00
}
},
methods: {
addNewCollection() {
if (!this.name) {
this.$toast.info(this.$t("invalid_collection_name").toString())
2021-03-18 14:55:12 +00:00
return
}
addGraphqlCollection({
name: this.name,
folders: [],
requests: [],
2021-03-18 14:55:12 +00:00
})
this.hideModal()
2021-03-18 14:55:12 +00:00
},
hideModal() {
this.name = null
2021-03-18 14:55:12 +00:00
this.$emit("hide-modal")
},
},
})
2021-03-18 14:55:12 +00:00
</script>