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