feat(CommunityPermissions): Switch to enable/disable 'Who holds' section
Closes: #8498
This commit is contained in:
parent
43196d9e31
commit
8dafdfceb8
|
@ -28,6 +28,8 @@ SplitView {
|
|||
permissionDuplicated: isPermissionDuplicatedCheckBox.checked
|
||||
permissionTypeLimitReached: isLimitReachedCheckBox.checked
|
||||
|
||||
showWhoHoldsSwitch: true
|
||||
|
||||
assetsModel: AssetsModel {}
|
||||
collectiblesModel: CollectiblesModel {}
|
||||
channelsModel: ChannelsModel {}
|
||||
|
|
|
@ -79,6 +79,8 @@ SplitView {
|
|||
|
||||
isOwner: isOwnerCheckBox.checked
|
||||
|
||||
showWhoHoldsSwitch: true
|
||||
|
||||
onCreatePermissionRequested: {
|
||||
permissionsStoreMock.createPermission(holdings, permissionType,
|
||||
isPrivate, channels)
|
||||
|
|
|
@ -105,6 +105,8 @@ StatusFlowSelector {
|
|||
*/
|
||||
property bool itemsClickable: true
|
||||
|
||||
readonly property alias count: repeater.count
|
||||
|
||||
/*!
|
||||
\qmlsignal StatusItemSelector::itemClicked
|
||||
This signal is emitted when the item is clicked.
|
||||
|
|
|
@ -89,11 +89,14 @@ Control{
|
|||
StatusBaseText {
|
||||
font.pixelSize: d.itemTextPixelSize
|
||||
height: d.flowRowHeight
|
||||
text: qsTr("Anyone who holds")
|
||||
text: holdingsRepeater.count > 0 ? qsTr("Anyone who holds")
|
||||
: qsTr("Anyone")
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: holdingsRepeater
|
||||
|
||||
model: root.holdingsListModel
|
||||
|
||||
StatusListItemTag {
|
||||
|
|
|
@ -23,6 +23,10 @@ SettingsPageLayout {
|
|||
|
||||
property int viewWidth: 560 // by design
|
||||
|
||||
// TODO: temporary property, to be removed when no need to hide the switch
|
||||
// in the app
|
||||
property bool showWhoHoldsSwitch: false
|
||||
|
||||
signal createPermissionRequested(
|
||||
int permissionType, var holdings, var channels, bool isPrivate)
|
||||
|
||||
|
@ -182,6 +186,10 @@ SettingsPageLayout {
|
|||
|
||||
permissionType: d.permissionTypeToEdit
|
||||
isPrivate: d.isPrivateToEditValue
|
||||
holdingsRequired: selectedHoldingsModel ? selectedHoldingsModel.count > 0
|
||||
: false
|
||||
|
||||
showWhoHoldsSwitch: root.showWhoHoldsSwitch
|
||||
|
||||
permissionDuplicated: {
|
||||
// dependencies
|
||||
|
@ -205,6 +213,12 @@ SettingsPageLayout {
|
|||
|
||||
const same = (a, b) => ModelUtils.checkEqualitySet(a, b, ["key"])
|
||||
|
||||
if (holdings.rowCount() === 0 && dirtyValues.holdingsRequired)
|
||||
continue
|
||||
|
||||
if (holdings.rowCount() !== 0 && !dirtyValues.holdingsRequired)
|
||||
continue
|
||||
|
||||
if (same(dirtyValues.selectedHoldingsModel, holdings)
|
||||
&& same(dirtyValues.selectedChannelsModel, channels)
|
||||
&& dirtyValues.permissionType === permissionType)
|
||||
|
@ -233,9 +247,11 @@ SettingsPageLayout {
|
|||
}
|
||||
|
||||
onCreatePermissionClicked: {
|
||||
const holdings = ModelUtils.modelToArray(
|
||||
dirtyValues.selectedHoldingsModel,
|
||||
["key", "type", "amount"])
|
||||
const holdings = dirtyValues.holdingsRequired ?
|
||||
ModelUtils.modelToArray(
|
||||
dirtyValues.selectedHoldingsModel,
|
||||
["key", "type", "amount"])
|
||||
: []
|
||||
|
||||
const channels = ModelUtils.modelToArray(
|
||||
dirtyValues.selectedChannelsModel, ["key"])
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import QtQuick 2.14
|
||||
import QtQuick.Layouts 1.14
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtQml 2.15
|
||||
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
|
@ -30,8 +31,13 @@ StatusScrollView {
|
|||
property int viewWidth: 560 // by design
|
||||
property bool isEditState: false
|
||||
|
||||
// TODO: temporary property, to be removed when no need to hide the switch
|
||||
// in the app
|
||||
property bool showWhoHoldsSwitch: false
|
||||
|
||||
readonly property bool dirty:
|
||||
!holdingsModelComparator.equal ||
|
||||
root.holdingsRequired !== d.dirtyValues.holdingsRequired ||
|
||||
(d.dirtyValues.holdingsRequired && !holdingsModelComparator.equal) ||
|
||||
!channelsModelComparator.equal ||
|
||||
root.isPrivate !== d.dirtyValues.isPrivate ||
|
||||
root.permissionType !== d.dirtyValues.permissionType
|
||||
|
@ -39,12 +45,13 @@ StatusScrollView {
|
|||
readonly property alias dirtyValues: d.dirtyValues
|
||||
|
||||
readonly property bool isFullyFilled:
|
||||
dirtyValues.selectedHoldingsModel.count > 0 &&
|
||||
(dirtyValues.selectedHoldingsModel.count > 0 || !whoHoldsSwitch.checked) &&
|
||||
dirtyValues.permissionType !== PermissionTypes.Type.None &&
|
||||
(d.isCommunityPermission || dirtyValues.selectedChannelsModel.count > 0)
|
||||
|
||||
property int permissionType: PermissionTypes.Type.None
|
||||
property bool isPrivate: false
|
||||
property bool holdingsRequired: true
|
||||
|
||||
// roles: type, key, name, amount, imageSource
|
||||
property var selectedHoldingsModel: ListModel {}
|
||||
|
@ -111,6 +118,7 @@ StatusScrollView {
|
|||
|
||||
property int permissionType: PermissionTypes.Type.None
|
||||
property bool isPrivate: false
|
||||
property bool holdingsRequired: true
|
||||
|
||||
Binding on isPrivate {
|
||||
value: (d.dirtyValues.permissionType === PermissionTypes.Type.Admin) ||
|
||||
|
@ -161,6 +169,9 @@ StatusScrollView {
|
|||
|
||||
// Is private permission
|
||||
d.dirtyValues.isPrivate = root.isPrivate
|
||||
|
||||
// Are holdings required
|
||||
d.dirtyValues.holdingsRequired = root.holdingsRequired
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,7 +203,8 @@ StatusScrollView {
|
|||
tagLeftPadding: 2
|
||||
asset.height: 28
|
||||
asset.width: asset.height
|
||||
addButton.visible: model.count < d.maxHoldingsItems
|
||||
addButton.visible: count < d.maxHoldingsItems &&
|
||||
whoHoldsSwitch.checked
|
||||
|
||||
model: HoldingsSelectionModel {
|
||||
sourceModel: d.dirtyValues.selectedHoldingsModel
|
||||
|
@ -201,6 +213,36 @@ StatusScrollView {
|
|||
collectiblesModel: root.collectiblesModel
|
||||
}
|
||||
|
||||
label.enabled: whoHoldsSwitch.checked
|
||||
placeholderItem.visible: count === 0 && whoHoldsSwitch.checked
|
||||
|
||||
Binding on model {
|
||||
when: !whoHoldsSwitch.checked
|
||||
value: 0
|
||||
restoreMode: Binding.RestoreBindingOrValue
|
||||
}
|
||||
|
||||
Binding on bottomPadding {
|
||||
when: !whoHoldsSwitch.checked
|
||||
value: 0
|
||||
restoreMode: Binding.RestoreBindingOrValue
|
||||
}
|
||||
|
||||
children: StatusSwitch {
|
||||
id: whoHoldsSwitch
|
||||
|
||||
visible: root.showWhoHoldsSwitch
|
||||
|
||||
padding: 0
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.rightMargin: 12
|
||||
anchors.topMargin: 10
|
||||
|
||||
checked: d.dirtyValues.holdingsRequired
|
||||
onToggled: d.dirtyValues.holdingsRequired = checked
|
||||
}
|
||||
|
||||
HoldingsDropdown {
|
||||
id: dropdown
|
||||
|
||||
|
|
Loading…
Reference in New Issue