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 /> <PlayIcon />
</button> </button>
<ForceEntryForm @close="hideForceenter" /> <ForceEntryForm :pair="botStore.activeBot.selectedPair" @close="hideForceenter" />
</div> </div>
</template> </template>

View File

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