In Blogsiple, workflows are enabled with the following config when
instantiating Create:
workflows: {
url: function(model) {
return "" + (model.getSubjectUri()) + "/workflow";
}
},
When I activate an item, I see a GET to /2/workflow (the object's URI
in this case is /2), with response:
[{"name":"unpublish","label":"Unpublish","action":{"type":"http","http":{"type":"PUT"},"url":"/2/unpublish"},"type":"button"},{"name":"destroy","label":"Delete","action":{"type":"backbone_destroy"},"type":"button"}]
This gives me buttons "unpublish" and "delete" in the UI.
Clicking "unpublish" makes a HTTP PUT to /2/unpublish with the entity
as contents, and also gets back the same entity, but with some
metadata changed to reflect that it has been unpublished.
Clicking Delete makes a HTTP DELETE call to the entity URI (/2).
Here is the CoffeeScript source code for implementing these:
Route returning workflows:
https://github.com/bergie/blogsiple/blob/master/lib/blogsiple.coffee#L91
Server-side publish/unpublish routes:
https://github.com/bergie/blogsiple/blob/master/lib/blogsiple.coffee#L101
Client-side config:
https://github.com/bergie/blogsiple/blob/master/lib/static/js/editable.coffee#L8
/Henri
--
Henri Bergius
Motorcycle Adventures and Free Software
http://bergie.iki.fi/
Jabber: henri....@gmail.com
Microblogs: @bergie