Using Workflows

58 views
Skip to first unread message

floegel

unread,
Feb 25, 2012, 5:24:10 AM2/25/12
to CreateJS
Hello,

i'm currently trying to implement createJS for a project i'm working
on and have come to an issue i can't find a solution for: I want to
use Workflows (just be able to delete items that have been added to a
collection). It is mentioned how to provide a backend url (https://
github.com/bergie/create). However, it is not mentioned what the
backend should return and how to progress from there on. Console says
"error fetching flows".. it would be great to see a simple workflow
example in action.

Greets

Henri Bergius

unread,
Feb 27, 2012, 4:27:26 AM2/27/12
to crea...@googlegroups.com
Hi,

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

Reply all
Reply to author
Forward
0 new messages