fix(permissions): Unable to Confirm Changes to Existing Community Permission

- distinguish between `permissionTypeLimitReached` and the new
`permissionTypeLimitExceeded`
- the latter is used to enable/disable the "Save" button when editting
the permissions as we're not going to add a new one (going over the
limit), and to also hide the warning texts

Fixes #13989
This commit is contained in:
Lukáš Tinkl 2024-03-18 18:28:09 +01:00 committed by Lukáš Tinkl
parent 4b36054d6a
commit 5eb825cbe3
2 changed files with 13 additions and 10 deletions

View File

@ -198,12 +198,12 @@ StackView {
return false
}
permissionTypeLimitReached: {
readonly property var permissionTypeLimitReachedOrExceeded: {
const type = dirtyValues.permissionType
const limit = PermissionTypes.getPermissionsCountLimit(type)
if (limit === -1)
return false
return [false, false]
const model = root.permissionsModel
const count = model.rowCount()
@ -213,9 +213,12 @@ StackView {
if (type === ModelUtils.get(model, i, "permissionType"))
sameTypeCount++
return limit <= sameTypeCount
return [sameTypeCount >= limit, sameTypeCount > limit]
}
permissionTypeLimitReached: permissionTypeLimitReachedOrExceeded[0]
permissionTypeLimitExceeded: permissionTypeLimitReachedOrExceeded[1]
onCreatePermissionClicked: {
const holdings = dirtyValues.holdingsRequired ?
ModelUtils.modelToArray(

View File

@ -28,7 +28,7 @@ StatusScrollView {
readonly property bool saveEnabled: root.isFullyFilled
&& !root.permissionDuplicated
&& !root.permissionTypeLimitReached
&& (isEditState ? !root.permissionTypeLimitExceeded : !root.permissionTypeLimitReached)
property int viewWidth: 560 // by design
property bool isEditState: false
@ -59,6 +59,7 @@ StatusScrollView {
property bool permissionDuplicated: false
property bool permissionTypeLimitReached: false
property bool permissionTypeLimitExceeded
signal createPermissionClicked
signal navigateToMintTokenSettings(bool isAssetType)
@ -119,8 +120,7 @@ StatusScrollView {
property bool holdingsRequired: true
Binding on isPrivate {
value: (d.dirtyValues.permissionType === PermissionTypes.Type.Admin) ||
(d.dirtyValues.permissionType === PermissionTypes.Type.Moderator)
value: d.dirtyValues.permissionType === PermissionTypes.Type.Admin
}
function getHoldingIndex(key) {
@ -404,17 +404,17 @@ StatusScrollView {
leftPadding: 6
Binding on bgColor {
when: root.permissionTypeLimitReached
when: root.permissionTypeLimitReached && !root.isEditState
value: Theme.palette.dangerColor3
}
Binding on titleText.color {
when: root.permissionTypeLimitReached
when: root.permissionTypeLimitReached && !root.isEditState
value: Theme.palette.dangerColor1
}
Binding on asset.color {
when: root.permissionTypeLimitReached
when: root.permissionTypeLimitReached && !root.isEditState
value: Theme.palette.dangerColor1
}
@ -603,7 +603,7 @@ StatusScrollView {
return ""
}
visible: root.permissionDuplicated || root.permissionTypeLimitReached
visible: root.permissionDuplicated || (root.permissionTypeLimitReached && !root.isEditState)
}
StatusWarningBox {