fix(ChannelPermissions): Fixing duplicate permission detection and save button state
The duplicate permission detection was not working because the channel selection cannot be dirty when the channel selector is disabled.
This commit is contained in:
parent
b891243ad8
commit
87d3dcb113
|
@ -118,8 +118,7 @@ StackView {
|
|||
implicitWidth: 0
|
||||
title: isEditState ? qsTr("Edit permission") : qsTr("New permission")
|
||||
|
||||
property alias isDirty: editPermissionView.dirty
|
||||
property alias isFullyFilled: editPermissionView.isFullyFilled
|
||||
property alias isSaveEnabled: editPermissionView.saveEnabled
|
||||
property alias isPrivateToEditValue: editPermissionView.isPrivate
|
||||
property alias permissionTypeToEdit: editPermissionView.permissionType
|
||||
property alias holdingsToEditModel: editPermissionView.selectedHoldingsModel
|
||||
|
@ -186,8 +185,12 @@ StackView {
|
|||
if (holdings.rowCount() !== 0 && !dirtyValues.holdingsRequired)
|
||||
continue
|
||||
|
||||
const channelsModel = showChannelSelector ?
|
||||
dirtyValues.selectedChannelsModel :
|
||||
selectedChannelsModel
|
||||
|
||||
if (same(dirtyValues.selectedHoldingsModel, holdings)
|
||||
&& same(dirtyValues.selectedChannelsModel, channels)
|
||||
&& same(channelsModel, channels)
|
||||
&& dirtyValues.permissionType === permissionType)
|
||||
return true
|
||||
}
|
||||
|
@ -277,10 +280,7 @@ StackView {
|
|||
saveChangesText: qsTr("Update permission")
|
||||
cancelChangesText: qsTr("Revert changes")
|
||||
|
||||
saveChangesButtonEnabled:
|
||||
!editPermissionView.permissionDuplicated
|
||||
&& !editPermissionView.permissionTypeLimitReached
|
||||
&& editPermissionView.isFullyFilled
|
||||
saveChangesButtonEnabled: editPermissionView.saveEnabled
|
||||
|
||||
onSaveChangesClicked: {
|
||||
editPermissionView.saveChanges()
|
||||
|
|
|
@ -784,7 +784,7 @@ StatusStackModal {
|
|||
onClicked: {
|
||||
channelToAddPermission.clear();
|
||||
channelToAddPermission.append({"key": root.chatId, "name": nameInput.text});
|
||||
const propertiess = {
|
||||
const properties = {
|
||||
channelsToEditModel: channelToAddPermission,
|
||||
header: null,
|
||||
topPadding: -root.subHeaderPadding - 8,
|
||||
|
@ -792,7 +792,7 @@ StatusStackModal {
|
|||
rightPadding: 16,
|
||||
viewWidth: scrollView.availableWidth - 32
|
||||
};
|
||||
editPermissionView.pushEditView(propertiess);
|
||||
editPermissionView.pushEditView(properties);
|
||||
d.currentPage = CreateChannelPopup.CurrentPage.ChannelPermissions;
|
||||
}
|
||||
}
|
||||
|
@ -896,20 +896,23 @@ StatusStackModal {
|
|||
initialPage.topPadding: 0
|
||||
initialPage.leftPadding: 0
|
||||
viewWidth: scrollView.availableWidth - 32
|
||||
readonly property string nextButtonText: !!currentItem.permissionKeyToEdit ?
|
||||
qsTr("Update permission") : qsTr("Create permission")
|
||||
readonly property string stackTitleText: !!currentItem.permissionKeyToEdit ?
|
||||
qsTr("Edit #%1 permission").arg(nameInput.text) : qsTr("New #%1 permission").arg(nameInput.text)
|
||||
readonly property string deleteButtonText: !!currentItem.permissionKeyToEdit ?
|
||||
qsTr("Revert changes") : ""
|
||||
readonly property bool canGoNext: !!currentItem && currentItem.isDirty && currentItem.isFullyFilled ? currentItem.isDirty && currentItem.isFullyFilled : false
|
||||
readonly property bool deleteButtonEnabled: editPermissionView.canGoNext
|
||||
assetsModel: root.assetsModel
|
||||
collectiblesModel: root.collectiblesModel
|
||||
permissionsModel: d.channelEditModel.channelPermissionsModel
|
||||
channelsModel: d.channelEditModel.liveChannelsModel
|
||||
communityDetails: d.communityDetails
|
||||
showChannelSelector: false
|
||||
|
||||
readonly property string nextButtonText: !!currentItem.permissionKeyToEdit ?
|
||||
qsTr("Update permission") : qsTr("Create permission")
|
||||
readonly property string stackTitleText: !!currentItem.permissionKeyToEdit ?
|
||||
qsTr("Edit #%1 permission").arg(nameInput.text) : qsTr("New #%1 permission").arg(nameInput.text)
|
||||
readonly property string deleteButtonText: !!currentItem.permissionKeyToEdit ?
|
||||
qsTr("Revert changes") : ""
|
||||
readonly property bool canGoNext: !!currentItem && !!currentItem.isSaveEnabled ? currentItem.isSaveEnabled : false
|
||||
|
||||
readonly property bool deleteButtonEnabled: editPermissionView.canGoNext
|
||||
|
||||
readonly property var nextDeleteAction: function () {
|
||||
if (!!currentItem.permissionKeyToEdit) {
|
||||
currentItem.resetChanges();
|
||||
|
|
|
@ -26,6 +26,10 @@ StatusScrollView {
|
|||
// id, name, image, color, owner properties expected
|
||||
required property var communityDetails
|
||||
|
||||
readonly property bool saveEnabled: root.isFullyFilled
|
||||
&& !root.permissionDuplicated
|
||||
&& !root.permissionTypeLimitReached
|
||||
|
||||
property int viewWidth: 560 // by design
|
||||
property bool isEditState: false
|
||||
|
||||
|
@ -619,9 +623,7 @@ StatusScrollView {
|
|||
|
||||
visible: !root.isEditState && root.showChannelSelector
|
||||
text: qsTr("Create permission")
|
||||
enabled: root.isFullyFilled
|
||||
&& !root.permissionDuplicated
|
||||
&& !root.permissionTypeLimitReached
|
||||
enabled: root.saveEnabled
|
||||
|
||||
onClicked: root.createPermissionClicked()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue