properly fill pair input

This commit is contained in:
Tako 2022-11-25 07:52:24 +00:00
parent a5239f9cdc
commit 68d072e7fa
2 changed files with 24 additions and 10 deletions

View File

@ -63,7 +63,7 @@ forceexit
>
<PlayIcon />
</button>
<ForceEntryForm @close="hideForceenter" />
<ForceEntryForm :pair="botStore.activeBot.selectedPair" @close="hideForceenter" />
</div>
</template>

View File

@ -29,11 +29,16 @@
<b-form-group label="Pair" label-for="pair-input" invalid-feedback="Pair is required">
<b-form-input
id="pair-input"
v-model="pair"
v-model="selectedPair"
list="pair-input-whitelist"
required
:placeholder="botStore.activeBot.selectedPair"
@keydown.enter.native="handleEntry"
@focus="inputSelect"
></b-form-input>
<b-form-datalist
id="pair-input-whitelist"
:options="botStore.activeBot.whitelist"
></b-form-datalist>
</b-form-group>
<b-form-group
label="*Price [optional]"
@ -106,12 +111,18 @@ import { defineComponent, ref, nextTick, getCurrentInstance } from 'vue';
export default defineComponent({
name: 'ForceEntryForm',
setup() {
props: {
pair: {
type: String,
default: '',
},
},
setup(props) {
const root = getCurrentInstance();
const botStore = useBotStore();
const form = ref<HTMLFormElement>();
const pair = ref('');
const selectedPair = ref('');
const price = ref<number | null>(null);
const stakeAmount = ref<number | null>(null);
const leverage = ref<number | null>(null);
@ -126,15 +137,13 @@ export default defineComponent({
};
const handleSubmit = async () => {
pair.value = pair.value !== '' ? pair.value : botStore.activeBot.selectedPair;
await nextTick();
// Exit when the form isn't valid
if (!checkFormValidity()) {
return;
}
// call forceentry
const payload: ForceEnterPayload = { pair: pair.value };
const payload: ForceEnterPayload = { pair: selectedPair.value };
if (price.value) {
payload.price = Number(price.value);
}
@ -157,7 +166,7 @@ export default defineComponent({
};
const resetForm = () => {
console.log('resetForm');
pair.value = '';
selectedPair.value = props.pair;
price.value = null;
stakeAmount.value = null;
if (botStore.activeBot.botApiVersion > 1.1) {
@ -176,13 +185,18 @@ export default defineComponent({
// Trigger submit handler
handleSubmit();
};
const inputSelect = (bvModalEvt) => {
bvModalEvt.srcElement?.select();
};
return {
handleSubmit,
botStore,
form,
handleEntry,
inputSelect,
resetForm,
pair,
selectedPair,
price,
stakeAmount,
ordertype,