api-client/components/collections/Add.vue

56 lines
1.2 KiB
Vue
Raw Normal View History

2019-10-01 22:20:23 +00:00
<template>
<SmartModal v-if="show" :title="$t('collection.new')" @close="hideModal">
<template #body>
2021-07-17 17:40:28 +00:00
<div class="flex flex-col px-2">
2021-07-09 17:19:45 +00:00
<input
id="selectLabelAdd"
v-model="name"
v-focus
2021-08-07 09:21:13 +00:00
class="input floating-input"
placeholder=" "
2021-07-09 17:19:45 +00:00
type="text"
@keyup.enter="addNewCollection"
/>
2021-08-07 09:21:13 +00:00
<label for="selectLabelAdd">
{{ $t("label") }}
</label>
2021-07-09 17:19:45 +00:00
</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>
</SmartModal>
2019-10-01 22:20:23 +00:00
</template>
<script>
2019-11-02 05:32:21 +00:00
export default {
props: {
2020-02-24 18:44:50 +00:00
show: Boolean,
2019-11-02 05:32:21 +00:00
},
data() {
return {
name: null,
2020-02-24 18:44:50 +00:00
}
2019-11-02 05:32:21 +00:00
},
methods: {
addNewCollection() {
2021-08-08 06:31:36 +00:00
if (!this.name) {
this.$toast.info(this.$t("collection.invalid_name"), {
icon: "info",
})
2021-08-08 06:31:36 +00:00
return
}
this.$emit("submit", this.name)
this.hideModal()
2019-10-01 22:20:23 +00:00
},
2019-11-02 05:32:21 +00:00
hideModal() {
this.name = null
this.$emit("hide-modal")
2020-02-24 18:44:50 +00:00
},
},
}
2019-10-22 12:02:26 +00:00
</script>