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

71 lines
1.6 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')">
2021-03-18 14:55:12 +00:00
<div slot="header">
<div class="row-wrapper">
<h3 class="heading">{{ $t("new_folder") }}</h3>
2021-03-18 14:55:12 +00:00
<div>
<button class="icon button" @click="hideModal">
2021-03-18 14:55:12 +00:00
<i class="material-icons">close</i>
</button>
</div>
</div>
</div>
<div slot="body" class="flex flex-col">
<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_folder')"
@keyup.enter="addFolder"
/>
</div>
<div slot="footer">
<div class="row-wrapper">
<span></span>
<span>
<button class="icon button" @click="hideModal">
2021-03-18 14:55:12 +00:00
{{ $t("cancel") }}
</button>
<button class="icon button primary" @click="addFolder">
2021-03-18 14:55:12 +00:00
{{ $t("save") }}
</button>
</span>
</div>
</div>
</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>