frequi_origin/src/components/BotRename.vue

54 lines
1.2 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
/>
<div class="d-flex ms-2">
2022-03-10 07:57:06 +00:00
<b-button type="submit" size="sm" title="Save">
2023-05-09 16:16:58 +00:00
<i-mdi-check />
2022-03-10 07:57:06 +00:00
</b-button>
<b-button class="ms-1" 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>
<script lang="ts">
import { useBotStore } from '@/stores/ftbotwrapper';
2022-04-15 17:35:14 +00:00
import { BotDescriptor } from '@/types';
2022-07-07 18:44:19 +00:00
import { defineComponent, ref } from 'vue';
2022-03-10 07:57:06 +00:00
2022-04-15 17:35:14 +00:00
export default defineComponent({
name: 'BotRename',
props: {
bot: { type: Object as () => BotDescriptor, required: true },
},
2022-07-07 18:44:19 +00:00
emits: ['cancelled', 'saved'],
2022-04-15 17:35:14 +00:00
setup(props, { emit }) {
2022-04-18 11:21:53 +00:00
const botStore = useBotStore();
2022-04-15 17:35:14 +00:00
const newName = ref<string>(props.bot.botName);
const save = () => {
2023-04-18 18:20:17 +00:00
botStore.updateBot(props.bot.botId, {
2022-04-15 17:35:14 +00:00
botName: newName.value,
});
emit('saved');
};
return {
newName,
save,
};
},
});
2022-03-10 07:57:06 +00:00
</script>