Edit account names - altcoin forms

This commit is contained in:
xyzmaker123 2022-01-31 13:18:25 +01:00
parent e8ee3fa4c3
commit 702a31f1d6
No known key found for this signature in database
GPG Key ID: 47689699B7B0AAFC
4 changed files with 35 additions and 7 deletions

View File

@ -166,15 +166,14 @@ public class AssetsForm extends PaymentMethodForm {
@Override
protected void autoFillNameTextField() {
if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.isSelected()) {
accountNameTextField.setText(createAssetsAccountName(paymentAccount, addressInputTextField.getText()));
accountNameTextField.setText(createAssetsAccountName(paymentAccount, assetAccount.getAddress()));
}
}
@Override
public void addFormForEditAccount() {
gridRowFrom = gridRow;
addTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"),
assetAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addAccountNameTextFieldWithAutoFillToggleButton();
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
Res.get(assetAccount.getPaymentMethod().getId()));
Tuple3<Label, TextField, VBox> tuple2 = addCompactTopLabelTextField(gridPane, ++gridRow,

View File

@ -101,6 +101,12 @@ class AltCoinAccountsDataModel extends ActivatableDataModel {
TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
preferences.addCryptoCurrency((CryptoCurrency) singleTradeCurrency);
user.addPaymentAccount(paymentAccount);
paymentAccount.onPersistChanges();
}
public void onUpdateAccount(PaymentAccount paymentAccount) {
paymentAccount.onPersistChanges();
user.requestPersistence();
}
public boolean onDeleteAccount(PaymentAccount paymentAccount) {

View File

@ -168,6 +168,16 @@ public class AltCoinAccountsView extends PaymentAccountsView<GridPane, AltCoinAc
preferences.dontShowAgain(INSTANT_TRADE_NEWS, true);
}
private void onUpdateAccount(PaymentAccount paymentAccount) {
model.onUpdateAccount(paymentAccount);
removeSelectAccountForm();
}
private void onCancelSelectedAccount(PaymentAccount paymentAccount) {
paymentAccount.revertChanges();
removeSelectAccountForm();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Base form
///////////////////////////////////////////////////////////////////////////////////////////
@ -220,11 +230,20 @@ public class AltCoinAccountsView extends PaymentAccountsView<GridPane, AltCoinAc
paymentMethodForm = getPaymentMethodForm(paymentAccount);
paymentMethodForm.addFormForEditAccount();
gridRow = paymentMethodForm.getGridRow();
Tuple2<Button, Button> tuple = add2ButtonsAfterGroup(root, ++gridRow, Res.get("shared.deleteAccount"), Res.get("shared.cancel"));
Button deleteAccountButton = tuple.first;
Tuple3<Button, Button, Button> tuple = add3ButtonsAfterGroup(
root,
++gridRow,
Res.get("shared.save"),
Res.get("shared.deleteAccount"),
Res.get("shared.cancel")
);
Button saveAccountButton = tuple.first;
saveAccountButton.setOnAction(event -> onUpdateAccount(paymentAccount));
Button deleteAccountButton = tuple.second;
deleteAccountButton.setOnAction(event -> onDeleteAccount(paymentAccount));
Button cancelButton = tuple.second;
cancelButton.setOnAction(event -> removeSelectAccountForm());
Button cancelButton = tuple.third;
cancelButton.setOnAction(event -> onCancelSelectedAccount(paymentAccount));
GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan());
model.onSelectAccount(paymentAccount);
}

View File

@ -50,6 +50,10 @@ class AltCoinAccountsViewModel extends ActivatableWithDataModel<AltCoinAccountsD
dataModel.onSaveNewAccount(paymentAccount);
}
public void onUpdateAccount(PaymentAccount paymentAccount) {
dataModel.onUpdateAccount(paymentAccount);
}
public boolean onDeleteAccount(PaymentAccount paymentAccount) {
return dataModel.onDeleteAccount(paymentAccount);
}