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