Skip to content

Commit

Permalink
fix: reject page not working
Browse files Browse the repository at this point in the history
  • Loading branch information
wonknu committed Oct 19, 2016
1 parent 9cd845d commit da00c4d
Showing 1 changed file with 55 additions and 53 deletions.
108 changes: 55 additions & 53 deletions src/cli/cms/operations/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,59 +106,61 @@ export function unpublish(filePath) {
}

export function reject(filePath, tplPath, json) {
abeExtend.hooks.instance.trigger('beforeReject', filePath)

var p = new Promise((resolve) => {
cmsOperations.save.save(
path.join(config.root, config.draft.url, filePath.replace(config.root)),
tplPath,
json,
'',
'draft',
null,
'reject')
.then(() => {
resolve()
}).catch(function(e) {
console.error(e)
})
})
var p = new Promise((resolve, reject) => {
var p1 = new Promise((resolve) => {
cmsOperations.save.save(
path.join(config.root, config.draft.url, filePath.replace(config.root)),
tplPath,
json,
'',
'draft',
null,
'reject')
.then((resSave) => {
resolve()
}).catch(function(e) {
console.error(e)
})
})

p.then((resSave) => {
cmsOperations.save.save(
path.join(config.root, config.draft.url, filePath.replace(config.root)),
tplPath,
json,
'',
'reject',
resSave,
'reject')
.then((resSave) => {
var result
if(typeof resSave.error !== 'undefined' && resSave.error !== null ){
result = {
success: 0,
error: resSave.error
}
} else if(typeof resSave.reject !== 'undefined' && resSave.reject !== null){
result = resSave
} else if(typeof resSave.json !== 'undefined' && resSave.json !== null){
result = {
success: 1,
json: resSave.json
p1.then((resSave) => {
cmsOperations.save.save(
path.join(config.root, config.draft.url, filePath.replace(config.root)),
tplPath,
json,
'',
'reject',
resSave,
'reject')
.then((resSave) => {
var result
if(typeof resSave.error !== 'undefined' && resSave.error !== null ){
result = {
success: 0,
error: resSave.error
}
} else if(typeof resSave.reject !== 'undefined' && resSave.reject !== null){
result = resSave
} else if(typeof resSave.json !== 'undefined' && resSave.json !== null){
result = {
success: 1,
json: resSave.json
}
}
}
abeExtend.hooks.instance.trigger('afterReject', result)
Manager.instance.updateList()
resolve(result)
})
}).catch(function(e) {
console.error(e)
var result = {
success: 0,
error: 'reject error'
}
abeExtend.hooks.instance.trigger('afterReject', result)
resolve(result)
})
abeExtend.hooks.instance.trigger('afterReject', result)
Manager.instance.updateList()
resolve(result)
})
}).catch(function(e) {
console.error(e)
var result = {
success: 0,
error: 'reject error'
}
abeExtend.hooks.instance.trigger('afterReject', result)
resolve(result)
})
})

return p
}

0 comments on commit da00c4d

Please sign in to comment.