frequi_origin/src/components/BotRename.vue

60 lines
1.3 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">
<CheckIcon />
2022-03-10 07:57:06 +00:00
</b-button>
<b-button class="ms-1" size="sm" title="Cancel" @click="$emit('cancelled')">
<CloseIcon />
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';
import CheckIcon from '~icons/mdi/check';
import CloseIcon from '~icons/mdi/close';
2022-03-10 07:57:06 +00:00
2022-04-15 17:35:14 +00:00
export default defineComponent({
name: 'BotRename',
2022-03-10 07:57:06 +00:00
components: {
CheckIcon,
CloseIcon,
},
2022-04-15 17:35:14 +00:00
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>