api-client/packages/hoppscotch-app/src/components/collections/EditFolder.vue

81 lines
1.7 KiB
Vue
Raw Normal View History

<template>
<SmartModal
v-if="show"
dialog
:title="t('folder.edit')"
@close="$emit('hide-modal')"
>
<template #body>
<div class="flex flex-col">
2021-07-09 17:19:45 +00:00
<input
id="selectLabelEditFolder"
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"
autocomplete="off"
2021-07-09 17:19:45 +00:00
@keyup.enter="editFolder"
/>
2021-08-07 09:21:13 +00:00
<label for="selectLabelEditFolder">
{{ t("action.label") }}
2021-08-07 09:21:13 +00:00
</label>
2021-07-09 17:19:45 +00:00
</div>
</template>
<template #footer>
<span class="flex">
<ButtonPrimary
:label="t('action.save')"
:loading="loadingState"
@click="editFolder"
/>
<ButtonSecondary :label="t('action.cancel')" @click="hideModal" />
</span>
</template>
</SmartModal>
</template>
<script lang="ts">
import { defineComponent } from "vue"
import { useI18n } from "@composables/i18n"
import { useToast } from "@composables/toast"
2021-08-24 03:44:46 +00:00
export default defineComponent({
2019-11-02 05:32:21 +00:00
props: {
show: Boolean,
editingFolderName: { type: String, default: null },
loadingState: Boolean,
2019-11-02 05:32:21 +00:00
},
emits: ["submit", "hide-modal"],
setup() {
return {
t: useI18n(),
toast: useToast(),
}
},
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
},
watch: {
editingFolderName(val) {
this.name = val
},
},
2019-11-02 05:32:21 +00:00
methods: {
editFolder() {
2021-08-08 06:31:36 +00:00
if (!this.name) {
this.toast.error(this.t("folder.invalid_name"))
2021-08-08 06:31:36 +00:00
return
}
this.$emit("submit", this.name)
},
2019-11-02 05:32:21 +00:00
hideModal() {
this.name = null
this.$emit("hide-modal")
2020-02-24 18:44:50 +00:00
},
},
2021-08-24 03:44:46 +00:00
})
</script>