populate trigger price and extra info on duplicate or edit offer

This commit is contained in:
woodser 2025-04-04 13:55:25 -04:00 committed by GitHub
parent 9bd4f70d02
commit 9668dd2369
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 29 additions and 7 deletions

View file

@ -262,6 +262,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
buyerAsTakerWithoutDepositSlider.setSelected(model.dataModel.getBuyerAsTakerWithoutDeposit().get()); buyerAsTakerWithoutDepositSlider.setSelected(model.dataModel.getBuyerAsTakerWithoutDeposit().get());
triggerPriceInputTextField.setText(model.triggerPrice.get());
extraInfoTextArea.setText(model.dataModel.extraInfo.get()); extraInfoTextArea.setText(model.dataModel.extraInfo.get());
} }
} }

View file

@ -501,7 +501,10 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
}; };
extraInfoStringListener = (ov, oldValue, newValue) -> { extraInfoStringListener = (ov, oldValue, newValue) -> {
if (newValue != null) {
extraInfo.set(newValue);
onExtraInfoTextAreaChanged(); onExtraInfoTextAreaChanged();
}
}; };
isWalletFundedListener = (ov, oldValue, newValue) -> updateButtonDisableState(); isWalletFundedListener = (ov, oldValue, newValue) -> updateButtonDisableState();
@ -582,6 +585,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
dataModel.getVolume().removeListener(volumeListener); dataModel.getVolume().removeListener(volumeListener);
dataModel.getSecurityDepositPct().removeListener(securityDepositAsDoubleListener); dataModel.getSecurityDepositPct().removeListener(securityDepositAsDoubleListener);
dataModel.getBuyerAsTakerWithoutDeposit().removeListener(buyerAsTakerWithoutDepositListener); dataModel.getBuyerAsTakerWithoutDeposit().removeListener(buyerAsTakerWithoutDepositListener);
dataModel.getExtraInfo().removeListener(extraInfoStringListener);
//dataModel.feeFromFundingTxProperty.removeListener(feeFromFundingTxListener); //dataModel.feeFromFundingTxProperty.removeListener(feeFromFundingTxListener);
dataModel.getIsXmrWalletFunded().removeListener(isWalletFundedListener); dataModel.getIsXmrWalletFunded().removeListener(isWalletFundedListener);
@ -843,7 +847,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
extraInfoValidationResult.set(getExtraInfoValidationResult()); extraInfoValidationResult.set(getExtraInfoValidationResult());
updateButtonDisableState(); updateButtonDisableState();
if (extraInfoValidationResult.get().isValid) { if (extraInfoValidationResult.get().isValid) {
dataModel.setExtraInfo(extraInfo.get()); setExtraInfoToModel();
} }
} }

View file

@ -26,6 +26,7 @@ import haveno.core.locale.TradeCurrency;
import haveno.core.offer.CreateOfferService; import haveno.core.offer.CreateOfferService;
import haveno.core.offer.Offer; import haveno.core.offer.Offer;
import haveno.core.offer.OfferUtil; import haveno.core.offer.OfferUtil;
import haveno.core.offer.OpenOffer;
import haveno.core.offer.OpenOfferManager; import haveno.core.offer.OpenOfferManager;
import haveno.core.payment.PaymentAccount; import haveno.core.payment.PaymentAccount;
import haveno.core.provider.price.PriceFeedService; import haveno.core.provider.price.PriceFeedService;
@ -89,13 +90,15 @@ class DuplicateOfferDataModel extends MutableOfferDataModel {
setPrice(offer.getPrice()); setPrice(offer.getPrice());
setVolume(offer.getVolume()); setVolume(offer.getVolume());
setUseMarketBasedPrice(offer.isUseMarketBasedPrice()); setUseMarketBasedPrice(offer.isUseMarketBasedPrice());
setBuyerAsTakerWithoutDeposit(offer.hasBuyerAsTakerWithoutDeposit());
setSecurityDepositPct(getSecurityAsPercent(offer));
if (offer.isUseMarketBasedPrice()) { if (offer.isUseMarketBasedPrice()) {
setMarketPriceMarginPct(offer.getMarketPriceMarginPct()); 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) { private double getSecurityAsPercent(Offer offer) {

View file

@ -29,6 +29,7 @@ import haveno.core.payment.validation.XmrValidator;
import haveno.core.provider.price.PriceFeedService; import haveno.core.provider.price.PriceFeedService;
import haveno.core.user.Preferences; import haveno.core.user.Preferences;
import haveno.core.util.FormattingUtils; import haveno.core.util.FormattingUtils;
import haveno.core.util.PriceUtil;
import haveno.core.util.coin.CoinFormatter; import haveno.core.util.coin.CoinFormatter;
import haveno.core.util.validation.AmountValidator4Decimals; import haveno.core.util.validation.AmountValidator4Decimals;
import haveno.core.util.validation.AmountValidator8Decimals; import haveno.core.util.validation.AmountValidator8Decimals;
@ -76,6 +77,16 @@ class DuplicateOfferViewModel extends MutableOfferViewModel<DuplicateOfferDataMo
public void activate() { public void activate() {
super.activate(); super.activate();
dataModel.populateData(offer); 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(); triggerFocusOutOnAmountFields();
onFocusOutPriceAsPercentageTextField(true, false); onFocusOutPriceAsPercentageTextField(true, false);
} }

View file

@ -137,6 +137,9 @@ class EditOfferDataModel extends MutableOfferDataModel {
securityDepositPct.set(securityDepositPercent); securityDepositPct.set(securityDepositPercent);
allowAmountUpdate = false; allowAmountUpdate = false;
triggerPrice = openOffer.getTriggerPrice();
extraInfo.set(offer.getOfferExtraInfo());
} }
@Override @Override
@ -164,10 +167,10 @@ class EditOfferDataModel extends MutableOfferDataModel {
setPrice(offer.getPrice()); setPrice(offer.getPrice());
setVolume(offer.getVolume()); setVolume(offer.getVolume());
setUseMarketBasedPrice(offer.isUseMarketBasedPrice()); setUseMarketBasedPrice(offer.isUseMarketBasedPrice());
setTriggerPrice(openOffer.getTriggerPrice());
if (offer.isUseMarketBasedPrice()) { if (offer.isUseMarketBasedPrice()) {
setMarketPriceMarginPct(offer.getMarketPriceMarginPct()); setMarketPriceMarginPct(offer.getMarketPriceMarginPct());
} }
setTriggerPrice(openOffer.getTriggerPrice());
setExtraInfo(offer.getOfferExtraInfo()); setExtraInfo(offer.getOfferExtraInfo());
} }