[Mint Token] Automatically switch the typed text to uppercase in symbol input

allow uppercase ASCII only input, up to 6 characters

Fixes #11201
This commit is contained in:
Lukáš Tinkl 2023-06-27 10:15:49 +02:00 committed by Lukáš Tinkl
parent 26c4eaa75b
commit 62fec738a1
1 changed files with 9 additions and 5 deletions

View File

@ -183,10 +183,10 @@ StatusScrollView {
regexValidator.errorMessage: qsTr("Your token symbol contains invalid characters (use A-Z only)")
regexValidator.regularExpression: Constants.regularExpressions.capitalOnly
extraValidator.validate: function (value) {
// If minted failed, we can retry same deployment, so same symbol allowed
var allowRepeatedName = (root.isAssetView ? asset.deployState : collectible.deployState) === Constants.ContractTransactionStatus.Failed
// If minting failed, we can retry same deployment, so same symbol allowed
const allowRepeatedName = (root.isAssetView ? asset.deployState : collectible.deployState) === Constants.ContractTransactionStatus.Failed
if(allowRepeatedName)
if(symbolInput.text === root.referenceSymbol)
if(symbolInput.text.toUpperCase() === root.referenceSymbol.toUpperCase())
return true
// Otherwise, no repeated names allowed:
@ -195,10 +195,14 @@ StatusScrollView {
extraValidator.errorMessage: qsTr("You have used this token symbol before")
onTextChanged: {
const cursorPos = input.edit.cursorPosition
const upperSymbol = text.toUpperCase()
if(root.isAssetView)
asset.symbol = text
asset.symbol = upperSymbol
else
collectible.symbol = text
collectible.symbol = upperSymbol
text = upperSymbol // breaking the binding on purpose but so does validate() and onTextChanged() internal handler
input.edit.cursorPosition = cursorPos
}
}