2020-12-11 20:29:46 +00:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
import QtQuick.Dialogs 1.3
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2020-12-11 20:29:46 +00:00
|
|
|
import "../../../../shared"
|
2021-10-14 12:14:11 +00:00
|
|
|
import "../../../../shared/panels"
|
2021-10-14 10:52:56 +00:00
|
|
|
import "../../../../shared/popups"
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2021-08-17 10:49:13 +00:00
|
|
|
import StatusQ.Controls.Validators 0.1
|
2021-07-16 10:11:03 +00:00
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
StatusModal {
|
2021-02-11 20:37:31 +00:00
|
|
|
property QtObject community: chatsModel.communities.activeCommunity
|
2020-12-17 13:24:33 +00:00
|
|
|
|
2020-12-21 17:59:47 +00:00
|
|
|
property bool isEdit: false
|
2021-06-29 12:47:28 +00:00
|
|
|
|
|
|
|
readonly property int maxCommunityNameLength: 30
|
|
|
|
readonly property int maxCommunityDescLength: 140
|
|
|
|
readonly property var communityColorValidator: Utils.Validate.NoEmpty
|
|
|
|
| Utils.Validate.TextHexColor
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
|
|
id: popup
|
2021-09-14 06:01:43 +00:00
|
|
|
height: 509
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
|
|
onOpened: {
|
2021-03-29 12:28:41 +00:00
|
|
|
if (isEdit) {
|
2021-09-07 13:28:38 +00:00
|
|
|
contentItem.communityName.input.text = community.name;
|
|
|
|
contentItem.communityDescription.input.text = community.description;
|
|
|
|
contentItem.communityColor.color = community.communityColor;
|
|
|
|
contentItem.communityColor.colorSelected = true
|
2021-05-24 03:09:49 +00:00
|
|
|
if (community.largeImage) {
|
2021-09-07 13:28:38 +00:00
|
|
|
contentItem.communityImage.selectedImage = community.largeImage
|
2021-05-24 03:09:49 +00:00
|
|
|
}
|
|
|
|
membershipRequirementSettingPopup.checkedMembership = community.access
|
2021-03-29 12:28:41 +00:00
|
|
|
}
|
2021-09-07 13:28:38 +00:00
|
|
|
contentItem.communityName.input.forceActiveFocus(Qt.MouseFocusReason)
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2021-03-29 12:28:41 +00:00
|
|
|
onClosed: destroy()
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-06-29 12:47:28 +00:00
|
|
|
function isFormValid() {
|
2021-09-07 13:28:38 +00:00
|
|
|
return contentItem.communityName.valid && contentItem.communityDescription.valid &&
|
|
|
|
Utils.validateAndReturnError(contentItem.communityColor.color.toString().toUpperCase(),
|
2021-08-17 10:49:13 +00:00
|
|
|
communityColorValidator) === ""
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
header.title: isEdit ?
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Edit community"
|
|
|
|
qsTrId("edit-community") :
|
|
|
|
//% "New community"
|
|
|
|
qsTrId("new-community")
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-09-02 14:40:10 +00:00
|
|
|
contentItem: ScrollView {
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
|
|
id: scrollView
|
2021-07-16 10:11:03 +00:00
|
|
|
|
|
|
|
property ScrollBar vScrollBar: ScrollBar.vertical
|
|
|
|
|
|
|
|
property alias communityName: nameInput
|
|
|
|
property alias communityDescription: descriptionTextArea
|
|
|
|
property alias communityColor: colorDialog
|
|
|
|
property alias communityImage: addImageButton
|
|
|
|
property alias imageCropperModal: imageCropperModal
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
contentHeight: content.height
|
2021-07-16 10:11:03 +00:00
|
|
|
bottomPadding: 8
|
|
|
|
width: popup.width
|
2021-09-14 06:01:43 +00:00
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
clip: true
|
|
|
|
|
|
|
|
function scrollBackUp() {
|
|
|
|
vScrollBar.setPosition(0)
|
|
|
|
}
|
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
Column {
|
2020-12-11 20:29:46 +00:00
|
|
|
id: content
|
2021-07-16 10:11:03 +00:00
|
|
|
width: popup.width
|
2021-09-14 06:01:43 +00:00
|
|
|
spacing: 8
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2021-09-14 06:01:43 +00:00
|
|
|
Item {
|
2021-08-17 10:49:13 +00:00
|
|
|
height: 8
|
2021-07-16 10:11:03 +00:00
|
|
|
width: parent.width
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-08-17 10:49:13 +00:00
|
|
|
StatusInput {
|
|
|
|
id: nameInput
|
2021-09-14 06:01:43 +00:00
|
|
|
label: qsTr("Name your community")
|
2021-08-17 10:49:13 +00:00
|
|
|
charLimit: maxCommunityNameLength
|
|
|
|
input.placeholderText: qsTr("A catchy name")
|
2021-09-20 03:00:50 +00:00
|
|
|
validators: [StatusMinLengthValidator {
|
|
|
|
minLength: 1
|
|
|
|
errorMessage: Utils.getErrorMessage(errors, "community name")
|
|
|
|
}]
|
2021-08-17 10:49:13 +00:00
|
|
|
}
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2021-08-17 10:49:13 +00:00
|
|
|
StatusInput {
|
|
|
|
id: descriptionTextArea
|
|
|
|
label: qsTr("Description")
|
|
|
|
charLimit: maxCommunityDescLength
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2021-08-17 10:49:13 +00:00
|
|
|
input.placeholderText: qsTr("What your community is about")
|
|
|
|
input.multiline: true
|
|
|
|
input.implicitHeight: 88
|
2021-07-16 10:11:03 +00:00
|
|
|
|
2021-09-20 03:00:50 +00:00
|
|
|
validators: [StatusMinLengthValidator {
|
|
|
|
minLength: 1
|
|
|
|
errorMessage: Utils.getErrorMessage(errors, "community description")
|
|
|
|
}]
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
StatusBaseText {
|
2020-12-11 20:29:46 +00:00
|
|
|
id: thumbnailText
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Thumbnail image"
|
|
|
|
text: qsTrId("thumbnail-image")
|
2021-08-17 10:49:13 +00:00
|
|
|
font.pixelSize: 15
|
2021-07-16 10:11:03 +00:00
|
|
|
color: Theme.palette.directColor1
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 16
|
2021-08-17 10:49:13 +00:00
|
|
|
anchors.topMargin: 8
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
Item {
|
|
|
|
width: parent.width
|
|
|
|
height: addImageButton.height + 32
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
Rectangle {
|
|
|
|
id: addImageButton
|
|
|
|
color: imagePreview.visible ? "transparent" : Style.current.inputBackground
|
|
|
|
width: 128
|
|
|
|
height: width
|
|
|
|
radius: width / 2
|
|
|
|
anchors.centerIn: parent
|
|
|
|
property string selectedImage: ""
|
|
|
|
|
|
|
|
FileDialog {
|
|
|
|
id: imageDialog
|
|
|
|
//% "Please choose an image"
|
|
|
|
title: qsTrId("please-choose-an-image")
|
|
|
|
folder: shortcuts.pictures
|
|
|
|
nameFilters: [
|
|
|
|
//% "Image files (*.jpg *.jpeg *.png)"
|
|
|
|
qsTrId("image-files----jpg---jpeg---png-")
|
|
|
|
]
|
|
|
|
onAccepted: {
|
|
|
|
addImageButton.selectedImage = imageDialog.fileUrls[0]
|
|
|
|
imageCropperModal.open()
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
Rectangle {
|
|
|
|
id: imagePreviewCropper
|
|
|
|
clip: true
|
2021-03-29 12:28:41 +00:00
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
2021-07-16 10:11:03 +00:00
|
|
|
radius: parent.width / 2
|
|
|
|
visible: !!addImageButton.selectedImage
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: imagePreview
|
|
|
|
visible: !!addImageButton.selectedImage
|
|
|
|
source: addImageButton.selectedImage
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
}
|
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: OpacityMask {
|
|
|
|
maskSource: Rectangle {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: imageCropperModal.width
|
|
|
|
height: imageCropperModal.height
|
|
|
|
radius: width / 2
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
Item {
|
|
|
|
id: addImageCenter
|
|
|
|
visible: !imagePreview.visible
|
|
|
|
width: uploadText.width
|
|
|
|
height: childrenRect.height
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: imageImg
|
2021-09-28 15:04:06 +00:00
|
|
|
source: Style.svg("images_icon")
|
2021-07-16 10:11:03 +00:00
|
|
|
width: 20
|
|
|
|
height: 18
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-08-17 10:49:13 +00:00
|
|
|
StatusBaseText {
|
2021-07-16 10:11:03 +00:00
|
|
|
id: uploadText
|
|
|
|
//% "Upload"
|
|
|
|
text: qsTrId("upload")
|
|
|
|
anchors.top: imageImg.bottom
|
|
|
|
anchors.topMargin: 5
|
|
|
|
font.pixelSize: 15
|
2021-08-17 10:49:13 +00:00
|
|
|
color: Theme.palette.baseColor1
|
2021-07-16 10:11:03 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
StatusRoundButton {
|
|
|
|
type: StatusRoundButton.Type.Secondary
|
|
|
|
icon.name: "add"
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.halfPadding
|
|
|
|
highlighted: sensor.containsMouse
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
MouseArea {
|
|
|
|
id: sensor
|
|
|
|
hoverEnabled: true
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: imageDialog.open()
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
ImageCropperModal {
|
|
|
|
id: imageCropperModal
|
|
|
|
selectedImage: addImageButton.selectedImage
|
|
|
|
ratio: "1:1"
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2021-03-29 12:28:41 +00:00
|
|
|
}
|
2021-07-16 10:11:03 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
2021-07-22 15:03:59 +00:00
|
|
|
//% "Community colour"
|
|
|
|
text: qsTrId("community-color")
|
2021-08-17 10:49:13 +00:00
|
|
|
font.pixelSize: 15
|
2021-07-16 10:11:03 +00:00
|
|
|
color: Theme.palette.directColor1
|
2021-03-29 12:28:41 +00:00
|
|
|
anchors.left: parent.left
|
2021-07-16 10:11:03 +00:00
|
|
|
anchors.leftMargin: 16
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
Item {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
height: colorSelectorButton.height + 16
|
|
|
|
width: parent.width - 32
|
2021-03-29 12:28:41 +00:00
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
StatusPickerButton {
|
|
|
|
id: colorSelectorButton
|
2021-03-01 19:43:50 +00:00
|
|
|
anchors.top: parent.top
|
2021-07-16 10:11:03 +00:00
|
|
|
anchors.topMargin: 10
|
|
|
|
|
|
|
|
property string validationError: ""
|
|
|
|
|
|
|
|
bgColor: colorDialog.colorSelected ?
|
|
|
|
colorDialog.color : Theme.palette.baseColor2
|
|
|
|
contentColor: colorDialog.colorSelected ? Theme.palette.indirectColor1 : Theme.palette.baseColor1
|
|
|
|
text: colorDialog.colorSelected ?
|
|
|
|
colorDialog.color.toString().toUpperCase() :
|
2021-07-22 15:03:59 +00:00
|
|
|
//% "Pick a color"
|
|
|
|
qsTrId("pick-a-color")
|
2021-03-01 19:43:50 +00:00
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
onClicked: colorDialog.open();
|
|
|
|
onTextChanged: {
|
|
|
|
if (colorDialog.colorSelected) {
|
|
|
|
validationError = Utils.validateAndReturnError(text, communityColorValidator)
|
|
|
|
}
|
2021-03-01 19:43:50 +00:00
|
|
|
}
|
2021-07-16 10:11:03 +00:00
|
|
|
|
|
|
|
ColorDialog {
|
|
|
|
id: colorDialog
|
|
|
|
property bool colorSelected: false
|
|
|
|
color: Theme.palette.primaryColor1
|
|
|
|
onAccepted: colorSelected = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
text: colorSelectorButton.validationError
|
|
|
|
visible: !!text
|
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
anchors.top: colorSelectorButton.bottom
|
|
|
|
anchors.topMargin: 4
|
|
|
|
anchors.right: colorSelectorButton.right
|
2021-03-01 19:43:50 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-10 20:37:17 +00:00
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
StatusModalDivider {
|
|
|
|
topPadding: 8
|
|
|
|
bottomPadding: 8
|
2020-12-17 13:24:33 +00:00
|
|
|
visible: !isEdit
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
StatusListItem {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
visible: !isEdit
|
2021-07-22 15:03:59 +00:00
|
|
|
//% "Membership requirement"
|
|
|
|
title: qsTrId("membership-title")
|
2021-07-16 10:11:03 +00:00
|
|
|
label: {
|
2021-02-10 20:37:17 +00:00
|
|
|
switch (membershipRequirementSettingPopup.checkedMembership) {
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Require invite from another member"
|
|
|
|
case Constants.communityChatInvitationOnlyAccess: return qsTrId("membership-invite")
|
|
|
|
//% "Require approval"
|
|
|
|
case Constants.communityChatOnRequestAccess: return qsTrId("membership-approval")
|
|
|
|
//% "No requirement"
|
|
|
|
default: return qsTrId("membership-free")
|
2021-02-10 20:37:17 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2021-07-16 10:11:03 +00:00
|
|
|
sensor.onClicked: membershipRequirementSettingPopup.open()
|
|
|
|
components: [
|
|
|
|
StatusIcon {
|
|
|
|
icon: "chevron-down"
|
|
|
|
rotation: 270
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
]
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
StatusBaseText {
|
2021-09-14 06:01:43 +00:00
|
|
|
visible: !isEdit
|
2021-02-10 20:37:17 +00:00
|
|
|
height: visible ? implicitHeight : 0
|
2020-12-11 20:29:46 +00:00
|
|
|
wrapMode: Text.WordWrap
|
2021-04-28 18:15:58 +00:00
|
|
|
font.pixelSize: 13
|
2021-07-16 10:11:03 +00:00
|
|
|
color: Theme.palette.baseColor1
|
2021-04-28 18:15:58 +00:00
|
|
|
width: parent.width * 0.78
|
2021-07-22 15:03:59 +00:00
|
|
|
//% "You can require new members to meet certain criteria before they can join. This can be changed at any time"
|
|
|
|
text: qsTrId("membership-none-placeholder")
|
2021-07-16 10:11:03 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 16
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2021-02-10 20:37:17 +00:00
|
|
|
|
2021-04-21 14:39:01 +00:00
|
|
|
// Feature commented temporarily
|
|
|
|
/*
|
2021-02-10 20:37:17 +00:00
|
|
|
StatusSettingsLineButton {
|
|
|
|
id: ensOnlySwitch
|
|
|
|
anchors.top: privateExplanation.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
2021-03-05 17:46:02 +00:00
|
|
|
isEnabled: profileModel.profile.ensVerified
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Require ENS username"
|
|
|
|
text: qsTrId("membership-ens")
|
2021-02-10 20:37:17 +00:00
|
|
|
isSwitch: true
|
|
|
|
onClicked: switchChecked = checked
|
2021-03-05 17:46:02 +00:00
|
|
|
|
|
|
|
StatusToolTip {
|
|
|
|
visible: !ensOnlySwitch.isEnabled && ensMouseArea.isHovered
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "You can only enable this setting if you have an ENS name"
|
|
|
|
text: qsTrId("you-can-only-enable-this-setting-if-you-have-an-ens-name")
|
2021-03-05 17:46:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
property bool isHovered: false
|
|
|
|
|
|
|
|
id: ensMouseArea
|
|
|
|
enabled: !ensOnlySwitch.isEnabled
|
|
|
|
visible: enabled
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onEntered: isHovered = true
|
|
|
|
onExited: isHovered = false
|
|
|
|
}
|
2021-02-10 20:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
visible: !isEdit
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
id: ensExplanation
|
|
|
|
anchors.top: ensOnlySwitch.bottom
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
anchors.topMargin: isEdit ? 0 : Style.current.halfPadding
|
|
|
|
width: parent.width
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Your community requires an ENS username to be able to join"
|
|
|
|
text: qsTrId("membership-ens-description")
|
2021-02-10 20:37:17 +00:00
|
|
|
}
|
2021-04-21 14:39:01 +00:00
|
|
|
*/
|
2021-02-10 20:37:17 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2021-07-16 10:11:03 +00:00
|
|
|
leftButtons: [
|
2021-05-24 03:09:49 +00:00
|
|
|
StatusRoundButton {
|
|
|
|
id: btnBack
|
|
|
|
visible: isEdit
|
|
|
|
icon.name: "arrow-right"
|
|
|
|
icon.width: 20
|
|
|
|
icon.height: 16
|
|
|
|
rotation: 180
|
|
|
|
onClicked: popup.destroy()
|
|
|
|
}
|
2021-07-16 10:11:03 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
rightButtons: [
|
2021-05-24 03:09:49 +00:00
|
|
|
StatusButton {
|
|
|
|
id: btnCreateEdit
|
2021-06-29 12:47:28 +00:00
|
|
|
enabled: isFormValid()
|
2021-05-24 03:09:49 +00:00
|
|
|
text: isEdit ?
|
|
|
|
//% "Save"
|
|
|
|
qsTrId("Save") :
|
|
|
|
//% "Create"
|
|
|
|
qsTrId("create")
|
|
|
|
onClicked: {
|
2021-06-29 12:47:28 +00:00
|
|
|
if (!isFormValid()) {
|
2021-09-07 13:28:38 +00:00
|
|
|
popup.contentItem.scrollBackUp()
|
2021-05-24 03:09:49 +00:00
|
|
|
return
|
|
|
|
}
|
2020-12-17 13:24:33 +00:00
|
|
|
|
2021-05-24 03:09:49 +00:00
|
|
|
let error = false;
|
|
|
|
if(isEdit) {
|
2021-07-16 10:11:03 +00:00
|
|
|
error = chatsModel.communities.editCommunity(
|
|
|
|
community.id,
|
2021-09-07 13:28:38 +00:00
|
|
|
Utils.filterXSS(popup.contentItem.communityName.input.text),
|
|
|
|
Utils.filterXSS(popup.contentItem.communityDescription.input.text),
|
2021-07-16 10:11:03 +00:00
|
|
|
membershipRequirementSettingPopup.checkedMembership,
|
|
|
|
false,
|
2021-09-07 13:28:38 +00:00
|
|
|
popup.contentItem.communityColor.color.toString().toUpperCase(),
|
2021-07-16 10:11:03 +00:00
|
|
|
// to retain the existing image, pass "" for the image path
|
2021-09-07 13:28:38 +00:00
|
|
|
popup.contentItem.communityImage.selectedImage === community.largeImage ? "" :
|
|
|
|
popup.contentItem.communityImage.selectedImage,
|
|
|
|
popup.contentItem.imageCropperModal.aX,
|
|
|
|
popup.contentItem.imageCropperModal.aY,
|
|
|
|
popup.contentItem.imageCropperModal.bX,
|
|
|
|
popup.contentItem.imageCropperModal.bY
|
2021-07-16 10:11:03 +00:00
|
|
|
)
|
2021-05-24 03:09:49 +00:00
|
|
|
} else {
|
2021-07-16 10:11:03 +00:00
|
|
|
error = chatsModel.communities.createCommunity(
|
2021-09-07 13:28:38 +00:00
|
|
|
Utils.filterXSS(popup.contentItem.communityName.input.text),
|
|
|
|
Utils.filterXSS(popup.contentItem.communityDescription.input.text),
|
2021-07-16 10:11:03 +00:00
|
|
|
membershipRequirementSettingPopup.checkedMembership,
|
|
|
|
false, // ensOnlySwitch.switchChecked, // TODO:
|
2021-09-07 13:28:38 +00:00
|
|
|
popup.contentItem.communityColor.color.toString().toUpperCase(),
|
|
|
|
popup.contentItem.communityImage.selectedImage,
|
|
|
|
popup.contentItem.imageCropperModal.aX,
|
|
|
|
popup.contentItem.imageCropperModal.aY,
|
|
|
|
popup.contentItem.imageCropperModal.bX,
|
|
|
|
popup.contentItem.imageCropperModal.bY
|
2021-07-16 10:11:03 +00:00
|
|
|
)
|
2021-05-24 03:09:49 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-05-24 03:09:49 +00:00
|
|
|
if (error) {
|
|
|
|
creatingError.text = error.error
|
|
|
|
return creatingError.open()
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-05-24 03:09:49 +00:00
|
|
|
popup.close()
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2021-07-16 10:11:03 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
id: creatingError
|
|
|
|
//% "Error creating the community"
|
|
|
|
title: qsTrId("error-creating-the-community")
|
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
}
|
|
|
|
|
|
|
|
MembershipRequirementPopup {
|
2021-07-19 13:31:59 +00:00
|
|
|
anchors.centerIn: parent
|
2021-07-16 10:11:03 +00:00
|
|
|
id: membershipRequirementSettingPopup
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|