assembly/components/sidebar/context/strategy/SidebarStrategy.vue

67 lines
1.5 KiB
Vue
Raw Normal View History

2021-08-22 12:54:23 +00:00
<template>
<SidebarContextContainer class="h-full overflow-hidden">
<SidebarContextHeader class="xxl:hidden">Strategy</SidebarContextHeader>
<div class="h-full overflow-y-scroll scrollbar-hover">
<div class="mx-auto" style="max-width: 296px">
<div class="py-2 sm:py-4">
<pre>{{ $props }}</pre>
2021-08-22 13:49:31 +00:00
<pre>{{ selectedStrategy }}</pre>
<input
type="text"
v-for="(input, index) in selectedStrategy.inputs"
:key="index"
:value="input.value"
@input="$event => input.onInput($event.target.value)"
/>
2021-08-22 12:54:23 +00:00
</div>
</div>
</div>
</SidebarContextContainer>
</template>
2021-08-22 13:49:31 +00:00
<script lang="ts">
import {
computed,
defineComponent,
watch,
watchEffect,
ref
} from "@nuxtjs/composition-api";
import { useSidebar } from "~/composables/useSidebar";
import { protocolStrategies, DefineStrategy } from "~/core/strategies";
2021-08-22 12:54:23 +00:00
export default defineComponent({
props: {
protocol: {
type: String,
2021-08-22 13:49:31 +00:00
required: true
2021-08-22 12:54:23 +00:00
},
strategy: {
type: String,
2021-08-22 13:49:31 +00:00
required: true
2021-08-22 12:54:23 +00:00
}
},
setup(props) {
const { close } = useSidebar();
2021-08-22 13:49:31 +00:00
const strategies: DefineStrategy[] =
protocolStrategies[props.protocol] || [];
2021-08-22 12:54:23 +00:00
2021-08-22 13:49:31 +00:00
const selectedStrategy = ref(
strategies.find(strategy => strategy.id === props.strategy)
);
2021-08-22 12:54:23 +00:00
2021-08-22 13:49:31 +00:00
watch(() => {
selectedStrategy.value = strategies.find(
strategy => strategy.id === props.strategy
);
});
2021-08-22 12:54:23 +00:00
return {
2021-08-22 13:49:31 +00:00
selectedStrategy
};
}
});
2021-08-22 12:54:23 +00:00
</script>