mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-06 21:13:59 -04:00
populate trigger price and extra info on duplicate or edit offer
This commit is contained in:
parent
9bd4f70d02
commit
9668dd2369
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -501,7 +501,10 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
||||
};
|
||||
|
||||
extraInfoStringListener = (ov, oldValue, newValue) -> {
|
||||
onExtraInfoTextAreaChanged();
|
||||
if (newValue != null) {
|
||||
extraInfo.set(newValue);
|
||||
onExtraInfoTextAreaChanged();
|
||||
}
|
||||
};
|
||||
|
||||
isWalletFundedListener = (ov, oldValue, newValue) -> updateButtonDisableState();
|
||||
@ -582,6 +585,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
||||
dataModel.getVolume().removeListener(volumeListener);
|
||||
dataModel.getSecurityDepositPct().removeListener(securityDepositAsDoubleListener);
|
||||
dataModel.getBuyerAsTakerWithoutDeposit().removeListener(buyerAsTakerWithoutDepositListener);
|
||||
dataModel.getExtraInfo().removeListener(extraInfoStringListener);
|
||||
|
||||
//dataModel.feeFromFundingTxProperty.removeListener(feeFromFundingTxListener);
|
||||
dataModel.getIsXmrWalletFunded().removeListener(isWalletFundedListener);
|
||||
@ -843,7 +847,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
||||
extraInfoValidationResult.set(getExtraInfoValidationResult());
|
||||
updateButtonDisableState();
|
||||
if (extraInfoValidationResult.get().isValid) {
|
||||
dataModel.setExtraInfo(extraInfo.get());
|
||||
setExtraInfoToModel();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,13 +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);
|
||||
}
|
||||
|
@ -137,6 +137,9 @@ class EditOfferDataModel extends MutableOfferDataModel {
|
||||
securityDepositPct.set(securityDepositPercent);
|
||||
|
||||
allowAmountUpdate = false;
|
||||
|
||||
triggerPrice = openOffer.getTriggerPrice();
|
||||
extraInfo.set(offer.getOfferExtraInfo());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -164,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