Implemented that calling retrieve account transactions and transfer money is only possible if the (selected) bank account supports this
This commit is contained in:
parent
4cd023c5f4
commit
37570da2ac
|
@ -4,7 +4,6 @@ import javafx.beans.property.SimpleBooleanProperty
|
|||
import javafx.scene.input.KeyCode
|
||||
import javafx.scene.input.KeyCodeCombination
|
||||
import javafx.scene.input.KeyCombination
|
||||
import net.dankito.banking.ui.model.Account
|
||||
import net.dankito.banking.ui.presenter.MainWindowPresenter
|
||||
import net.dankito.utils.javafx.ui.extensions.fixedHeight
|
||||
import tornadofx.*
|
||||
|
@ -17,10 +16,10 @@ open class MainMenuBar(protected val presenter: MainWindowPresenter) : View() {
|
|||
|
||||
init {
|
||||
presenter.addAccountsChangedListener {
|
||||
checkIfThereAreAccountsThatCanTransferMoney(it)
|
||||
checkIfThereAreAccountsThatCanTransferMoney()
|
||||
}
|
||||
|
||||
checkIfThereAreAccountsThatCanTransferMoney(presenter.accounts)
|
||||
checkIfThereAreAccountsThatCanTransferMoney()
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,8 +49,8 @@ open class MainMenuBar(protected val presenter: MainWindowPresenter) : View() {
|
|||
}
|
||||
|
||||
|
||||
protected open fun checkIfThereAreAccountsThatCanTransferMoney(accounts: List<Account>) {
|
||||
areAccountsThatCanTransferMoneyAdded.value = accounts.isNotEmpty() // TODO: add check if they support transferring money
|
||||
protected open fun checkIfThereAreAccountsThatCanTransferMoney() {
|
||||
areAccountsThatCanTransferMoneyAdded.value = presenter.hasBankAccountsSupportTransferringMoney
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package net.dankito.banking.ui.javafx.controls
|
||||
|
||||
import javafx.beans.property.SimpleBooleanProperty
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import javafx.geometry.Insets
|
||||
import javafx.geometry.Pos
|
||||
|
@ -19,6 +20,11 @@ open class AccountTransactionsControlView(
|
|||
) : View() {
|
||||
|
||||
|
||||
protected val supportsRetrievingAccountTransactions = SimpleBooleanProperty(false)
|
||||
|
||||
protected val supportsTransferringMoney = SimpleBooleanProperty(false)
|
||||
|
||||
|
||||
override val root = borderpane {
|
||||
fixedHeight = 36.0
|
||||
|
||||
|
@ -31,17 +37,21 @@ open class AccountTransactionsControlView(
|
|||
|
||||
center {
|
||||
searchtextfield(transactionsFilter) {
|
||||
|
||||
enableWhen(supportsRetrievingAccountTransactions)
|
||||
}
|
||||
}
|
||||
|
||||
right = hbox {
|
||||
alignment = Pos.CENTER_LEFT
|
||||
|
||||
hbox {
|
||||
useMaxHeight = true
|
||||
|
||||
visibleWhen(supportsRetrievingAccountTransactions)
|
||||
|
||||
label(messages["account.transactions.control.view.balance.label"]) {
|
||||
hboxConstraints {
|
||||
alignment = Pos.CENTER_LEFT
|
||||
marginLeft = 48.0
|
||||
marginRight = 6.0
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +61,15 @@ open class AccountTransactionsControlView(
|
|||
alignment = Pos.CENTER_RIGHT
|
||||
}
|
||||
|
||||
hboxConstraints {
|
||||
alignment = Pos.CENTER_LEFT
|
||||
marginLeft = 48.0
|
||||
}
|
||||
}
|
||||
|
||||
updateButton {
|
||||
enableWhen(supportsRetrievingAccountTransactions)
|
||||
|
||||
action { updateAccountTransactions(this) }
|
||||
|
||||
hboxConstraints {
|
||||
|
@ -62,6 +80,8 @@ open class AccountTransactionsControlView(
|
|||
addButton {
|
||||
useMaxHeight = true
|
||||
|
||||
enableWhen(supportsTransferringMoney)
|
||||
|
||||
action { presenter.showTransferMoneyDialog() }
|
||||
|
||||
hboxConstraints {
|
||||
|
@ -69,9 +89,41 @@ open class AccountTransactionsControlView(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
initLogic()
|
||||
}
|
||||
|
||||
private fun updateAccountTransactions(updateButton: UpdateButton) {
|
||||
|
||||
protected open fun initLogic() {
|
||||
presenter.addAccountsChangedListener { accountsChanged() }
|
||||
presenter.addSelectedBankAccountsChangedListener { selectedBankAccountsChanged() }
|
||||
|
||||
checkIfSupportsTransferringMoneyOnUiThread()
|
||||
checkIfSupportsRetrievingAccountTransactionsOnUiThread()
|
||||
}
|
||||
|
||||
protected open fun accountsChanged() {
|
||||
runLater {
|
||||
checkIfSupportsTransferringMoneyOnUiThread()
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun selectedBankAccountsChanged() {
|
||||
runLater {
|
||||
checkIfSupportsRetrievingAccountTransactionsOnUiThread()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected open fun checkIfSupportsTransferringMoneyOnUiThread() {
|
||||
supportsTransferringMoney.value = presenter.hasBankAccountsSupportTransferringMoney
|
||||
}
|
||||
|
||||
protected open fun checkIfSupportsRetrievingAccountTransactionsOnUiThread() {
|
||||
supportsRetrievingAccountTransactions.value = presenter.doSelectedBankAccountsSupportRetrievingAccountTransactions
|
||||
}
|
||||
|
||||
protected open fun updateAccountTransactions(updateButton: UpdateButton) {
|
||||
presenter.updateAccountsTransactionsAsync { transactions ->
|
||||
runLater {
|
||||
updateButton.resetIsUpdating()
|
||||
|
|
|
@ -82,7 +82,7 @@ open class AccountTransactionsView(private val presenter: MainWindowPresenter) :
|
|||
val contextMenu = ContextMenu()
|
||||
|
||||
contextMenu.apply {
|
||||
if (selectedItem.otherPartyName != null) {
|
||||
if (selectedItem.bankAccount.supportsTransferringMoney && selectedItem.otherPartyName != null) {
|
||||
item(String.format(FX.messages["account.transactions.table.context.menu.transfer.money.to"], selectedItem.otherPartyName)) {
|
||||
action { showTransferMoneyDialog(selectedItem) }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue