2021-05-23 14:54:38 +00:00
|
|
|
<template>
|
2021-05-23 15:06:04 +00:00
|
|
|
<b-form-select
|
|
|
|
v-model="selectedTimeframe"
|
|
|
|
placeholder="Use strategy default"
|
|
|
|
:options="availableTimeframes"
|
|
|
|
@change="emitSelectedTimeframe"
|
|
|
|
></b-form-select>
|
2021-05-23 14:54:38 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2022-07-07 18:44:19 +00:00
|
|
|
import { defineComponent, computed, ref } from 'vue';
|
2021-05-23 14:54:38 +00:00
|
|
|
|
2022-04-20 05:11:23 +00:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'TimefameSelect',
|
|
|
|
props: {
|
|
|
|
value: { default: '', type: String },
|
|
|
|
belowTimeframe: { required: false, default: '', type: String },
|
|
|
|
},
|
|
|
|
emits: ['input'],
|
|
|
|
setup(props, { emit }) {
|
|
|
|
const selectedTimeframe = ref('');
|
|
|
|
// The below list must always remain sorted correctly!
|
|
|
|
const availableTimeframesBase = [
|
|
|
|
// Placeholder value
|
|
|
|
{ value: '', text: 'Use strategy default' },
|
|
|
|
'1m',
|
|
|
|
'3m',
|
|
|
|
'5m',
|
|
|
|
'15m',
|
|
|
|
'30m',
|
|
|
|
'1h',
|
|
|
|
'2h',
|
|
|
|
'4h',
|
|
|
|
'6h',
|
|
|
|
'8h',
|
|
|
|
'12h',
|
|
|
|
'1d',
|
|
|
|
'3d',
|
|
|
|
'1w',
|
|
|
|
'2w',
|
|
|
|
'1M',
|
|
|
|
'1y',
|
|
|
|
];
|
2021-05-23 14:54:38 +00:00
|
|
|
|
2022-04-20 05:11:23 +00:00
|
|
|
const availableTimeframes = computed(() => {
|
|
|
|
if (!props.belowTimeframe) {
|
|
|
|
return availableTimeframesBase;
|
|
|
|
}
|
|
|
|
const idx = availableTimeframesBase.findIndex((v) => v === props.belowTimeframe);
|
2021-05-23 14:54:38 +00:00
|
|
|
|
2022-04-20 05:11:23 +00:00
|
|
|
return [...availableTimeframesBase].splice(0, idx);
|
|
|
|
});
|
2021-08-14 18:18:06 +00:00
|
|
|
|
2022-04-20 05:11:23 +00:00
|
|
|
const emitSelectedTimeframe = () => {
|
|
|
|
emit('input', selectedTimeframe.value);
|
|
|
|
};
|
2021-05-23 14:54:38 +00:00
|
|
|
|
2022-04-20 05:11:23 +00:00
|
|
|
return {
|
|
|
|
availableTimeframesBase,
|
|
|
|
availableTimeframes,
|
|
|
|
emitSelectedTimeframe,
|
|
|
|
selectedTimeframe,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
2021-05-23 14:54:38 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|