2022-11-25 17:35:30 +00:00
import QtQuick 2.14
import QtQuick . Layouts 1.14
import StatusQ . Core 0.1
import SortFilterProxyModel 0.2
2022-11-24 16:23:54 +00:00
import shared . popups 1.0
2023-06-29 11:54:04 +00:00
import utils 1.0
2022-11-25 17:35:30 +00:00
2023-06-23 06:17:04 +00:00
import AppLayouts . Communities . controls 1.0
2023-06-29 11:54:04 +00:00
import AppLayouts . Communities . panels 1.0
2022-11-25 17:35:30 +00:00
2022-12-13 13:09:38 +00:00
StatusScrollView {
2022-11-25 17:35:30 +00:00
id: root
2023-03-07 08:47:04 +00:00
required property var permissionsModel
required property var assetsModel
required property var collectiblesModel
required property var channelsModel
2023-06-29 07:37:49 +00:00
// id, name, image, color, owner, admin properties expected
2023-03-07 08:47:04 +00:00
required property var communityDetails
2023-02-22 17:51:49 +00:00
2022-11-25 17:35:30 +00:00
property int viewWidth: 560 // by design
2023-02-10 22:40:07 +00:00
signal editPermissionRequested ( int index )
signal duplicatePermissionRequested ( int index )
signal removePermissionRequested ( int index )
2022-11-24 16:23:54 +00:00
2023-06-29 11:54:04 +00:00
readonly property alias count: repeater . count
2023-06-29 22:05:46 +00:00
padding: 0
topPadding: count ? 16 : 0
2022-11-24 16:23:54 +00:00
QtObject {
id: d
2023-01-18 19:54:14 +00:00
2023-02-13 10:40:13 +00:00
property int permissionIndexToRemove
2022-11-24 16:23:54 +00:00
}
2022-11-25 17:35:30 +00:00
ColumnLayout {
id: mainLayout
2023-05-31 20:58:23 +00:00
width: root . viewWidth
2022-11-25 17:35:30 +00:00
spacing: 24
2023-01-27 09:22:04 +00:00
ListModel {
id: communityItemModel
Component.onCompleted: {
append ( {
2023-03-07 08:47:04 +00:00
text: root . communityDetails . name ,
imageSource: root . communityDetails . image ,
color: root . communityDetails . color
2023-01-27 09:22:04 +00:00
} )
}
}
2023-06-29 11:54:04 +00:00
IntroPanel {
2023-06-29 22:05:46 +00:00
Layout.fillWidth: true
2023-06-29 11:54:04 +00: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 17:35:30 +00:00
Repeater {
2023-06-29 11:54:04 +00:00
id: repeater
2023-03-07 08:47:04 +00:00
model: root . permissionsModel
2023-02-11 19:03:57 +00:00
2022-11-25 17:35:30 +00:00
delegate: PermissionItem {
2023-05-31 20:58:23 +00:00
Layout.fillWidth: true
2023-02-11 19:03:57 +00:00
2023-02-13 10:40:13 +00:00
holdingsListModel: HoldingsSelectionModel {
2022-11-25 17:35:30 +00:00
sourceModel: model . holdingsListModel
2023-03-07 08:47:04 +00:00
assetsModel: root . assetsModel
collectiblesModel: root . collectiblesModel
2022-11-25 17:35:30 +00:00
}
2023-02-11 19:03:57 +00:00
permissionType: model . permissionType
2023-01-27 09:22:04 +00:00
2023-02-28 12:44:46 +00:00
ChannelsSelectionModel {
id: channelsSelectionModel
2023-01-27 09:22:04 +00:00
2023-03-07 15:50:23 +00:00
sourceModel: model . channelsListModel ? ? null
2023-03-07 08:47:04 +00:00
channelsModel: root . channelsModel
2022-11-25 17:35:30 +00:00
}
2023-01-27 09:22:04 +00:00
2023-02-28 12:44:46 +00:00
channelsListModel: channelsSelectionModel . count
? channelsSelectionModel : communityItemModel
2022-11-25 17:35:30 +00:00
isPrivate: model . isPrivate
2023-06-29 07:37:49 +00:00
showButtons: root . communityDetails . owner || ( root . communityDetails . admin && model . permissionType !== PermissionTypes . Type . Admin )
2023-06-14 16:00:41 +00:00
2023-02-10 22:40:07 +00:00
onEditClicked: root . editPermissionRequested ( model . index )
onDuplicateClicked: root . duplicatePermissionRequested ( model . index )
2023-01-27 09:22:04 +00:00
2023-02-10 22:40:07 +00:00
onRemoveClicked: {
d . permissionIndexToRemove = index
declineAllDialog . open ( )
}
2022-11-25 17:35:30 +00:00
}
}
}
2022-11-24 16:23:54 +00:00
2023-02-10 22:40:07 +00:00
ConfirmationDialog {
id: declineAllDialog
2023-05-23 12:46:16 +00:00
headerSettings.title: qsTr ( "Sure you want to delete permission" )
2023-02-15 23:04:24 +00: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 22:40:07 +00:00
onConfirmButtonClicked: {
root . removePermissionRequested ( d . permissionIndexToRemove )
close ( )
2022-11-24 16:23:54 +00:00
}
}
2022-11-25 17:35:30 +00:00
}