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
|
implicitWidth: 0
|
||||||
title: isEditState ? qsTr("Edit permission") : qsTr("New permission")
|
title: isEditState ? qsTr("Edit permission") : qsTr("New permission")
|
||||||
|
|
||||||
property alias isDirty: editPermissionView.dirty
|
property alias isSaveEnabled: editPermissionView.saveEnabled
|
||||||
property alias isFullyFilled: editPermissionView.isFullyFilled
|
|
||||||
property alias isPrivateToEditValue: editPermissionView.isPrivate
|
property alias isPrivateToEditValue: editPermissionView.isPrivate
|
||||||
property alias permissionTypeToEdit: editPermissionView.permissionType
|
property alias permissionTypeToEdit: editPermissionView.permissionType
|
||||||
property alias holdingsToEditModel: editPermissionView.selectedHoldingsModel
|
property alias holdingsToEditModel: editPermissionView.selectedHoldingsModel
|
||||||
|
@ -186,8 +185,12 @@ StackView {
|
||||||
if (holdings.rowCount() !== 0 && !dirtyValues.holdingsRequired)
|
if (holdings.rowCount() !== 0 && !dirtyValues.holdingsRequired)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
const channelsModel = showChannelSelector ?
|
||||||
|
dirtyValues.selectedChannelsModel :
|
||||||
|
selectedChannelsModel
|
||||||
|
|
||||||
if (same(dirtyValues.selectedHoldingsModel, holdings)
|
if (same(dirtyValues.selectedHoldingsModel, holdings)
|
||||||
&& same(dirtyValues.selectedChannelsModel, channels)
|
&& same(channelsModel, channels)
|
||||||
&& dirtyValues.permissionType === permissionType)
|
&& dirtyValues.permissionType === permissionType)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -277,10 +280,7 @@ StackView {
|
||||||
saveChangesText: qsTr("Update permission")
|
saveChangesText: qsTr("Update permission")
|
||||||
cancelChangesText: qsTr("Revert changes")
|
cancelChangesText: qsTr("Revert changes")
|
||||||
|
|
||||||
saveChangesButtonEnabled:
|
saveChangesButtonEnabled: editPermissionView.saveEnabled
|
||||||
!editPermissionView.permissionDuplicated
|
|
||||||
&& !editPermissionView.permissionTypeLimitReached
|
|
||||||
&& editPermissionView.isFullyFilled
|
|
||||||
|
|
||||||
onSaveChangesClicked: {
|
onSaveChangesClicked: {
|
||||||
editPermissionView.saveChanges()
|
editPermissionView.saveChanges()
|
||||||
|
|
|
@ -784,7 +784,7 @@ StatusStackModal {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
channelToAddPermission.clear();
|
channelToAddPermission.clear();
|
||||||
channelToAddPermission.append({"key": root.chatId, "name": nameInput.text});
|
channelToAddPermission.append({"key": root.chatId, "name": nameInput.text});
|
||||||
const propertiess = {
|
const properties = {
|
||||||
channelsToEditModel: channelToAddPermission,
|
channelsToEditModel: channelToAddPermission,
|
||||||
header: null,
|
header: null,
|
||||||
topPadding: -root.subHeaderPadding - 8,
|
topPadding: -root.subHeaderPadding - 8,
|
||||||
|
@ -792,7 +792,7 @@ StatusStackModal {
|
||||||
rightPadding: 16,
|
rightPadding: 16,
|
||||||
viewWidth: scrollView.availableWidth - 32
|
viewWidth: scrollView.availableWidth - 32
|
||||||
};
|
};
|
||||||
editPermissionView.pushEditView(propertiess);
|
editPermissionView.pushEditView(properties);
|
||||||
d.currentPage = CreateChannelPopup.CurrentPage.ChannelPermissions;
|
d.currentPage = CreateChannelPopup.CurrentPage.ChannelPermissions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -896,20 +896,23 @@ StatusStackModal {
|
||||||
initialPage.topPadding: 0
|
initialPage.topPadding: 0
|
||||||
initialPage.leftPadding: 0
|
initialPage.leftPadding: 0
|
||||||
viewWidth: scrollView.availableWidth - 32
|
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
|
assetsModel: root.assetsModel
|
||||||
collectiblesModel: root.collectiblesModel
|
collectiblesModel: root.collectiblesModel
|
||||||
permissionsModel: d.channelEditModel.channelPermissionsModel
|
permissionsModel: d.channelEditModel.channelPermissionsModel
|
||||||
channelsModel: d.channelEditModel.liveChannelsModel
|
channelsModel: d.channelEditModel.liveChannelsModel
|
||||||
communityDetails: d.communityDetails
|
communityDetails: d.communityDetails
|
||||||
showChannelSelector: false
|
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 () {
|
readonly property var nextDeleteAction: function () {
|
||||||
if (!!currentItem.permissionKeyToEdit) {
|
if (!!currentItem.permissionKeyToEdit) {
|
||||||
currentItem.resetChanges();
|
currentItem.resetChanges();
|
||||||
|
|
|
@ -26,6 +26,10 @@ StatusScrollView {
|
||||||
// id, name, image, color, owner properties expected
|
// id, name, image, color, owner properties expected
|
||||||
required property var communityDetails
|
required property var communityDetails
|
||||||
|
|
||||||
|
readonly property bool saveEnabled: root.isFullyFilled
|
||||||
|
&& !root.permissionDuplicated
|
||||||
|
&& !root.permissionTypeLimitReached
|
||||||
|
|
||||||
property int viewWidth: 560 // by design
|
property int viewWidth: 560 // by design
|
||||||
property bool isEditState: false
|
property bool isEditState: false
|
||||||
|
|
||||||
|
@ -619,9 +623,7 @@ StatusScrollView {
|
||||||
|
|
||||||
visible: !root.isEditState && root.showChannelSelector
|
visible: !root.isEditState && root.showChannelSelector
|
||||||
text: qsTr("Create permission")
|
text: qsTr("Create permission")
|
||||||
enabled: root.isFullyFilled
|
enabled: root.saveEnabled
|
||||||
&& !root.permissionDuplicated
|
|
||||||
&& !root.permissionTypeLimitReached
|
|
||||||
|
|
||||||
onClicked: root.createPermissionClicked()
|
onClicked: root.createPermissionClicked()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue