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
|
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../shared/status"
|
|
|
|
|
|
|
|
ModalPopup {
|
|
|
|
readonly property int maxDescChars: 140
|
2021-02-10 20:37:17 +00:00
|
|
|
|
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-03-29 12:28:41 +00:00
|
|
|
property bool isValid:
|
|
|
|
nameInput.isValid &&
|
|
|
|
descriptionTextArea.isValid &&
|
|
|
|
colorPicker.isValid
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
|
|
id: popup
|
|
|
|
height: 600
|
|
|
|
|
|
|
|
onOpened: {
|
2021-03-29 12:28:41 +00:00
|
|
|
if (isEdit) {
|
|
|
|
nameInput.text = community.name;
|
|
|
|
descriptionTextArea.text = community.description;
|
2021-05-24 03:09:49 +00:00
|
|
|
colorPicker.defaultColor = community.communityColor;
|
|
|
|
if (community.largeImage) {
|
|
|
|
addImageButton.selectedImage = community.largeImage
|
|
|
|
}
|
|
|
|
membershipRequirementSettingPopup.checkedMembership = community.access
|
2021-03-29 12:28:41 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
nameInput.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
2021-03-29 12:28:41 +00:00
|
|
|
onClosed: destroy()
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
|
|
function validate() {
|
2021-03-29 12:28:41 +00:00
|
|
|
nameInput.validate()
|
|
|
|
descriptionTextArea.validate()
|
|
|
|
colorPicker.validate()
|
|
|
|
return isValid
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2020-12-17 13:24:33 +00:00
|
|
|
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
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
property ScrollBar vScrollBar: ScrollBar.vertical
|
|
|
|
|
|
|
|
id: scrollView
|
|
|
|
anchors.fill: parent
|
2021-04-28 18:26:56 +00:00
|
|
|
rightPadding: Style.current.padding
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
anchors.topMargin: -Style.current.padding
|
|
|
|
leftPadding: Style.current.padding
|
|
|
|
topPadding: Style.current.padding
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
2020-12-11 20:29:46 +00:00
|
|
|
contentHeight: content.height
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
function scrollBackUp() {
|
|
|
|
vScrollBar.setPosition(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: content
|
2021-04-28 18:15:58 +00:00
|
|
|
height: childrenRect.height + 100 // Bottom padding
|
2020-12-11 20:29:46 +00:00
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
Input {
|
|
|
|
id: nameInput
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Name your community"
|
|
|
|
label: qsTrId("name-your-community")
|
|
|
|
//% "A catchy name"
|
|
|
|
placeholderText: qsTrId("name-your-community-placeholder")
|
2021-03-29 12:28:41 +00:00
|
|
|
property bool isValid: false
|
|
|
|
|
|
|
|
onTextEdited: {
|
|
|
|
if (text.includes(" ")) {
|
|
|
|
text = text.replace(" ", "-")
|
|
|
|
}
|
|
|
|
validate()
|
|
|
|
}
|
|
|
|
|
|
|
|
function validate() {
|
|
|
|
validationError = ""
|
|
|
|
if (nameInput.text === "") {
|
|
|
|
//% "You need to enter a name"
|
|
|
|
validationError = qsTrId("you-need-to-enter-a-name")
|
|
|
|
} else if (!(/^[a-z0-9\-]+$/.test(nameInput.text))) {
|
|
|
|
validationError = qsTr("Use only lowercase letters (a to z), numbers & dashes (-). Do not use chat keys.")
|
|
|
|
} else if (nameInput.text.length > 100) {
|
|
|
|
//% "Your name needs to be 100 characters or shorter"
|
|
|
|
validationError = qsTrId("your-name-needs-to-be-100-characters-or-shorter")
|
|
|
|
}
|
|
|
|
isValid = validationError === ""
|
|
|
|
return validationError
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StyledTextArea {
|
|
|
|
id: descriptionTextArea
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Give it a short description"
|
|
|
|
label: qsTrId("give-a-short-description-community")
|
|
|
|
//% "What your community is about"
|
|
|
|
placeholderText: qsTrId("what-your-community-is-about")
|
|
|
|
//% "The description cannot exceed 140 characters"
|
2021-03-29 12:28:41 +00:00
|
|
|
validationError: descriptionTextArea.text.length > popup.maxDescChars ? qsTrId("the-description-cannot-exceed-140-characters") :
|
2021-03-03 18:50:56 +00:00
|
|
|
popup.descriptionValidationError || ""
|
2020-12-11 20:29:46 +00:00
|
|
|
anchors.top: nameInput.bottom
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
customHeight: 88
|
2020-12-17 13:24:33 +00:00
|
|
|
textField.wrapMode: TextEdit.Wrap
|
2021-03-29 12:28:41 +00:00
|
|
|
|
|
|
|
property bool isValid: false
|
|
|
|
onTextChanged: validate()
|
|
|
|
|
|
|
|
function resetValidation() {
|
|
|
|
isValid = false
|
|
|
|
validationError = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
function validate() {
|
|
|
|
validationError = ""
|
|
|
|
if (text.length > popup.maxDescChars) {
|
|
|
|
validationError = qsTrId("the-description-cannot-exceed-140-characters")
|
|
|
|
}
|
|
|
|
if (text === "") {
|
|
|
|
validationError = qsTr("You need to enter a description")
|
|
|
|
}
|
|
|
|
isValid = validationError === ""
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: charLimit
|
2021-03-29 12:28:41 +00:00
|
|
|
text: `${descriptionTextArea.text.length}/${popup.maxDescChars}`
|
2020-12-11 20:29:46 +00:00
|
|
|
anchors.top: descriptionTextArea.bottom
|
|
|
|
anchors.topMargin: !descriptionTextArea.validationError ? 5 : - Style.current.smallPadding
|
|
|
|
anchors.right: descriptionTextArea.right
|
|
|
|
font.pixelSize: 12
|
|
|
|
color: !descriptionTextArea.validationError ? Style.current.textColor : Style.current.danger
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: thumbnailText
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Thumbnail image"
|
|
|
|
text: qsTrId("thumbnail-image")
|
2021-03-29 12:28:41 +00:00
|
|
|
anchors.top: charLimit.bottom
|
2020-12-11 20:29:46 +00:00
|
|
|
anchors.topMargin: Style.current.smallPadding
|
2021-03-29 12:28:41 +00:00
|
|
|
font.pixelSize: 13
|
|
|
|
color: Style.current.textColor
|
|
|
|
font.weight: Font.Medium
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: addImageButton
|
|
|
|
color: imagePreview.visible ? "transparent" : Style.current.inputBackground
|
|
|
|
width: 128
|
|
|
|
height: width
|
|
|
|
radius: width / 2
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: thumbnailText.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
2021-03-29 12:28:41 +00:00
|
|
|
property string selectedImage: ""
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
|
|
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: {
|
2021-03-29 12:28:41 +00:00
|
|
|
addImageButton.selectedImage = imageDialog.fileUrls[0]
|
2021-02-10 20:37:17 +00:00
|
|
|
imageCropperModal.open()
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-29 12:28:41 +00:00
|
|
|
Rectangle {
|
|
|
|
id: imagePreviewCropper
|
|
|
|
clip: true
|
2020-12-11 20:29:46 +00:00
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
2021-03-29 12:28:41 +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
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: OpacityMask {
|
|
|
|
maskSource: Rectangle {
|
|
|
|
anchors.centerIn: parent
|
2021-03-29 12:28:41 +00:00
|
|
|
width: imageCropperModal.width
|
|
|
|
height: imageCropperModal.height
|
|
|
|
radius: width / 2
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: addImageCenter
|
|
|
|
visible: !imagePreview.visible
|
|
|
|
width: uploadText.width
|
|
|
|
height: childrenRect.height
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: imageImg
|
|
|
|
source: "../../../img/images_icon.svg"
|
|
|
|
width: 20
|
|
|
|
height: 18
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: uploadText
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Upload"
|
|
|
|
text: qsTrId("upload")
|
2020-12-11 20:29:46 +00:00
|
|
|
anchors.top: imageImg.bottom
|
|
|
|
anchors.topMargin: 5
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: Style.current.primary
|
|
|
|
width: 40
|
|
|
|
height: width
|
|
|
|
radius: width / 2
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.halfPadding
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
source: "../../../img/plusSign.svg"
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: 13
|
|
|
|
height: 13
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: imageDialog.open()
|
|
|
|
}
|
|
|
|
|
2021-02-10 20:37:17 +00:00
|
|
|
ImageCropperModal {
|
|
|
|
id: imageCropperModal
|
2021-03-29 12:28:41 +00:00
|
|
|
selectedImage: addImageButton.selectedImage
|
2021-03-05 16:23:44 +00:00
|
|
|
ratio: "1:1"
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2021-03-29 12:28:41 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
StyledText {
|
|
|
|
id: imageValidation
|
|
|
|
visible: text && text !== ""
|
|
|
|
anchors.top: addImageButton.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
color: Style.current.danger
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-03-01 19:43:50 +00:00
|
|
|
Input {
|
2021-05-24 03:09:49 +00:00
|
|
|
property string defaultColor: Style.current.blue
|
2021-03-29 12:28:41 +00:00
|
|
|
property bool isValid: true
|
2021-03-01 19:43:50 +00:00
|
|
|
|
|
|
|
id: colorPicker
|
|
|
|
label: qsTr("Community color")
|
|
|
|
placeholderText: qsTr("Pick a color")
|
2021-03-29 12:28:41 +00:00
|
|
|
anchors.top: imageValidation.bottom
|
2021-03-01 19:43:50 +00:00
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
textField.text: defaultColor
|
|
|
|
textField.onReleased: colorDialog.open()
|
|
|
|
|
2021-03-29 12:28:41 +00:00
|
|
|
onTextChanged: validate()
|
|
|
|
|
|
|
|
function resetValidation() {
|
|
|
|
isValid = true
|
|
|
|
validationError = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
function validate() {
|
|
|
|
validationError = ""
|
|
|
|
if (text === "") {
|
|
|
|
validationError = qsTr("Please enter a color")
|
|
|
|
} else if (!Utils.isHexColor(colorPicker.text)) {
|
|
|
|
validationError = qsTr("Must be an hexadecimal color (eg: #4360DF)")
|
|
|
|
}
|
|
|
|
isValid = validationError === ""
|
|
|
|
}
|
|
|
|
|
2021-03-01 19:43:50 +00:00
|
|
|
StatusIconButton {
|
|
|
|
icon.name: "caret"
|
|
|
|
iconRotation: -90
|
|
|
|
iconColor: Style.current.textColor
|
|
|
|
icon.width: 13
|
|
|
|
icon.height: 7
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: colorPicker.textField.height / 2 - height / 2 + Style.current.bigPadding
|
|
|
|
onClicked: colorDialog.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
ColorDialog {
|
|
|
|
id: colorDialog
|
|
|
|
title: qsTr("Please choose a color")
|
|
|
|
color: colorPicker.defaultColor
|
|
|
|
onAccepted: {
|
|
|
|
colorPicker.text = colorDialog.color
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-02-10 20:37:17 +00:00
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Separator {
|
|
|
|
id: separator1
|
2021-03-01 19:43:50 +00:00
|
|
|
anchors.top: colorPicker.bottom
|
2020-12-17 13:24:33 +00:00
|
|
|
anchors.topMargin: isEdit ? 0 : Style.current.bigPadding
|
2021-04-28 18:26:56 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
2020-12-17 13:24:33 +00:00
|
|
|
visible: !isEdit
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-02-10 20:37:17 +00:00
|
|
|
StatusSettingsLineButton {
|
|
|
|
id: membershipRequirementSetting
|
2021-05-24 06:27:46 +00:00
|
|
|
// TODO: remove 'isEnabled: false' when we no longer need to force
|
|
|
|
// "request access" membership
|
|
|
|
isEnabled: false
|
2020-12-11 20:29:46 +00:00
|
|
|
anchors.top: separator1.bottom
|
2021-02-10 20:37:17 +00:00
|
|
|
anchors.topMargin: Style.current.halfPadding
|
|
|
|
text: qsTr("Membership requirement")
|
|
|
|
currentValue: {
|
|
|
|
switch (membershipRequirementSettingPopup.checkedMembership) {
|
2021-05-24 03:09:49 +00:00
|
|
|
case Constants.communityChatInvitationOnlyAccess: return qsTr("Require invite from another member")
|
|
|
|
case Constants.communityChatOnRequestAccess: return qsTr("Require approval")
|
|
|
|
default: return qsTr("No requirement")
|
2021-02-10 20:37:17 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2021-02-10 20:37:17 +00:00
|
|
|
onClicked: {
|
|
|
|
membershipRequirementSettingPopup.open()
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
2020-12-17 13:24:33 +00:00
|
|
|
visible: !isEdit
|
2021-02-10 20:37:17 +00:00
|
|
|
height: visible ? implicitHeight : 0
|
2020-12-11 20:29:46 +00:00
|
|
|
id: privateExplanation
|
2021-02-10 20:37:17 +00:00
|
|
|
anchors.top: membershipRequirementSetting.bottom
|
2020-12-11 20:29:46 +00:00
|
|
|
wrapMode: Text.WordWrap
|
2021-02-10 20:37:17 +00:00
|
|
|
anchors.topMargin: isEdit ? 0 : Style.current.halfPadding
|
2021-04-28 18:15:58 +00:00
|
|
|
font.pixelSize: 13
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
width: parent.width * 0.78
|
2021-02-10 20:37:17 +00:00
|
|
|
text: qsTr("You can require new members to meet certain criteria before they can join. This can be changed at any time")
|
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-02-10 20:37:17 +00:00
|
|
|
text: qsTr("Require ENS username")
|
|
|
|
isSwitch: true
|
|
|
|
onClicked: switchChecked = checked
|
2021-03-05 17:46:02 +00:00
|
|
|
|
|
|
|
StatusToolTip {
|
|
|
|
visible: !ensOnlySwitch.isEnabled && ensMouseArea.isHovered
|
|
|
|
text: qsTr("You can only enable this setting if you have an ENS name")
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
text: qsTr("Your community requires an ENS username to be able to join")
|
|
|
|
}
|
2021-04-21 14:39:01 +00:00
|
|
|
*/
|
2021-02-10 20:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MembershipRequirementPopup {
|
|
|
|
id: membershipRequirementSettingPopup
|
2021-05-24 06:27:46 +00:00
|
|
|
// TODO: remove the 'checkedMemership' setting when we no longer need
|
|
|
|
// to force "require approval" membership
|
|
|
|
checkedMembership: Constants.communityChatOnRequestAccess
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2021-05-24 03:09:49 +00:00
|
|
|
footer: Item {
|
|
|
|
anchors.left: parent.left
|
2020-12-11 20:29:46 +00:00
|
|
|
anchors.right: parent.right
|
2021-05-24 03:09:49 +00:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
height: btnCreateEdit.height
|
|
|
|
|
|
|
|
StatusRoundButton {
|
|
|
|
id: btnBack
|
|
|
|
anchors.left: parent.left
|
|
|
|
visible: isEdit
|
|
|
|
icon.name: "arrow-right"
|
|
|
|
icon.width: 20
|
|
|
|
icon.height: 16
|
|
|
|
rotation: 180
|
|
|
|
onClicked: popup.destroy()
|
|
|
|
}
|
|
|
|
StatusButton {
|
|
|
|
id: btnCreateEdit
|
|
|
|
text: isEdit ?
|
|
|
|
//% "Save"
|
|
|
|
qsTrId("Save") :
|
|
|
|
//% "Create"
|
|
|
|
qsTrId("create")
|
|
|
|
anchors.right: parent.right
|
|
|
|
onClicked: {
|
|
|
|
if (!validate()) {
|
|
|
|
scrollView.scrollBackUp()
|
|
|
|
return
|
|
|
|
}
|
2020-12-17 13:24:33 +00:00
|
|
|
|
2021-05-24 03:09:49 +00:00
|
|
|
let error = false;
|
|
|
|
if(isEdit) {
|
|
|
|
error = chatsModel.communities.editCommunity(community.id,
|
|
|
|
Utils.filterXSS(nameInput.text),
|
|
|
|
Utils.filterXSS(descriptionTextArea.text),
|
|
|
|
membershipRequirementSettingPopup.checkedMembership,
|
|
|
|
false,
|
|
|
|
colorPicker.text,
|
|
|
|
// to retain the existing image, pass "" for the image path
|
|
|
|
addImageButton.selectedImage === community.largeImage ? "" : addImageButton.selectedImage,
|
|
|
|
imageCropperModal.aX,
|
|
|
|
imageCropperModal.aY,
|
|
|
|
imageCropperModal.bX,
|
|
|
|
imageCropperModal.bY)
|
|
|
|
} else {
|
|
|
|
error = chatsModel.communities.createCommunity(Utils.filterXSS(nameInput.text),
|
|
|
|
Utils.filterXSS(descriptionTextArea.text),
|
|
|
|
membershipRequirementSettingPopup.checkedMembership,
|
|
|
|
false, // ensOnlySwitch.switchChecked, // TODO:
|
|
|
|
colorPicker.text,
|
|
|
|
addImageButton.selectedImage,
|
|
|
|
imageCropperModal.aX,
|
|
|
|
imageCropperModal.aY,
|
|
|
|
imageCropperModal.bX,
|
|
|
|
imageCropperModal.bY)
|
|
|
|
}
|
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-05-24 03:09:49 +00:00
|
|
|
MessageDialog {
|
|
|
|
id: creatingError
|
|
|
|
//% "Error creating the community"
|
|
|
|
title: qsTrId("error-creating-the-community")
|
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|