Fix admin edit page
This commit is contained in:
parent
57b98fd557
commit
86341e3ece
1 changed files with 29 additions and 14 deletions
|
@ -25,8 +25,33 @@ const EditPage = {
|
||||||
},
|
},
|
||||||
|
|
||||||
oninit: function(vnode) {
|
oninit: function(vnode) {
|
||||||
this.loading = m.route.param('key') !== 'add'
|
this.froala = null
|
||||||
this.creating = m.route.param('key') === 'add'
|
this.loadedFroala = Froala.loadedFroala
|
||||||
|
|
||||||
|
if (!this.loadedFroala) {
|
||||||
|
Froala.createFroalaScript()
|
||||||
|
.then(function() {
|
||||||
|
vnode.state.loadedFroala = true
|
||||||
|
m.redraw()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fetchPage(vnode)
|
||||||
|
},
|
||||||
|
|
||||||
|
onupdate: function(vnode) {
|
||||||
|
if (this.lastid !== m.route.param('id')) {
|
||||||
|
this.fetchPage(vnode)
|
||||||
|
if (this.lastid === 'add') {
|
||||||
|
m.redraw()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
fetchPage: function(vnode) {
|
||||||
|
this.lastid = m.route.param('id')
|
||||||
|
this.loading = this.lastid !== 'add'
|
||||||
|
this.creating = this.lastid === 'add'
|
||||||
this.error = ''
|
this.error = ''
|
||||||
this.page = {
|
this.page = {
|
||||||
name: '',
|
name: '',
|
||||||
|
@ -35,11 +60,9 @@ const EditPage = {
|
||||||
media: null,
|
media: null,
|
||||||
}
|
}
|
||||||
this.editedPath = false
|
this.editedPath = false
|
||||||
this.froala = null
|
|
||||||
this.loadedFroala = Froala.loadedFroala
|
|
||||||
|
|
||||||
if (m.route.param('key') !== 'add') {
|
if (this.lastid !== 'add') {
|
||||||
Page.getPage(m.route.param('key'))
|
Page.getPage(this.lastid)
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
vnode.state.editedPath = true
|
vnode.state.editedPath = true
|
||||||
vnode.state.page = result
|
vnode.state.page = result
|
||||||
|
@ -55,14 +78,6 @@ const EditPage = {
|
||||||
} else {
|
} else {
|
||||||
document.title = 'Create Page - Admin NFP Moe'
|
document.title = 'Create Page - Admin NFP Moe'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.loadedFroala) {
|
|
||||||
Froala.createFroalaScript()
|
|
||||||
.then(function() {
|
|
||||||
vnode.state.loadedFroala = true
|
|
||||||
m.redraw()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updateValue: function(name, e) {
|
updateValue: function(name, e) {
|
||||||
|
|
Loading…
Reference in a new issue