Merge pull request 'Add duplicate' (#49) from duplicate into main

Reviewed-on: https://codeberg.org/macchiato/pages/pulls/49
page-actions
bat 3 years ago
commit 0abc623a00

@ -21,6 +21,7 @@ export class Header extends HTMLElement {
textEn = {
download: 'Download',
rename: 'Move/Rename',
duplicate: 'Duplicate',
delete: 'Delete',
confirmDelete: f => (
`Are you sure you want to delete ${f}?`
@ -36,6 +37,7 @@ export class Header extends HTMLElement {
textEs = {
download: 'Descargar',
rename: 'Mover/Renombrar',
duplicate: 'Duplicar',
delete: 'Borrar',
confirmDelete: f => (
`¿Desea borrar ${f}?`
@ -253,6 +255,45 @@ export class Header extends HTMLElement {
dialog.footerEl.appendChild(bGroup)
dialog.open()
})
this.pageMenu.add(this.text.duplicate, () => {
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.duplicate, () => {
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)
)
dialog.close()
location.hash = newPath
})
bGroup.addCancel(this.text.cancel, () => {
dialog.close()
})
dialog.footerEl.appendChild(bGroup)
dialog.open()
})
this.pageMenu.add(this.text.delete, () => {
const dialog = document.createElement(
'm-dialog'

@ -17,7 +17,7 @@ async function initCache() {
'/loader/builder.js',
'/loader/editor-build.js',
'/menu/dropdown.js',
]) //2
]) //3
}
self.addEventListener("install", event => {

Loading…
Cancel
Save