Botentry -> script setup

This commit is contained in:
Matthias 2023-05-06 15:33:29 +02:00
parent 60620a8103
commit f9ea16973c

View File

@ -54,59 +54,39 @@
</div> </div>
</template> </template>
<script lang="ts"> <script setup lang="ts">
import EditIcon from 'vue-material-design-icons/Pencil.vue'; import EditIcon from 'vue-material-design-icons/Pencil.vue';
import LoginIcon from 'vue-material-design-icons/Login.vue'; import LoginIcon from 'vue-material-design-icons/Login.vue';
import DeleteIcon from 'vue-material-design-icons/Delete.vue'; import DeleteIcon from 'vue-material-design-icons/Delete.vue';
import OnlineIcon from 'vue-material-design-icons/Circle.vue'; import OnlineIcon from 'vue-material-design-icons/Circle.vue';
import LoggedOutIcon from 'vue-material-design-icons/Cancel.vue'; import LoggedOutIcon from 'vue-material-design-icons/Cancel.vue';
import { BotDescriptor } from '@/types'; import { BotDescriptor } from '@/types';
import { defineComponent, computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { useBotStore } from '@/stores/ftbotwrapper'; import { useBotStore } from '@/stores/ftbotwrapper';
export default defineComponent({ const props = defineProps({
name: 'BotEntry', bot: { required: true, type: Object as () => BotDescriptor },
components: { noButtons: { default: false, type: Boolean },
DeleteIcon, });
EditIcon, defineEmits(['edit', 'editLogin']);
LoginIcon, const botStore = useBotStore();
OnlineIcon,
LoggedOutIcon, const changeEvent = (v) => {
botStore.botStores[props.bot.botId].setAutoRefresh(v);
};
const botRemoveModalVisible = ref(false);
const confirmRemoveBot = () => {
botRemoveModalVisible.value = false;
botStore.removeBot(props.bot.botId);
console.log('removing bot.');
};
const autoRefreshLoc = computed({
get() {
return botStore.botStores[props.bot.botId].autoRefresh;
}, },
props: { set() {
bot: { required: true, type: Object as () => BotDescriptor }, // pass
noButtons: { default: false, type: Boolean },
},
emits: ['edit', 'editLogin'],
setup(props) {
const botStore = useBotStore();
const changeEvent = (v) => {
botStore.botStores[props.bot.botId].setAutoRefresh(v);
};
const botRemoveModalVisible = ref(false);
const confirmRemoveBot = () => {
botRemoveModalVisible.value = false;
botStore.removeBot(props.bot.botId);
console.log('removing bot.');
};
const autoRefreshLoc = computed({
get() {
return botStore.botStores[props.bot.botId].autoRefresh;
},
set() {
// pass
},
});
return {
botStore,
changeEvent,
autoRefreshLoc,
confirmRemoveBot,
botRemoveModalVisible,
};
}, },
}); });
</script> </script>