|
|
@ -309,14 +309,31 @@ export class Header extends HTMLElement { |
|
|
const input = document.createElement('input') |
|
|
const input = document.createElement('input') |
|
|
input.value = '/' |
|
|
input.value = '/' |
|
|
input.style.minWidth = '300px' |
|
|
input.style.minWidth = '300px' |
|
|
dialog.bodyEl.appendChi |
|
|
dialog.bodyEl.appendChild(input) |
|
|
|
|
|
let errorEl |
|
|
const bGroup = document.createElement( |
|
|
const bGroup = document.createElement( |
|
|
'm-forms-button-group' |
|
|
'm-forms-button-group' |
|
|
) |
|
|
) |
|
|
bGroup.addPrimary(this.text.createPage, () => { |
|
|
bGroup.addPrimary(this.text.createPage, () => { |
|
|
const newPath = this.encodePath(input.value) |
|
|
const newPath = this.encodePath(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(newPath, '') |
|
|
location.hash = newPath |
|
|
location.hash = newPath |
|
|
dialog.close() |
|
|
dialog.close() |
|
|
|
|
|
this.dispatchEvent(new CustomEvent( |
|
|
|
|
|
'create-page', {bubbles: true} |
|
|
|
|
|
)) |
|
|
}) |
|
|
}) |
|
|
bGroup.addCancel(this.text.cancel, () => { |
|
|
bGroup.addCancel(this.text.cancel, () => { |
|
|
dialog.close() |
|
|
dialog.close() |
|
|
|