remove min amount warning -> change amounts it not valid. only update price if perc. price is input source

This commit is contained in:
Manfred Karrer 2016-04-14 22:57:21 +02:00
parent c43575073d
commit 7fe4d37501

View file

@ -116,6 +116,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
private Offer offer; private Offer offer;
private Timer timeoutTimer; private Timer timeoutTimer;
private PriceFeed.Type priceFeedType; private PriceFeed.Type priceFeedType;
private boolean priceAsPercentageIsInput;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -256,6 +257,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
updateButtonDisableState(); updateButtonDisableState();
}; };
priceAsPercentageListener = (ov, oldValue, newValue) -> { priceAsPercentageListener = (ov, oldValue, newValue) -> {
if (priceAsPercentageIsInput) {
try { try {
if (!newValue.isEmpty() && !newValue.equals("-")) { if (!newValue.isEmpty() && !newValue.equals("-")) {
double percentageBasedPrice = formatter.parsePercentStringToDouble(newValue); double percentageBasedPrice = formatter.parsePercentStringToDouble(newValue);
@ -291,6 +293,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
new Popup().warning("Your input is not a valid number. Please enter a percentage number like \"5.4\" for 5.4%") new Popup().warning("Your input is not a valid number. Please enter a percentage number like \"5.4\" for 5.4%")
.show(); .show();
} }
}
}; };
volumeListener = (ov, oldValue, newValue) -> { volumeListener = (ov, oldValue, newValue) -> {
if (isFiatInputValid(newValue).isValid) { if (isFiatInputValid(newValue).isValid) {
@ -475,8 +478,9 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
// handle minAmount/amount relationship // handle minAmount/amount relationship
if (!dataModel.isMinAmountLessOrEqualAmount()) { if (!dataModel.isMinAmountLessOrEqualAmount()) {
amountValidationResult.set(new InputValidator.ValidationResult(false, minAmount.set(amount.get());
BSResources.get("createOffer.validation.amountSmallerThanMinAmount"))); /*amountValidationResult.set(new InputValidator.ValidationResult(false,
BSResources.get("createOffer.validation.amountSmallerThanMinAmount")));*/
} else { } else {
amountValidationResult.set(result); amountValidationResult.set(result);
if (minAmount.get() != null) if (minAmount.get() != null)
@ -496,8 +500,9 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
minAmount.set(formatter.formatCoin(dataModel.minAmountAsCoin.get())); minAmount.set(formatter.formatCoin(dataModel.minAmountAsCoin.get()));
if (!dataModel.isMinAmountLessOrEqualAmount()) { if (!dataModel.isMinAmountLessOrEqualAmount()) {
minAmountValidationResult.set(new InputValidator.ValidationResult(false, amount.set(minAmount.get());
BSResources.get("createOffer.validation.minAmountLargerThanAmount"))); /* minAmountValidationResult.set(new InputValidator.ValidationResult(false,
BSResources.get("createOffer.validation.minAmountLargerThanAmount")));*/
} else { } else {
minAmountValidationResult.set(result); minAmountValidationResult.set(result);
if (amount.get() != null) if (amount.get() != null)
@ -523,10 +528,10 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
} }
void onFocusOutPriceAsPercentageTextField(boolean oldValue, boolean newValue, String userInput) { void onFocusOutPriceAsPercentageTextField(boolean oldValue, boolean newValue, String userInput) {
if (oldValue && !newValue) { priceAsPercentageIsInput = !oldValue && newValue;
if (oldValue && !newValue)
priceAsPercentage.set(formatter.formatToNumberString(dataModel.getPercentageBasedPrice() * 100, 2)); priceAsPercentage.set(formatter.formatToNumberString(dataModel.getPercentageBasedPrice() * 100, 2));
} }
}
void onFocusOutVolumeTextField(boolean oldValue, boolean newValue, String userInput) { void onFocusOutVolumeTextField(boolean oldValue, boolean newValue, String userInput) {
if (oldValue && !newValue) { if (oldValue && !newValue) {