|
|
@ -1,9 +1,10 @@ |
|
|
export class PageActions { |
|
|
export class PageActions extends HTMLElement { |
|
|
textEn = { |
|
|
textEn = { |
|
|
download: 'Download', |
|
|
download: 'Download', |
|
|
rename: 'Move/Rename', |
|
|
rename: 'Move/Rename', |
|
|
duplicate: 'Duplicate', |
|
|
duplicate: 'Duplicate', |
|
|
delete_: 'Delete', |
|
|
delete_: 'Delete', |
|
|
|
|
|
settings: 'Settings', |
|
|
confirmDelete: f => ( |
|
|
confirmDelete: f => ( |
|
|
`Are you sure you want to delete ${f}?` |
|
|
`Are you sure you want to delete ${f}?` |
|
|
), |
|
|
), |
|
|
@ -16,6 +17,7 @@ export class PageActions { |
|
|
rename: 'Mover/Renombrar', |
|
|
rename: 'Mover/Renombrar', |
|
|
duplicate: 'Duplicar', |
|
|
duplicate: 'Duplicar', |
|
|
delete_: 'Borrar', |
|
|
delete_: 'Borrar', |
|
|
|
|
|
settings: 'Configuración', |
|
|
confirmDelete: f => ( |
|
|
confirmDelete: f => ( |
|
|
`¿Desea borrar ${f}?` |
|
|
`¿Desea borrar ${f}?` |
|
|
), |
|
|
), |
|
|
@ -24,7 +26,11 @@ export class PageActions { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
constructor() { |
|
|
constructor() { |
|
|
|
|
|
super() |
|
|
|
|
|
this.attachShadow({mode: 'open'}) |
|
|
this.language = navigator.language |
|
|
this.language = navigator.language |
|
|
|
|
|
this.dialogWrap = document.createElement('div') |
|
|
|
|
|
this.shadowRoot.append(this.dialogWrap) |
|
|
this.menuActions = [ |
|
|
this.menuActions = [ |
|
|
{ |
|
|
{ |
|
|
text: this.text.download, |
|
|
text: this.text.download, |
|
|
@ -42,8 +48,21 @@ export class PageActions { |
|
|
text: this.text.delete_, |
|
|
text: this.text.delete_, |
|
|
click: this.delete_.bind(this), |
|
|
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) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
download() { |
|
|
download() { |
|
|
const text = localStorage.getItem(this.path) |
|
|
const text = localStorage.getItem(this.path) |
|
|
@ -170,6 +189,47 @@ export class PageActions { |
|
|
dialog.open() |
|
|
dialog.open() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
settings() { |
|
|
|
|
|
const dialog = document.createElement( |
|
|
|
|
|
'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 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) |
|
|
|
|
|
dialog.close() |
|
|
|
|
|
location.hash = newPath |
|
|
|
|
|
}) |
|
|
|
|
|
bGroup.addCancel(this.text.cancel, () => { |
|
|
|
|
|
dialog.close() |
|
|
|
|
|
}) |
|
|
|
|
|
dialog.footerEl.appendChild(bGroup) |
|
|
|
|
|
dialog.open() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
get language() { |
|
|
get language() { |
|
|
return this._language |
|
|
return this._language |
|
|
} |
|
|
} |
|
|
|