Skip to content

Commit

Permalink
enhancement: add list-workflow with better explanation + bug url unpu…
Browse files Browse the repository at this point in the history
…blish
  • Loading branch information
nicolaslabbe committed Dec 2, 2016
1 parent 24ac7ab commit 867b966
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
28 changes: 23 additions & 5 deletions src/server/routes/get-list-workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,33 @@ var route = function(router, req, res, next) {
}

var workflowUrl = {}
var previous = ""
var next = ""
Array.prototype.forEach.call(config.users.workflow, (flow) => {
var current = false
if (flow != 'publish') {
Array.prototype.forEach.call(config.users.workflow, (flowCheck) => {
if (current) {
next = flowCheck
current = false
}
if (flow === flowCheck) {
current = true
}
})
}else {
next = "draft"
}
workflowUrl[flow] = [
{url: `/abe/operations/edit/${flow}`, action: 'edit', workflow: flow},
{url: `/abe/operations/delete/${flow}`, action: 'delete', workflow: flow}
{url: `/abe/operations/edit/${flow}`, action: 'edit', workflow: flow, previous: previous, next: next},
{url: `/abe/operations/delete/${flow}`, action: 'delete', workflow: flow, previous: previous, next: next},
{url: `/abe/operations/submit/${flow}`, action: 'submit', workflow: flow, previous: previous, next: next}
]
if (flow != 'publish') {
workflowUrl[flow].push({url: `/abe/operations/reject/${flow}`, action: 'reject', workflow: flow})
workflowUrl[flow].push({url: `/abe/operations/submit/${flow}`, action: 'submit', workflow: flow})

if (flow !== 'draft') {
workflowUrl[flow].push({url: `/abe/operations/reject/${flow}`, action: 'reject', workflow: flow, previous: previous, next: next})
}
previous = flow
})
var template = Handlebars.compile(html, {noEscape: true})
var tmp = template({
Expand Down
6 changes: 3 additions & 3 deletions src/server/routes/operations/get/unpublish.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ var route = function(req, res, next){
abeExtend.hooks.instance.trigger('beforeRoute', req, res, next)
if(typeof res._header !== 'undefined' && res._header !== null) return

var operation = req.originalUrl.replace(/\/abe\/operations\/unpublish\//, '')
var postUrl = req.originalUrl.replace(/\/abe\/operations\/unpublish\//, '')

cmsOperations.post.unpublish(operation.postUrl)
cmsOperations.post.unpublish(postUrl)

var result = {
success: 1,
file: operation.postUrl
file: postUrl
}
res.set('Content-Type', 'application/json')
res.send(JSON.stringify(result))
Expand Down
14 changes: 12 additions & 2 deletions src/server/views/list-workflow.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,19 @@
<div class="workflow-title">{{@key}} :</div>
{{#each this}}
{{#isAuthorized this.url ../../workflow}}
<div class="workflow-actif">{{this.action}}</div>
<div class="workflow-actif">
{{this.action}}
{{#ifCond this.action "edit"}} in <b>{{this.workflow}}</b>{{/ifCond}}
{{#ifCond this.action "reject"}} to <b>{{this.previous}}</b> status{{/ifCond}}
{{#ifCond this.action "submit"}} to <b>{{next}}</b> status{{/ifCond}}
</div>
{{else}}
<div class="workflow-inactif">{{this.action}}</div>
<div class="workflow-inactif">
{{this.action}}
{{#ifCond this.action "edit"}} in <b>{{this.workflow}}</b>{{/ifCond}}
{{#ifCond this.action "reject"}} to <b>{{this.previous}}</b> status{{/ifCond}}
{{#ifCond this.action "submit"}} to <b>{{next}}</b> status{{/ifCond}}
</div>
{{/isAuthorized}}
{{/each}}

Expand Down

0 comments on commit 867b966

Please sign in to comment.