chore(CommunityPermissionsView): component api unified and simplified
This commit is contained in:
parent
0af9c27910
commit
7388bbfef3
|
@ -47,8 +47,12 @@ SplitView {
|
|||
}
|
||||
}
|
||||
|
||||
onEditPermission: logs.logEvent("CommunitiesStore::editPermission - index: " + index)
|
||||
onRemovePermission: logs.logEvent("CommunitiesStore::removePermission - index: " + index)
|
||||
onEditPermissionRequested:
|
||||
logs.logEvent("CommunitiesStore::editPermission - index: " + index)
|
||||
onRemovePermissionRequested:
|
||||
logs.logEvent("CommunitiesStore::removePermission - index: " + index)
|
||||
onDuplicatePermissionRequested:
|
||||
logs.logEvent("CommunitiesStore::duplicatePermission - index: " + index)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,14 +15,14 @@ SettingsPageLayout {
|
|||
|
||||
function navigateBack() {
|
||||
if (root.state === d.newPermissionViewState) {
|
||||
root.state = d.getInitialState()
|
||||
root.state = d.initialState
|
||||
} else if(root.state === d.permissionsViewState) {
|
||||
root.state = d.newPermissionViewState
|
||||
} else if(root.state === d.editPermissionViewState) {
|
||||
if (root.dirty) {
|
||||
root.notifyDirty()
|
||||
} else {
|
||||
root.state = d.getInitialState()
|
||||
root.state = d.initialState
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,9 +52,8 @@ SettingsPageLayout {
|
|||
}
|
||||
}
|
||||
|
||||
function getInitialState() {
|
||||
return root.store.permissionsModel.count > 0 ? d.permissionsViewState : d.welcomeViewState
|
||||
}
|
||||
readonly property string initialState: root.store.permissionsModel.count > 0
|
||||
? d.permissionsViewState : d.welcomeViewState
|
||||
|
||||
function initializeData() {
|
||||
holdingsToEditModel = defaultListObject.createObject(d)
|
||||
|
@ -67,7 +66,7 @@ SettingsPageLayout {
|
|||
saveChangesButtonEnabled: true
|
||||
saveChangesText: qsTr("Update permission")
|
||||
cancelChangesText: qsTr("Revert changes")
|
||||
state: d.getInitialState()
|
||||
state: d.initialState
|
||||
states: [
|
||||
State {
|
||||
name: d.welcomeViewState
|
||||
|
@ -193,18 +192,30 @@ SettingsPageLayout {
|
|||
|
||||
Component {
|
||||
id: permissionsView
|
||||
|
||||
CommunityPermissionsView {
|
||||
viewWidth: root.viewWidth
|
||||
rootStore: root.rootStore
|
||||
store: root.store
|
||||
onEditPermission: {
|
||||
|
||||
onEditPermissionRequested: {
|
||||
const item = root.store.permissionsModel.get(index)
|
||||
|
||||
d.permissionIndexToEdit = index
|
||||
d.holdingsToEditModel = holidings
|
||||
d.permissionsToEditObject = permission
|
||||
d.channelsToEditModel = channels
|
||||
d.isPrivateToEditValue = isPrivate
|
||||
d.holdingsToEditModel = item.holdingsListModel
|
||||
d.permissionsToEditObject = item.permissionsObjectModel
|
||||
d.channelsToEditModel = item.channelsListModel
|
||||
d.isPrivateToEditValue = item.isPrivate
|
||||
root.state = d.editPermissionViewState
|
||||
}
|
||||
|
||||
onDuplicatePermissionRequested: {
|
||||
root.store.duplicatePermission(index)
|
||||
}
|
||||
|
||||
onRemovePermissionRequested: {
|
||||
root.store.removePermission(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ StatusScrollView {
|
|||
|
||||
property int viewWidth: 560 // by design
|
||||
property bool isEditState: false
|
||||
|
||||
readonly property bool dirty: {
|
||||
// Holdings:
|
||||
if (!holdingsModelComparator.equal)
|
||||
|
|
|
@ -6,7 +6,6 @@ import StatusQ.Core.Theme 0.1
|
|||
import StatusQ.Controls 0.1
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
import utils 1.0
|
||||
import shared.popups 1.0
|
||||
|
||||
import AppLayouts.Chat.controls.community 1.0
|
||||
|
@ -19,8 +18,9 @@ StatusScrollView {
|
|||
property var store
|
||||
property int viewWidth: 560 // by design
|
||||
|
||||
signal editPermission(int index, var holidings, var permission, var channels, bool isPrivate)
|
||||
signal removePermission(int index)
|
||||
signal editPermissionRequested(int index)
|
||||
signal duplicatePermissionRequested(int index)
|
||||
signal removePermissionRequested(int index)
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
@ -34,11 +34,6 @@ StatusScrollView {
|
|||
contentWidth: mainLayout.width
|
||||
contentHeight: mainLayout.height + mainLayout.anchors.topMargin
|
||||
|
||||
onRemovePermission: {
|
||||
d.permissionIndexToRemove = index
|
||||
Global.openPopup(deletePopup)
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: mainLayout
|
||||
width: root.viewWidth
|
||||
|
@ -92,27 +87,26 @@ StatusScrollView {
|
|||
? proxiedChannelsModel : communityItemModel
|
||||
isPrivate: model.isPrivate
|
||||
|
||||
onEditClicked: root.editPermission(model.index, model.holdingsListModel,
|
||||
model.permissionsObjectModel,
|
||||
model.channelsListModel, model.isPrivate)
|
||||
onEditClicked: root.editPermissionRequested(model.index)
|
||||
onDuplicateClicked: root.duplicatePermissionRequested(model.index)
|
||||
|
||||
onDuplicateClicked: store.duplicatePermission(model.index)
|
||||
onRemoveClicked: root.removePermission(model.index)
|
||||
onRemoveClicked: {
|
||||
d.permissionIndexToRemove = index
|
||||
declineAllDialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: deletePopup
|
||||
ConfirmationDialog {
|
||||
id: declineAllDialog
|
||||
header.title: qsTr("Sure you want to delete permission")
|
||||
confirmationText: qsTr("If you delete this permission, any of your community members who rely on this permission will loose the access this permission gives them.")
|
||||
onConfirmButtonClicked: {
|
||||
store.removePermission(d.permissionIndexToRemove)
|
||||
close()
|
||||
}
|
||||
ConfirmationDialog {
|
||||
id: declineAllDialog
|
||||
|
||||
header.title: qsTr("Sure you want to delete permission")
|
||||
confirmationText: qsTr("If you delete this permission, any of your community members who rely on this permission will loose the access this permission gives them.")
|
||||
|
||||
onConfirmButtonClicked: {
|
||||
root.removePermissionRequested(d.permissionIndexToRemove)
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue