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

64 lines
1.5 KiB
Vue
Raw Normal View History

2021-03-18 14:55:12 +00:00
<template>
2021-05-18 16:09:55 +00:00
<SmartModal v-if="show" @close="$emit('hide-modal')">
<template #header>
<h3 class="heading">{{ $t("new_folder") }}</h3>
<div>
2021-07-03 13:14:58 +00:00
<ButtonSecondary icon="close" @click.native="hideModal" />
2021-03-18 14:55:12 +00:00
</div>
</template>
<template #body>
2021-07-17 17:40:28 +00:00
<div class="flex flex-col px-2">
<label for="selectLabelGqlAddFolder" class="font-semibold px-4 pb-4">
2021-07-09 17:19:45 +00:00
{{ $t("label") }}
</label>
<input
id="selectLabelGqlAddFolder"
v-model="name"
class="input"
type="text"
:placeholder="$t('my_new_folder')"
@keyup.enter="addFolder"
/>
</div>
</template>
<template #footer>
<span>
2021-07-03 13:14:58 +00:00
<ButtonPrimary :label="$t('save')" @click.native="addFolder" />
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"
export default Vue.extend({
2021-03-18 14:55:12 +00:00
props: {
show: Boolean,
2021-05-18 16:09:55 +00:00
folderPath: { type: String, default: null },
collectionIndex: { type: Number, default: null },
2021-03-18 14:55:12 +00:00
},
data() {
return {
name: null,
2021-03-18 14:55:12 +00:00
}
},
methods: {
addFolder() {
// TODO: Blocking when name is null ?
2021-03-18 14:55:12 +00:00
this.$emit("add-folder", {
name: this.name,
path: this.folderPath || `${this.collectionIndex}`,
})
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>