Files
hoppscotch/components/collections/graphql/AddFolder.vue

63 lines
1.3 KiB
Vue

<template>
<SmartModal
v-if="show"
:title="$t('folder.new')"
@close="$emit('hide-modal')"
>
<template #body>
<div class="flex flex-col px-2">
<input
id="selectLabelGqlAddFolder"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"
@keyup.enter="addFolder"
/>
<label for="selectLabelGqlAddFolder">
{{ $t("label") }}
</label>
</div>
</template>
<template #footer>
<span>
<ButtonPrimary :label="$t('save')" @click.native="addFolder" />
<ButtonSecondary :label="$t('cancel')" @click.native="hideModal" />
</span>
</template>
</SmartModal>
</template>
<script lang="ts">
import Vue from "vue"
export default Vue.extend({
props: {
show: Boolean,
folderPath: { type: String, default: null },
collectionIndex: { type: Number, default: null },
},
data() {
return {
name: null,
}
},
methods: {
addFolder() {
// TODO: Blocking when name is null ?
this.$emit("add-folder", {
name: this.name,
path: this.folderPath || `${this.collectionIndex}`,
})
this.hideModal()
},
hideModal() {
this.name = null
this.$emit("hide-modal")
},
},
})
</script>