orbeon / orbeon-forms

Orbeon Forms is an open source web forms solution. It includes an XForms engine, the Form Builder web-based form editor, and the Form Runner runtime.
http://www.orbeon.com/
GNU Lesser General Public License v2.1
513 stars 220 forks source link

Basic Workflow: support for "stage" #2256

Open avernet opened 9 years ago

avernet commented 9 years ago

Related issues

Use case

In a small business, anyone with the role employee can submit an expense report by filling out a form. After it has been submitted, the employee who created the expense report can can see but not edit the data (but other employees can't see the data), and anyone with the role manager can either approve or reject it.

New concept: stage

Overview

Out of the box, we'll have 2 stages: started (the default), and submitted. Our submit process will change the workflow stage to submitted, which will allow us to make a distinction in the database between form data that has been just saved, but hasn't been submitted yet, and data that has been submitted.

workflow stages

Available to

The Available to section shows in the Operations tab of the Workflow dialog. Its purpose is to allow form authors to whom a given operation is available, e.g. based on the user's authentication role or the workflow stage.

Design - WF - Available to

Pre-defined operations

Design - WF - Op - Create

Design - WF - Op - View

Design - WF - Op - Delete

Custom operations

Design - WF - Op - Submit

Design - WF - Op - Save

Design - WF - Op - Approve

Implementation

Kevinhebertd commented 8 years ago

Looking forward to this. Keep it up

ebruchez commented 8 years ago

@Kevinhebertd We are working on it :)

ebruchez commented 8 years ago

We have done quite a bit of progress on the UI. Remaining steps:

Kevinhebertd commented 8 years ago

Do you have an updated release date for 4.11 ?? :smiley:

ebruchez commented 8 years ago

It's not going to be in 2015, that's for sure. Shooting for sometime Q1 2016.

ebruchez commented 8 years ago

UPDATE: We have progressed on this until the end of 2015, but then decided that 2016.1 (AKA 4.11) would focus instead a number of features and fixes for customers. For 2016.2, we have decided to focus on one Form Builder usability feature.

Still, there was some work done:

When we pick this up, we should focus on addressing #2762 first.

ebruchez commented 7 years ago

2016-09-26: RESOLUTION: For now we write our workflow configuration UI with XForms, with the following thoughts:

ebruchez commented 7 years ago

Tasks:

ebruchez commented 7 years ago

Initial UI is in! Here is a screenshot.

screen shot 2016-11-11 at 4 29 09 pm

ebruchez commented 7 years ago

The UI is done but there is quite a lot left to do in the backend and that won't make it for 2016.3. Moving to 2017.1.

ebruchez commented 7 years ago

For 2016.3, we will just disable the "Workflow and Permissions" toolbox button.

ebruchez commented 7 years ago

Remaining UI tasks:

ebruchez commented 7 years ago

With the current permissions settings, the picture is pretty clear: CRUD operations are enabled to a user depending on:

The basic workflow adds to this:

Now at the persistence layer permission must be known in terms of CRUD. So the idea was to generate, from a workflow configuration, a permissions configuration which can be used at the lower level.

The idea was that the update operation would be inferred from the actions, specifically processes, associated with the operation. If the button associated with the operation runs a "Save" process, then we infer update. How? Probably by looking at the process definition in the properties?

One issue with that is that:

So we need to decide how to make this as clear as possible.

Possibly, we could infer the update permission depending on the process, but show it as a checkbox. This would clarify to the form author that the permission is set or not. Then the user could override the update permission with that checkbox (or other).

ebruchez commented 7 years ago

Also noting that we want to infer read permissions for any update permission.

Discussion with @avernet, we think this is ok. We make it clear to the user what the update and read permissions are in the UI at least.

Also, the idea for the persistence layer is to have enhanced permissions check:

avernet commented 7 years ago

Our existing format for permissions is restricted to 2-level expressions that looks like (… AND … AND…) OR (… AND … AND…) OR…. This is enough as any multi-level expression can be flattened into 2-levels. For instance:

  a OR (b AND (c OR (d AND e)))
⇔ a OR (b AND c) OR (b AND d AND e)

We'll leave the proof thereof to the reader. However, the current format does not support subtractive rules, i.e. it doesn't support NOT. We could expand it to have a 3rd level for NOT, which would allow us to rewrite any expression to the 3 levels OR / AND / NOT, in that order. For instance:

  a OR (b AND NOT (NOT c OR (d AND NOT e)))
⇔ a OR (b AND (c AND NOT (d AND NOT e)))
⇔ a OR (b AND (c AND (NOT d OR e)))
⇔ a OR (b AND c AND (NOT d OR e))
⇔ a OR (b AND c AND NOT d) OR (b AND c AND e)

