2022-11-24 16:23:54 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
2022-12-01 16:31:03 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2022-11-24 16:23:54 +00:00
|
|
|
|
2023-07-04 15:11:41 +00:00
|
|
|
import AppLayouts.Communities.controls 1.0
|
|
|
|
|
2022-12-01 16:31:03 +00:00
|
|
|
Flickable {
|
2022-11-24 16:23:54 +00:00
|
|
|
id: root
|
|
|
|
|
|
|
|
property var model
|
|
|
|
|
2023-02-13 10:40:13 +00:00
|
|
|
property var assetKeys: []
|
|
|
|
property var collectibleKeys: []
|
2023-02-28 12:44:46 +00:00
|
|
|
property var channelKeys: []
|
2023-02-13 10:40:13 +00:00
|
|
|
|
2022-12-01 16:31:03 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
2023-02-13 10:40:13 +00:00
|
|
|
|
|
|
|
property int newType
|
|
|
|
property string newKey
|
2022-12-01 16:31:03 +00:00
|
|
|
property string newName
|
|
|
|
property double newAmount
|
|
|
|
property string newImageSource
|
|
|
|
property string newChannelName
|
|
|
|
property string newChannelIconSource
|
|
|
|
}
|
|
|
|
|
|
|
|
contentWidth: root.width
|
|
|
|
contentHeight: globalContent.implicitHeight
|
2022-11-24 16:23:54 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
2022-12-01 16:31:03 +00:00
|
|
|
id: globalContent
|
2023-02-28 12:44:46 +00:00
|
|
|
spacing: 20
|
2022-12-01 16:31:03 +00:00
|
|
|
anchors.fill: parent
|
2022-11-24 16:23:54 +00:00
|
|
|
|
2022-12-01 16:31:03 +00:00
|
|
|
Repeater {
|
|
|
|
model: root.model
|
2022-11-24 16:23:54 +00:00
|
|
|
|
2023-02-28 12:44:46 +00:00
|
|
|
GroupBox {
|
|
|
|
title: `Permission ${model.index}`
|
|
|
|
|
2022-12-01 16:31:03 +00:00
|
|
|
Layout.preferredHeight: content.implicitHeight + 50
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: content
|
2023-02-28 12:44:46 +00:00
|
|
|
spacing: 20
|
2022-12-01 16:31:03 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
2023-02-28 12:44:46 +00:00
|
|
|
Repeater {
|
|
|
|
model: holdingsListModel
|
2022-12-01 16:31:03 +00:00
|
|
|
|
2023-02-28 12:44:46 +00:00
|
|
|
GroupBox {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
title: `Who holds [item ${model.index}]`
|
2022-12-01 16:31:03 +00:00
|
|
|
|
2023-02-13 10:40:13 +00:00
|
|
|
CommunityPermissionsHoldingItemEditor {
|
2023-02-28 12:44:46 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
2023-02-13 10:40:13 +00:00
|
|
|
type: model.type
|
|
|
|
key: model.key
|
2022-12-01 16:31:03 +00:00
|
|
|
amountText: model.amount
|
2023-02-13 10:40:13 +00:00
|
|
|
|
|
|
|
assetKeys: root.assetKeys
|
|
|
|
collectibleKeys: root.collectibleKeys
|
|
|
|
|
|
|
|
onTypeChanged: model.type = type
|
|
|
|
onKeyChanged: model.key = key
|
2022-12-01 16:31:03 +00:00
|
|
|
onAmountTextChanged: model.amount = parseFloat(amountText)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 12:44:46 +00:00
|
|
|
GroupBox {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
title: "New holding item"
|
2023-02-13 10:40:13 +00:00
|
|
|
|
2023-02-28 12:44:46 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
2023-02-13 10:40:13 +00:00
|
|
|
|
2023-02-28 12:44:46 +00:00
|
|
|
CommunityPermissionsHoldingItemEditor {
|
|
|
|
Layout.fillWidth: true
|
2022-12-01 16:31:03 +00:00
|
|
|
|
2023-02-28 12:44:46 +00:00
|
|
|
type: d.newType
|
|
|
|
key: d.newKey
|
|
|
|
amountText: d.newAmount
|
2022-12-01 16:31:03 +00:00
|
|
|
|
2023-02-28 12:44:46 +00:00
|
|
|
assetKeys: root.assetKeys
|
|
|
|
collectibleKeys: root.collectibleKeys
|
|
|
|
|
|
|
|
onTypeChanged: d.newType = type
|
|
|
|
onKeyChanged: d.newKey = key
|
|
|
|
onAmountTextChanged: d.newAmount = parseFloat(amountText)
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuSeparator {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
enabled: d.newKey && (d.newAmount || d.newType === HoldingTypes.Type.Ens)
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: "Add new holding"
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
model.holdingsListModel.append({
|
|
|
|
type: d.newType,
|
|
|
|
key: d.newKey,
|
|
|
|
amount: d.newAmount
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-12-01 16:31:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-28 12:44:46 +00:00
|
|
|
MenuSeparator {
|
2022-12-01 16:31:03 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2023-02-28 12:44:46 +00:00
|
|
|
Label {
|
|
|
|
text: "Channels"
|
|
|
|
}
|
|
|
|
|
|
|
|
Flow {
|
2022-12-01 16:31:03 +00:00
|
|
|
Layout.fillWidth: true
|
2023-02-28 12:44:46 +00:00
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: channelsRepeater
|
|
|
|
|
|
|
|
model: root.channelKeys
|
|
|
|
|
|
|
|
CheckBox {
|
|
|
|
text: modelData
|
|
|
|
|
|
|
|
checked: ModelUtils.contains(
|
2023-02-28 14:10:50 +00:00
|
|
|
channelsListModel, "key", modelData)
|
2023-02-28 12:44:46 +00:00
|
|
|
|
|
|
|
onToggled: {
|
|
|
|
const channels = []
|
|
|
|
const count = channelsRepeater.count
|
|
|
|
|
|
|
|
for (let i = 0; i < count; i++) {
|
|
|
|
const checked = channelsRepeater.itemAt(i).checked
|
|
|
|
|
|
|
|
if (checked) {
|
2023-02-28 14:10:50 +00:00
|
|
|
const key = root.channelKeys[i]
|
|
|
|
channels.push({ key })
|
2023-02-28 12:44:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
channelsListModel.clear()
|
|
|
|
channelsListModel.append(channels)
|
|
|
|
}
|
|
|
|
}
|
2022-12-01 16:31:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckBox {
|
|
|
|
text: "Permission is private"
|
|
|
|
checked: model.isPrivate
|
|
|
|
onToggled: model.isPrivate = checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-24 16:23:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|