fix(permissions): Communities: HoldingsDropdown doesn't allow decimal input (Edit Permissions)

If chainName is empty, HoldingsDropdown doesn't initialise decimals for AmountInput

Fixes #14942
This commit is contained in:
Andrey Bocharnikov 2024-05-28 17:11:29 +04:00
parent c9641bb0b9
commit bcb9d787c8
4 changed files with 13 additions and 2 deletions

View File

@ -13,6 +13,7 @@ Control {
property string shortName
property string amount
property url iconSource
property string decimals
property bool selected: false
property bool showSubItemsIcon: false

View File

@ -19,6 +19,7 @@ ColumnLayout {
property alias tokenShortName: item.shortName
property alias tokenAmount: item.amount
property alias tokenImage: item.iconSource
property alias tokenDecimals: item.decimals
property alias amountText: amountInput.text
property alias amount: amountInput.amount
property alias decimals: amountInput.tokenDecimals
@ -131,7 +132,7 @@ ColumnLayout {
maximumAmount: !!networksComboBoxLoader.item
? networksComboBoxLoader.item.currentAmount : "0"
tokenDecimals: !!networksComboBoxLoader.item
? networksComboBoxLoader.item.decimals : 0
? networksComboBoxLoader.item.decimals : root.tokenDecimals
multiplierIndex: !!networksComboBoxLoader.item
? networksComboBoxLoader.item.currentMultiplierIndex : 0

View File

@ -36,6 +36,13 @@ QtObject {
return ""
}
function getTokenDecimalsByKey(model, key) {
const item = getTokenByKey(model, key)
if (item)
return item.decimals ?? 0
return 0
}
function getTokenRemainingSupplyByKey(model, key) {
const item = getTokenByKey(model, key)

View File

@ -402,6 +402,7 @@ StatusDropdown {
tokenName: PermissionsHelpers.getTokenNameByKey(root.assetsModel, root.assetKey)
tokenShortName: PermissionsHelpers.getTokenShortNameByKey(root.assetsModel, root.assetKey)
tokenImage: PermissionsHelpers.getTokenIconByKey(root.assetsModel, root.assetKey)
tokenDecimals: PermissionsHelpers.getTokenDecimalsByKey(root.assetsModel, root.assetKey)
tokenAmount: PermissionsHelpers.getTokenRemainingSupplyByKey(root.assetsModel, root.assetKey)
amountText: d.assetAmountText
tokenCategoryText: qsTr("Asset")
@ -477,6 +478,7 @@ StatusDropdown {
tokenShortName: ""
tokenImage: PermissionsHelpers.getTokenIconByKey(root.collectiblesModel, root.collectibleKey)
tokenAmount: PermissionsHelpers.getTokenRemainingSupplyByKey(root.collectiblesModel, root.collectibleKey)
tokenDecimals: PermissionsHelpers.getTokenDecimalsByKey(root.collectiblesModel, root.assetKey)
amountText: d.collectibleAmountText
tokenCategoryText: qsTr("Collectible")
addOrUpdateButtonEnabled: d.collectiblesReady