composition: BotList

This commit is contained in:
Matthias 2022-04-15 19:35:14 +02:00
parent 090cc3ec5e
commit 80f01ed91a

View File

@ -22,36 +22,39 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { namespace } from 'vuex-class';
import CheckIcon from 'vue-material-design-icons/Check.vue'; import CheckIcon from 'vue-material-design-icons/Check.vue';
import CloseIcon from 'vue-material-design-icons/Close.vue'; import CloseIcon from 'vue-material-design-icons/Close.vue';
import { BotDescriptor, RenameBotPayload } from '@/types'; import { BotDescriptor } from '@/types';
import StoreModules from '@/store/storeSubModules'; import StoreModules from '@/store/storeSubModules';
import { defineComponent, ref } from '@vue/composition-api';
import { useNamespacedActions } from 'vuex-composition-helpers';
const ftbot = namespace(StoreModules.ftbot); export default defineComponent({
name: 'BotRename',
@Component({
components: { components: {
CheckIcon, CheckIcon,
CloseIcon, CloseIcon,
}, },
}) props: {
export default class BotList extends Vue { bot: { type: Object as () => BotDescriptor, required: true },
@Prop({ required: true, type: Object }) bot!: BotDescriptor; },
emits: ['saved'],
setup(props, { emit }) {
const { renameBot } = useNamespacedActions(StoreModules.ftbot, ['renameBot']);
const newName = ref<string>(props.bot.botName);
// eslint-disable-next-line @typescript-eslint/no-unused-vars const save = () => {
@ftbot.Action renameBot!: (payload: RenameBotPayload) => Promise<void>; renameBot({
botId: props.bot.botId,
botName: newName.value,
});
newName: string = this.bot.botName; emit('saved');
};
save() { return {
this.renameBot({ newName,
botId: this.bot.botId, save,
botName: this.newName, };
}); },
});
this.$emit('saved');
}
}
</script> </script>