mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-16 05:53:06 -04:00
populate trigger price on duplicate or edit offer
This commit is contained in:
parent
9080400e1c
commit
feb37d5027
@ -262,6 +262,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
||||
|
||||
buyerAsTakerWithoutDepositSlider.setSelected(model.dataModel.getBuyerAsTakerWithoutDeposit().get());
|
||||
|
||||
triggerPriceInputTextField.setText(model.triggerPrice.get());
|
||||
extraInfoTextArea.setText(model.dataModel.extraInfo.get());
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.offer.CreateOfferService;
|
||||
import haveno.core.offer.Offer;
|
||||
import haveno.core.offer.OfferUtil;
|
||||
import haveno.core.offer.OpenOffer;
|
||||
import haveno.core.offer.OpenOfferManager;
|
||||
import haveno.core.payment.PaymentAccount;
|
||||
import haveno.core.provider.price.PriceFeedService;
|
||||
@ -89,12 +90,15 @@ class DuplicateOfferDataModel extends MutableOfferDataModel {
|
||||
setPrice(offer.getPrice());
|
||||
setVolume(offer.getVolume());
|
||||
setUseMarketBasedPrice(offer.isUseMarketBasedPrice());
|
||||
setBuyerAsTakerWithoutDeposit(offer.hasBuyerAsTakerWithoutDeposit());
|
||||
setSecurityDepositPct(getSecurityAsPercent(offer));
|
||||
if (offer.isUseMarketBasedPrice()) {
|
||||
setMarketPriceMarginPct(offer.getMarketPriceMarginPct());
|
||||
}
|
||||
setBuyerAsTakerWithoutDeposit(offer.hasBuyerAsTakerWithoutDeposit());
|
||||
setSecurityDepositPct(getSecurityAsPercent(offer));
|
||||
setExtraInfo(offer.getOfferExtraInfo());
|
||||
|
||||
OpenOffer openOffer = openOfferManager.getOpenOffer(offer.getId()).orElse(null);
|
||||
if (openOffer != null) setTriggerPrice(openOffer.getTriggerPrice());
|
||||
}
|
||||
|
||||
private double getSecurityAsPercent(Offer offer) {
|
||||
|
@ -29,6 +29,7 @@ import haveno.core.payment.validation.XmrValidator;
|
||||
import haveno.core.provider.price.PriceFeedService;
|
||||
import haveno.core.user.Preferences;
|
||||
import haveno.core.util.FormattingUtils;
|
||||
import haveno.core.util.PriceUtil;
|
||||
import haveno.core.util.coin.CoinFormatter;
|
||||
import haveno.core.util.validation.AmountValidator4Decimals;
|
||||
import haveno.core.util.validation.AmountValidator8Decimals;
|
||||
@ -76,6 +77,16 @@ class DuplicateOfferViewModel extends MutableOfferViewModel<DuplicateOfferDataMo
|
||||
public void activate() {
|
||||
super.activate();
|
||||
dataModel.populateData(offer);
|
||||
|
||||
long triggerPriceAsLong = dataModel.getTriggerPrice();
|
||||
dataModel.setTriggerPrice(triggerPriceAsLong);
|
||||
if (triggerPriceAsLong > 0) {
|
||||
triggerPrice.set(PriceUtil.formatMarketPrice(triggerPriceAsLong, dataModel.getCurrencyCode()));
|
||||
} else {
|
||||
triggerPrice.set("");
|
||||
}
|
||||
onTriggerPriceTextFieldChanged();
|
||||
|
||||
triggerFocusOutOnAmountFields();
|
||||
onFocusOutPriceAsPercentageTextField(true, false);
|
||||
}
|
||||
|
@ -138,6 +138,7 @@ class EditOfferDataModel extends MutableOfferDataModel {
|
||||
|
||||
allowAmountUpdate = false;
|
||||
|
||||
triggerPrice = openOffer.getTriggerPrice();
|
||||
extraInfo.set(offer.getOfferExtraInfo());
|
||||
}
|
||||
|
||||
@ -166,10 +167,10 @@ class EditOfferDataModel extends MutableOfferDataModel {
|
||||
setPrice(offer.getPrice());
|
||||
setVolume(offer.getVolume());
|
||||
setUseMarketBasedPrice(offer.isUseMarketBasedPrice());
|
||||
setTriggerPrice(openOffer.getTriggerPrice());
|
||||
if (offer.isUseMarketBasedPrice()) {
|
||||
setMarketPriceMarginPct(offer.getMarketPriceMarginPct());
|
||||
}
|
||||
setTriggerPrice(openOffer.getTriggerPrice());
|
||||
setExtraInfo(offer.getOfferExtraInfo());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user