From bcb9d787c892806058c0998832cd0b297bf6db45 Mon Sep 17 00:00:00 2001 From: Andrey Bocharnikov Date: Tue, 28 May 2024 17:11:29 +0400 Subject: [PATCH] fix(permissions): Communities: HoldingsDropdown doesn't allow decimal input (Edit Permissions) If chainName is empty, HoldingsDropdown doesn't initialise decimals for AmountInput Fixes #14942 --- ui/app/AppLayouts/Communities/controls/TokenItem.qml | 1 + ui/app/AppLayouts/Communities/controls/TokenPanel.qml | 3 ++- .../AppLayouts/Communities/helpers/PermissionsHelpers.qml | 7 +++++++ ui/app/AppLayouts/Communities/popups/HoldingsDropdown.qml | 4 +++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ui/app/AppLayouts/Communities/controls/TokenItem.qml b/ui/app/AppLayouts/Communities/controls/TokenItem.qml index a71eacab74..f0ef0875d4 100644 --- a/ui/app/AppLayouts/Communities/controls/TokenItem.qml +++ b/ui/app/AppLayouts/Communities/controls/TokenItem.qml @@ -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 diff --git a/ui/app/AppLayouts/Communities/controls/TokenPanel.qml b/ui/app/AppLayouts/Communities/controls/TokenPanel.qml index f24675c5a7..efff620c8f 100644 --- a/ui/app/AppLayouts/Communities/controls/TokenPanel.qml +++ b/ui/app/AppLayouts/Communities/controls/TokenPanel.qml @@ -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 diff --git a/ui/app/AppLayouts/Communities/helpers/PermissionsHelpers.qml b/ui/app/AppLayouts/Communities/helpers/PermissionsHelpers.qml index b192b3b20a..79f0092d2d 100644 --- a/ui/app/AppLayouts/Communities/helpers/PermissionsHelpers.qml +++ b/ui/app/AppLayouts/Communities/helpers/PermissionsHelpers.qml @@ -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) diff --git a/ui/app/AppLayouts/Communities/popups/HoldingsDropdown.qml b/ui/app/AppLayouts/Communities/popups/HoldingsDropdown.qml index 5a80e50058..f68001802a 100644 --- a/ui/app/AppLayouts/Communities/popups/HoldingsDropdown.qml +++ b/ui/app/AppLayouts/Communities/popups/HoldingsDropdown.qml @@ -306,7 +306,7 @@ StatusDropdown { && ModelUtils.get(root.collectiblesModel, 0, "category") === TokenCategories.Category.General } - onTypeChanged: forceActiveFocus() + onTypeChanged: forceActiveFocus() onItemClicked: { d.assetAmountText = "" @@ -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