|
|
|
@ -10,6 +10,8 @@ export class PageActions extends HTMLElement { |
|
|
|
), |
|
|
|
cancel: 'Cancel', |
|
|
|
alreadyExists: 'There is already a page with that name.', |
|
|
|
save: 'Guardar', |
|
|
|
close: 'Close', |
|
|
|
} |
|
|
|
|
|
|
|
textEs = { |
|
|
|
@ -23,6 +25,8 @@ export class PageActions extends HTMLElement { |
|
|
|
), |
|
|
|
cancel: 'Cancelar', |
|
|
|
alreadyExists: 'Ya existe una página con ese nombre.', |
|
|
|
save: 'Guardar', |
|
|
|
close: 'Cerrar', |
|
|
|
} |
|
|
|
|
|
|
|
constructor() { |
|
|
|
@ -31,7 +35,20 @@ export class PageActions extends HTMLElement { |
|
|
|
this.language = navigator.language |
|
|
|
this.dialogWrap = document.createElement('div') |
|
|
|
this.shadowRoot.append(this.dialogWrap) |
|
|
|
this.menuActions = [ |
|
|
|
} |
|
|
|
|
|
|
|
connectedCallback() { |
|
|
|
const style = document.createElement('style') |
|
|
|
style.textContent = ` |
|
|
|
m-dialog::part(footer) { |
|
|
|
padding-top: 15px; |
|
|
|
} |
|
|
|
` |
|
|
|
this.shadowRoot.appendChild(style) |
|
|
|
} |
|
|
|
|
|
|
|
get menuActions() { |
|
|
|
const baseActions = [ |
|
|
|
{ |
|
|
|
text: this.text.download, |
|
|
|
click: this.download.bind(this), |
|
|
|
@ -48,20 +65,18 @@ export class PageActions extends HTMLElement { |
|
|
|
text: this.text.delete_, |
|
|
|
click: this.delete_.bind(this), |
|
|
|
}, |
|
|
|
//{
|
|
|
|
// text: this.text.settings,
|
|
|
|
// click: this.settings.bind(this),
|
|
|
|
//},
|
|
|
|
] |
|
|
|
} |
|
|
|
connectedCallback() { |
|
|
|
const style = document.createElement('style') |
|
|
|
style.textContent = ` |
|
|
|
m-dialog::part(footer) { |
|
|
|
padding-top: 15px; |
|
|
|
} |
|
|
|
` |
|
|
|
this.shadowRoot.appendChild(style) |
|
|
|
if (this.page.isGroup) { |
|
|
|
return [ |
|
|
|
...baseActions, |
|
|
|
{ |
|
|
|
text: this.text.settings, |
|
|
|
click: this.settings.bind(this), |
|
|
|
}, |
|
|
|
] |
|
|
|
} else { |
|
|
|
return baseActions |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
download() { |
|
|
|
@ -111,7 +126,14 @@ export class PageActions extends HTMLElement { |
|
|
|
newPath, |
|
|
|
localStorage.getItem(this.path) |
|
|
|
) |
|
|
|
localStorage.setItem( |
|
|
|
'settings/page:' + newPath, |
|
|
|
localStorage.getItem(this.path) |
|
|
|
) |
|
|
|
localStorage.removeItem(this.path) |
|
|
|
localStorage.removeItem( |
|
|
|
'settings/page:' + newPath, |
|
|
|
) |
|
|
|
dialog.close() |
|
|
|
location.hash = newPath |
|
|
|
}) |
|
|
|
@ -153,6 +175,10 @@ export class PageActions extends HTMLElement { |
|
|
|
newPath, |
|
|
|
localStorage.getItem(this.path) |
|
|
|
) |
|
|
|
localStorage.setItem( |
|
|
|
'settings/page:' + newPath, |
|
|
|
localStorage.getItem(this.path) ?? '{}' |
|
|
|
) |
|
|
|
dialog.close() |
|
|
|
location.hash = newPath |
|
|
|
}) |
|
|
|
@ -179,6 +205,9 @@ export class PageActions extends HTMLElement { |
|
|
|
) |
|
|
|
bGroup.addPrimary(this.text.delete_, () => { |
|
|
|
localStorage.removeItem(this.path) |
|
|
|
localStorage.removeItem( |
|
|
|
'settings/page:' + this.path |
|
|
|
) |
|
|
|
location.hash = '/' |
|
|
|
dialog.close() |
|
|
|
}) |
|
|
|
@ -194,34 +223,21 @@ export class PageActions extends HTMLElement { |
|
|
|
'm-dialog' |
|
|
|
) |
|
|
|
this.dialogWrap.replaceChildren(dialog) |
|
|
|
const input = document.createElement('input') |
|
|
|
input.value = this.path |
|
|
|
input.style.minWidth = '300px' |
|
|
|
dialog.bodyEl.appendChild(input) |
|
|
|
let errorEl |
|
|
|
const settingsEl = document.createElement( |
|
|
|
'm-settings-page-settings' |
|
|
|
) |
|
|
|
settingsEl.cspProfiles = this.cspProfiles |
|
|
|
settingsEl.data = this.page.settings |
|
|
|
dialog.bodyEl.appendChild(settingsEl) |
|
|
|
const bGroup = document.createElement( |
|
|
|
'm-forms-button-group' |
|
|
|
) |
|
|
|
bGroup.addPrimary(this.text.rename, () => { |
|
|
|
const newPath = input.value |
|
|
|
const v = localStorage.getItem(newPath) |
|
|
|
if (v !== null || newPath === this.path) { |
|
|
|
if (!errorEl) { |
|
|
|
errorEl = document.createElement('p') |
|
|
|
errorEl.style.color = 'red' |
|
|
|
const errText = this.text.alreadyExists |
|
|
|
errorEl.innerText = errText |
|
|
|
dialog.bodyEl.appendChild(errorEl) |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
localStorage.setItem( |
|
|
|
newPath, |
|
|
|
localStorage.getItem(this.path) |
|
|
|
) |
|
|
|
localStorage.removeItem(this.path) |
|
|
|
bGroup.addPrimary(this.text.save, () => { |
|
|
|
this.page.settings = settingsEl.data |
|
|
|
dialog.close() |
|
|
|
location.hash = newPath |
|
|
|
this.dispatchEvent(new CustomEvent( |
|
|
|
'settings-change', {bubbles: true, composed: true} |
|
|
|
)) |
|
|
|
}) |
|
|
|
bGroup.addCancel(this.text.cancel, () => { |
|
|
|
dialog.close() |
|
|
|
|