frequi_origin/src/components/BotRename.vue

47 lines
1.1 KiB
Vue
Raw Normal View History

2022-03-10 07:57:06 +00:00
<template>
<form class="d-flex" @submit.prevent="save">
<b-form-input
v-model="newName"
size="sm"
class="w-100"
placeholder="Bot name"
style="border-style: solid; border-width: 1px"
autofocus
/>
2024-01-31 17:14:55 +00:00
<div class="d-flex ms-2 no-min-w">
<b-button type="submit" size="sm" title="Save" class="no-min-w">
2023-05-09 16:16:58 +00:00
<i-mdi-check />
2022-03-10 07:57:06 +00:00
</b-button>
2024-01-31 17:14:55 +00:00
<b-button class="ms-1 no-min-w" size="sm" title="Cancel" @click="$emit('cancelled')">
2023-05-09 16:16:58 +00:00
<i-mdi-close />
2022-03-10 07:57:06 +00:00
</b-button>
</div>
</form>
</template>
2023-05-09 16:17:34 +00:00
<script setup lang="ts">
import { useBotStore } from '@/stores/ftbotwrapper';
2022-04-15 17:35:14 +00:00
import { BotDescriptor } from '@/types';
2022-03-10 07:57:06 +00:00
2023-05-09 16:17:34 +00:00
const props = defineProps({
bot: { type: Object as () => BotDescriptor, required: true },
});
const emit = defineEmits(['cancelled', 'saved']);
const botStore = useBotStore();
2023-08-02 05:14:40 +00:00
const newName = ref<string>('');
2022-04-18 11:21:53 +00:00
2023-08-02 05:14:40 +00:00
onMounted(() => {
newName.value = props.bot.botName;
});
2022-04-15 17:35:14 +00:00
2023-05-09 16:17:34 +00:00
const save = () => {
botStore.updateBot(props.bot.botId, {
botName: newName.value,
});
2022-04-15 17:35:14 +00:00
2023-05-09 16:17:34 +00:00
emit('saved');
};
2022-03-10 07:57:06 +00:00
</script>