2019-10-24 02:15:55 +00:00
|
|
|
<template>
|
2021-08-08 07:12:29 +00:00
|
|
|
<SmartModal
|
|
|
|
|
v-if="show"
|
2022-03-24 00:24:56 +00:00
|
|
|
dialog
|
2022-09-29 05:25:21 +00:00
|
|
|
:title="t('folder.edit')"
|
2023-01-31 11:45:03 +00:00
|
|
|
@close="emit('hide-modal')"
|
2021-08-08 07:12:29 +00:00
|
|
|
>
|
2021-06-30 08:46:02 +00:00
|
|
|
<template #body>
|
2022-09-29 05:25:21 +00:00
|
|
|
<div class="flex flex-col">
|
2021-07-09 17:19:45 +00:00
|
|
|
<input
|
|
|
|
|
id="selectLabelEditFolder"
|
|
|
|
|
v-model="name"
|
2021-08-08 17:14:05 +00:00
|
|
|
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"
|
2021-08-29 11:14:18 +00:00
|
|
|
autocomplete="off"
|
2021-07-09 17:19:45 +00:00
|
|
|
@keyup.enter="editFolder"
|
|
|
|
|
/>
|
2021-08-07 09:21:13 +00:00
|
|
|
<label for="selectLabelEditFolder">
|
2022-09-29 05:25:21 +00:00
|
|
|
{{ t("action.label") }}
|
2021-08-07 09:21:13 +00:00
|
|
|
</label>
|
2021-07-09 17:19:45 +00:00
|
|
|
</div>
|
2021-06-30 08:46:02 +00:00
|
|
|
</template>
|
|
|
|
|
<template #footer>
|
2022-09-30 04:17:12 +00:00
|
|
|
<span class="flex space-x-2">
|
2022-04-20 18:18:25 +00:00
|
|
|
<ButtonPrimary
|
2022-09-29 05:25:21 +00:00
|
|
|
:label="t('action.save')"
|
2022-04-20 18:18:25 +00:00
|
|
|
:loading="loadingState"
|
2022-09-30 04:17:12 +00:00
|
|
|
outline
|
2022-09-29 05:25:21 +00:00
|
|
|
@click="editFolder"
|
2021-08-18 18:40:57 +00:00
|
|
|
/>
|
2022-09-30 04:17:12 +00:00
|
|
|
<ButtonSecondary
|
|
|
|
|
:label="t('action.cancel')"
|
|
|
|
|
outline
|
|
|
|
|
filled
|
|
|
|
|
@click="hideModal"
|
|
|
|
|
/>
|
2021-06-30 08:46:02 +00:00
|
|
|
</span>
|
|
|
|
|
</template>
|
2021-03-01 03:58:14 +00:00
|
|
|
</SmartModal>
|
2019-10-24 02:15:55 +00:00
|
|
|
</template>
|
|
|
|
|
|
2023-01-31 11:45:03 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ref, watch } from "vue"
|
2022-09-29 05:25:21 +00:00
|
|
|
import { useI18n } from "@composables/i18n"
|
|
|
|
|
import { useToast } from "@composables/toast"
|
2021-08-24 03:44:46 +00:00
|
|
|
|
2023-01-31 11:45:03 +00:00
|
|
|
const t = useI18n()
|
|
|
|
|
const toast = useToast()
|
|
|
|
|
|
|
|
|
|
const props = withDefaults(
|
|
|
|
|
defineProps<{
|
|
|
|
|
show: boolean
|
|
|
|
|
loadingState: boolean
|
|
|
|
|
editingFolderName: string
|
|
|
|
|
}>(),
|
|
|
|
|
{
|
|
|
|
|
show: false,
|
|
|
|
|
loadingState: false,
|
|
|
|
|
editingFolderName: "",
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
(e: "submit", name: string): void
|
|
|
|
|
(e: "hide-modal"): void
|
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
const name = ref("")
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => props.editingFolderName,
|
|
|
|
|
(newName) => {
|
|
|
|
|
name.value = newName
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const editFolder = () => {
|
|
|
|
|
if (name.value.trim() === "") {
|
|
|
|
|
toast.error(t("folder.invalid_name"))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit("submit", name.value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const hideModal = () => {
|
|
|
|
|
name.value = ""
|
|
|
|
|
emit("hide-modal")
|
|
|
|
|
}
|
2019-10-24 02:15:55 +00:00
|
|
|
</script>
|