apply inverse connections

main
bat 3 years ago
parent 9c67f0c741
commit 03885398c5

@ -237,7 +237,16 @@ export class PageActions extends HTMLElement {
'm-forms-button-group' 'm-forms-button-group'
) )
bGroup.addPrimary(this.text.save, () => { bGroup.addPrimary(this.text.save, () => {
this.page.settings = settingsEl.data const settingsData = settingsEl.data
this.page.settings = settingsData
for (const dir of ['outbound', 'inbound']) {
const otherDir = (
dir === 'outbound' ? 'inbound' : 'outbound'
)
this.applyInverseSettings(
settingsData, dir, otherDir
)
}
dialog.close() dialog.close()
this.dispatchEvent(new CustomEvent( this.dispatchEvent(new CustomEvent(
'settings-change', {bubbles: true, composed: true} 'settings-change', {bubbles: true, composed: true}
@ -250,6 +259,32 @@ export class PageActions extends HTMLElement {
dialog.open() dialog.open()
} }
applyInverseSettings(settingsData, dir, otherDir) {
const selfEntries = Object.entries(
settingsData.connections[dir]
)
for (const [path, access] of selfEntries) {
const key = 'settings/page:' + path
let val = localStorage.getItem(key)
try {
if (val !== null) {
val = JSON.parse(val)
}
} catch (err) {
// ignore
}
const data = val ?? {}
data.connections = data.connections ?? {}
data.connections[otherDir] = (
data.connections[otherDir] ?? {}
)
data.connections[otherDir][this.path] = access
localStorage.setItem(
key, JSON.stringify(data)
)
}
}
get language() { get language() {
return this._language return this._language
} }

Loading…
Cancel
Save