With this in mind, we can either:

  1. Add a 3rd level to the permission format, and write code converting the workflow to the permissions format, as illustrated above.
  2. Expand the permission format to allow any combination and AND, OR, and NOT.

The second option would make the conversion from the workflow format to the permissions format much simpler, but makes other algorithms more complex, e.g. to determine if a user has a access to a certain operation only based on their role. With this, my current preference is for option 2.

avernet commented 7 years ago

The pre-defined operations we have in the dialog ("Create", "View", and "Delete"), correspond to built-in operations available from the Form Builder summary page. We drive other pre-defined operations from those 3, e.g. View ⇒ PDF, Create + View ⇒ Duplicate.

Now, say we have a duplicate process (once #1874 is implemented), and users define a custom operation that runs the duplicate process. Per the logic we use for Update, if users can run a operation that runs a process (duplicate) that requires Create and View, they should have the permission to Create and View. But:

It seems to me that we're having those problems because we try to reduce the permissions to run increasingly more complex operations (and even, with processes, arbitrarily complex operations), to 4 booleans Create-Read-Update-Delete. And for built-in operations, like Duplicate, PDF, and maybe more in the future, we're trying to go from a combination of the 4 booleans to the operation itself.

This is not unlike a web app with complex permissions trying to also enforce permissions at the database level, mapping application-level permissions to a coarser database-level permissions, which in general isn't being done.

I suggest we should:

This would have the following:

Concretely, we would:

avernet commented 7 years ago

For the purpose of this discussion, let's assume we go for the change suggested in the previous comment. I have 3 questions relative to the operations:

  1. What operations should be there by default?
  2. Do we really need to have special operations that are always there, and that users can't remove?
  3. Is it reasonable to conflate special operations with "their" button?

To the first question:

To the second question:

To the third question:

ebruchez commented 7 years ago

Edit doesn't have the checkbox "Show button on detail page".

What if you are on the review page, and want to go back to edit?

avernet commented 7 years ago

Other smaller changes to discuss and maybe implement:

avernet commented 7 years ago

What if you are on the review page, and want to go back to edit?

This is covered by the second item in my previous comment. We need a general mechanism here, in particular for the case where we have a "fill out form → review → submit" process, in which case "submit" should only show on the "review page". (And we can leverage the stage here, so it doesn't show when users go to /new.)

avernet commented 7 years ago

2256.bmpr.zip

buttons

perspective_ creating

perspective_ editing

perspective_ approving

perspective_ viewing

avernet commented 7 years ago

Thinking about it, the term "perspective" seems to be fitting as in typical use / in the context of a workflow:

avernet commented 7 years ago

I updated the mockups above to make the checkbox "Fill new form" readonly if the constraints contain something that depends on the data (e.g. stage).

avernet commented 6 years ago

+1 from community

avernet commented 6 years ago

We have a new "perspective-based" design from 2017-04, and no significant work has been done to update the UI per this new design since then. Next steps:

ebruchez commented 6 years ago

Possible next steps:

avernet commented 6 years ago
avernet commented 6 years ago

Consider the case of an expense report, and say that after an employee submits an expense report, the employee can update it, but not approve it, and a manager can approve it (or reject it), but not update it.

When a persistence API implementation gets a PUT, it doesn't have enough information to discriminate between an update of the initial expense report (only allowed if done by the employee) and an approval or rejection (only allowed if done by the manager). It doesn't have enough information to properly enforce the permissions.

It could reject operations that are clearly forbidden, like a POST by someone other than the employee or the manager. And this is something we could do in the future, but it has two downsides:

(It should be noted that this second point is already a problem right now: a form can implement the above scenario by hiding controls or making them readonly based on the user's role, and persistence API implementation doesn't check that.)

ebruchez commented 5 years ago

Summary of how do we handle the workflow UI so far:

The idea is that:

In practice, our XForms implementation requires XPath expressions pointing to XML. That is why we do this Scala ↔ XML translation. See also #3455 for similar considerations on how we could improve that.

ebruchez commented 5 years ago

I think we can continue along these lines for now. Steps:

avernet commented 5 years ago

Next steps:

ebruchez commented 4 years ago

Supporting native instances would be good, see #3455.

ebruchez commented 4 years ago

For reading/writing from/to the form definition:

Converting (option in the Form Builder permissions and/or Workflow dialogs?):

Running:

ebruchez commented 4 years ago

Following discussion with @avernet today, we suggest, for the stage name, to have a localizable label. This is usual for:

  1. The Summary page
  2. To display in the Detail page as well