2022-11-25 18:35:30 +01:00
import QtQuick 2.14
import QtQuick . Layouts 1.14
import StatusQ . Core 0.1
import SortFilterProxyModel 0.2
2022-11-24 17:23:54 +01:00
import shared . popups 1.0
2023-06-29 13:54:04 +02:00
import utils 1.0
2022-11-25 18:35:30 +01:00
2023-06-23 08:17:04 +02:00
import AppLayouts . Communities . controls 1.0
2023-06-29 13:54:04 +02:00
import AppLayouts . Communities . panels 1.0
2022-11-25 18:35:30 +01:00
2022-12-13 14:09:38 +01:00
StatusScrollView {
2022-11-25 18:35:30 +01:00
id: root
2023-03-07 09:47:04 +01:00
required property var permissionsModel
required property var assetsModel
required property var collectiblesModel
required property var channelsModel
2023-06-29 09:37:49 +02:00
// id, name, image, color, owner, admin properties expected
2023-03-07 09:47:04 +01:00
required property var communityDetails
2023-02-22 18:51:49 +01:00
2022-11-25 18:35:30 +01:00
property int viewWidth: 560 // by design
2023-02-10 23:40:07 +01:00
signal editPermissionRequested ( int index )
signal duplicatePermissionRequested ( int index )
signal removePermissionRequested ( int index )
2022-11-24 17:23:54 +01:00
2023-06-29 13:54:04 +02:00
readonly property alias count: repeater . count
2023-06-30 00:05:46 +02:00
padding: 0
topPadding: count ? 16 : 0
2022-11-24 17:23:54 +01:00
QtObject {
id: d
2023-01-18 20:54:14 +01:00
2023-02-13 11:40:13 +01:00
property int permissionIndexToRemove
2022-11-24 17:23:54 +01:00
}
2022-11-25 18:35:30 +01:00
ColumnLayout {
id: mainLayout
2023-05-31 23:58:23 +03:00
width: root . viewWidth
2022-11-25 18:35:30 +01:00
spacing: 24
2023-01-27 10:22:04 +01:00
ListModel {
id: communityItemModel
Component.onCompleted: {
append ( {
2023-03-07 09:47:04 +01:00
text: root . communityDetails . name ,
imageSource: root . communityDetails . image ,
color: root . communityDetails . color
2023-01-27 10:22:04 +01:00
} )
}
}
2023-06-29 13:54:04 +02:00
IntroPanel {
2023-06-30 00:05:46 +02:00
Layout.fillWidth: true
2023-06-29 13:54:04 +02:00
visible: root . count === 0
image: Style . png ( "community/permissions2_3" )
title: qsTr ( "Permissions" )
subtitle: qsTr ( "You can manage your community by creating and issuing membership and access permissions" )
checkersModel: [
qsTr ( "Give individual members access to private channels" ) ,
qsTr ( "Monetise your community with subscriptions and fees" ) ,
qsTr ( "Require holding a token or NFT to obtain exclusive membership rights" )
]
}
2022-11-25 18:35:30 +01:00
Repeater {
2023-06-29 13:54:04 +02:00
id: repeater
2023-03-07 09:47:04 +01:00
model: root . permissionsModel
2023-02-11 20:03:57 +01:00
2022-11-25 18:35:30 +01:00
delegate: PermissionItem {
2023-05-31 23:58:23 +03:00
Layout.fillWidth: true
2023-02-11 20:03:57 +01:00
2023-02-13 11:40:13 +01:00
holdingsListModel: HoldingsSelectionModel {
2022-11-25 18:35:30 +01:00
sourceModel: model . holdingsListModel
2023-03-07 09:47:04 +01:00
assetsModel: root . assetsModel
collectiblesModel: root . collectiblesModel
2022-11-25 18:35:30 +01:00
}
2023-02-11 20:03:57 +01:00
permissionType: model . permissionType
2023-08-08 18:17:24 +02:00
permissionState: model . permissionState // TODO: Backend!
2023-01-27 10:22:04 +01:00
2023-02-28 13:44:46 +01:00
ChannelsSelectionModel {
id: channelsSelectionModel
2023-01-27 10:22:04 +01:00
2023-03-07 16:50:23 +01:00
sourceModel: model . channelsListModel ? ? null
2023-03-07 09:47:04 +01:00
channelsModel: root . channelsModel
2022-11-25 18:35:30 +01:00
}
2023-01-27 10:22:04 +01:00
2023-02-28 13:44:46 +01:00
channelsListModel: channelsSelectionModel . count
? channelsSelectionModel : communityItemModel
2022-11-25 18:35:30 +01:00
isPrivate: model . isPrivate
2023-08-22 20:09:34 +02:00
showButtons: ( model . permissionType !== PermissionTypes . Type . TokenMaster &&
model . permissionType !== PermissionTypes . Type . Owner ) &&
( root . communityDetails . owner ||
( ( root . communityDetails . admin || root . communityDetails . tokenMaster ) && model . permissionType !== PermissionTypes . Type . Admin ) )
2023-06-14 18:00:41 +02:00
2023-02-10 23:40:07 +01:00
onEditClicked: root . editPermissionRequested ( model . index )
onDuplicateClicked: root . duplicatePermissionRequested ( model . index )
2023-01-27 10:22:04 +01:00
2023-02-10 23:40:07 +01:00
onRemoveClicked: {
d . permissionIndexToRemove = index
declineAllDialog . open ( )
}
2022-11-25 18:35:30 +01:00
}
}
}
2022-11-24 17:23:54 +01:00
2023-02-10 23:40:07 +01:00
ConfirmationDialog {
id: declineAllDialog
2023-05-23 14:46:16 +02:00
headerSettings.title: qsTr ( "Sure you want to delete permission" )
2023-02-16 00:04:24 +01:00
confirmationText: qsTr ( "If you delete this permission, any of your community members who rely on this permission will lose the access this permission gives them." )
2023-02-10 23:40:07 +01:00
onConfirmButtonClicked: {
root . removePermissionRequested ( d . permissionIndexToRemove )
close ( )
2022-11-24 17:23:54 +01:00
}
}
2022-11-25 18:35:30 +01:00
}