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

71 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>
<div>
<button class="icon button" @click="hideModal">
<i class="material-icons">close</i>
</button>
2021-03-18 14:55:12 +00:00
</div>
</template>
<template #body>
2021-03-18 14:55:12 +00:00
<label for="selectLabel">{{ $t("label") }}</label>
<input
id="selectLabel"
v-model="name"
class="input"
2021-05-18 16:09:55 +00:00
type="text"
2021-03-18 14:55:12 +00:00
:placeholder="$t('my_new_collection')"
@keyup.enter="addNewCollection"
/>
</template>
<template #footer>
<span></span>
<span>
<button class="icon button" @click="hideModal">
{{ $t("cancel") }}
</button>
<button class="icon button primary" @click="addNewCollection">
{{ $t("save") }}
</button>
</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>