fix(CommunityPermissions): Adjust store API to not take models as parameters, move conversion to the caller
Closes: #9611
This commit is contained in:
parent
34676d0ec7
commit
9693e19ba5
|
@ -196,10 +196,18 @@ SettingsPageLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
onCreatePermissionClicked: {
|
onCreatePermissionClicked: {
|
||||||
root.store.createPermission(dirtyValues.holdingsModel,
|
const holdings = ModelUtils.modelToArray(
|
||||||
|
dirtyValues.holdingsModel,
|
||||||
|
["key", "type", "amount"])
|
||||||
|
|
||||||
|
const channels = ModelUtils.modelToArray(
|
||||||
|
dirtyValues.channelsModel,
|
||||||
|
["itemId", "text", "emoji", "color"])
|
||||||
|
|
||||||
|
root.store.createPermission(holdings,
|
||||||
dirtyValues.permissionType,
|
dirtyValues.permissionType,
|
||||||
dirtyValues.isPrivate,
|
dirtyValues.isPrivate,
|
||||||
dirtyValues.channelsModel)
|
channels)
|
||||||
|
|
||||||
root.state = d.permissionsViewState
|
root.state = d.permissionsViewState
|
||||||
}
|
}
|
||||||
|
@ -208,11 +216,19 @@ SettingsPageLayout {
|
||||||
target: d
|
target: d
|
||||||
|
|
||||||
function onSaveChanges() {
|
function onSaveChanges() {
|
||||||
|
const holdings = ModelUtils.modelToArray(
|
||||||
|
dirtyValues.holdingsModel,
|
||||||
|
["key", "type", "amount"])
|
||||||
|
|
||||||
|
const channels = ModelUtils.modelToArray(
|
||||||
|
dirtyValues.channelsModel,
|
||||||
|
["itemId", "text", "emoji", "color"])
|
||||||
|
|
||||||
root.store.editPermission(
|
root.store.editPermission(
|
||||||
d.permissionKeyToEdit,
|
d.permissionKeyToEdit,
|
||||||
dirtyValues.holdingsModel,
|
holdings,
|
||||||
dirtyValues.permissionType,
|
dirtyValues.permissionType,
|
||||||
dirtyValues.channelsModel,
|
channels,
|
||||||
dirtyValues.isPrivate)
|
dirtyValues.isPrivate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,35 +140,12 @@ QtObject {
|
||||||
|
|
||||||
function createPermissionEntry(holdings, permissionType, isPrivate, channels) {
|
function createPermissionEntry(holdings, permissionType, isPrivate, channels) {
|
||||||
const permission = {
|
const permission = {
|
||||||
holdingsListModel: [],
|
holdingsListModel: holdings,
|
||||||
channelsListModel: [],
|
channelsListModel: channels,
|
||||||
permissionType,
|
permissionType,
|
||||||
isPrivate
|
isPrivate
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting HOLDINGS:
|
|
||||||
for (let i = 0; i < holdings.count; i++ ) {
|
|
||||||
const entry = holdings.get(i)
|
|
||||||
|
|
||||||
permission.holdingsListModel.push({
|
|
||||||
type: entry.type,
|
|
||||||
key: entry.key,
|
|
||||||
amount: entry.amount
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setting CHANNELS:
|
|
||||||
for (let c = 0; c < channels.count; c++) {
|
|
||||||
const entry = channels.get(c)
|
|
||||||
|
|
||||||
permission.channelsListModel.push({
|
|
||||||
itemId: entry.itemId,
|
|
||||||
text: entry.text,
|
|
||||||
emoji: entry.emoji,
|
|
||||||
color: entry.color
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return permission
|
return permission
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue