petri_flow 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +113 -8
- data/app/controllers/wf/application_controller.rb +4 -4
- data/app/controllers/wf/comments_controller.rb +1 -1
- data/app/controllers/wf/workitems_controller.rb +7 -7
- data/app/views/layouts/wf/_nav.html.erb +1 -1
- data/app/views/wf/workitems/show.html.erb +3 -3
- data/lib/wf/engine.rb +14 -0
- data/lib/wf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b63de997ab1759fc0d4ebf282bfd6994fcc5724f5536acccf5d75f0f7de4526
|
4
|
+
data.tar.gz: 46c06f8c268cd939872634a583a384a9a0deae3a0c39de010f714a57b92fcbb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c22fec00a31eeb2026cc3f1c488da4bac9353c0cb275819b360a31b51c2b459ab4ee326e09194ee4d9eb6edbfcab08d50695ead0b1424c296a0300b403565ee
|
7
|
+
data.tar.gz: bb80c81ea18f8fcbae114af7b6fee30b0fca83112a9b32b87a882efb3116c056c428a6042c4cafbeeedf8d62b2428d881d19e9f9b67440f8a7dc0549c2f74840
|
data/README.md
CHANGED
@@ -1,26 +1,131 @@
|
|
1
|
-
#
|
2
|
-
Short description and motivation.
|
1
|
+
# Petri Flow
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
Workflow engine for Rails.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
* Full petri net features support (seq, parallel, iterative, timed, automitic etc.)
|
7
|
+
* Both approval workflow and business workflow.
|
8
|
+
* Simple web admin for workflow definition and case management.
|
9
|
+
* Build-in simple dynamic form.
|
10
|
+
* Replaceable dynamic form.
|
11
|
+
* Graph screen for workflow definition.
|
12
|
+
* Graph screen for case and token migration.
|
13
|
+
* Powerful guard expression.
|
14
|
+
* MySQL and Postgres Support.
|
15
|
+
* Powerful assignment management.
|
16
|
+
* Flexible integration of organizational structure system(role, group, position or department etc.)
|
17
|
+
|
18
|
+
## Docs
|
19
|
+
|
20
|
+
* [Petri-Nets and Workflows](https://app.gitbook.com/@hooopo/s/petri-flow/)
|
21
|
+
* [Workflow Conceptual Guide](https://app.gitbook.com/@hooopo/s/petri-flow/workflow-conceptual-guide)
|
22
|
+
* [Workflow Concepts Reference](https://app.gitbook.com/@hooopo/s/petri-flow/workflow-concepts-reference)
|
23
|
+
* [Petri Flow ERD](https://app.gitbook.com/@hooopo/s/petri-flow/erd)
|
24
|
+
* [Developer Doc](https://app.gitbook.com/@hooopo/s/petri-flow/developer-document)
|
25
|
+
|
26
|
+
## Screenshots
|
27
|
+
|
28
|
+
### iterative routing
|
29
|
+
|
30
|
+
![](https://github.com/hooopo/wf/blob/master/screenshots/iterative_routing.png)
|
31
|
+
|
32
|
+
### parallel_routing
|
33
|
+
|
34
|
+
![](https://github.com/hooopo/wf/blob/master/screenshots/parallel_routing.png)
|
35
|
+
|
36
|
+
### guard
|
37
|
+
|
38
|
+
![](https://github.com/hooopo/wf/blob/master/screenshots/workflow_with_guard.png)
|
6
39
|
|
40
|
+
### case state graph
|
41
|
+
|
42
|
+
![](https://github.com/hooopo/wf/blob/master/screenshots/case_state_graph.png)
|
43
|
+
|
44
|
+
###
|
7
45
|
## Installation
|
8
46
|
Add this line to your application's Gemfile:
|
9
47
|
|
10
48
|
```ruby
|
11
|
-
gem 'wf'
|
49
|
+
gem 'petri_flow', require: 'wf'
|
12
50
|
```
|
13
51
|
|
14
52
|
And then execute:
|
53
|
+
|
15
54
|
```bash
|
16
55
|
$ bundle
|
17
56
|
```
|
18
57
|
|
19
|
-
|
20
|
-
|
21
|
-
|
58
|
+
Install graphviz
|
59
|
+
|
60
|
+
```
|
61
|
+
brew install graphviz
|
62
|
+
```
|
63
|
+
|
64
|
+
Migration:
|
65
|
+
|
66
|
+
```
|
67
|
+
bundle exec rake wf:install:migrations
|
68
|
+
bundle exec rails db:create
|
69
|
+
bundle exec rails db:migrate
|
70
|
+
```
|
71
|
+
## Usage
|
72
|
+
|
73
|
+
Add wf_config:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
# config/initializers/wf_config.rb
|
77
|
+
Wf::Workflow.class_eval do
|
78
|
+
def self.user_class
|
79
|
+
::User
|
80
|
+
end
|
81
|
+
|
82
|
+
# you can add more org class, for example, Role, Department, Position etc.
|
83
|
+
def self.org_classes
|
84
|
+
{ group: ::Group }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
Set parties:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
class User < ApplicationRecord
|
93
|
+
belongs_to :group, optional: true
|
94
|
+
has_one :party, as: :partable, class_name: 'Wf::Party'
|
95
|
+
|
96
|
+
# NOTICE: group or user or role all has_many users
|
97
|
+
has_many :users, foreign_key: :id
|
98
|
+
|
99
|
+
after_create do
|
100
|
+
create_party(party_name: name)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
class Group < ApplicationRecord
|
107
|
+
has_many :users
|
108
|
+
has_one :party, as: :partable, class_name: 'Wf::Party'
|
109
|
+
after_create do
|
110
|
+
create_party(party_name: name)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
```
|
114
|
+
|
115
|
+
then
|
116
|
+
|
117
|
+
```
|
118
|
+
bundle exec rails
|
22
119
|
```
|
23
120
|
|
121
|
+
visit:
|
122
|
+
|
123
|
+
```
|
124
|
+
http://localhost:3000/wf
|
125
|
+
```
|
126
|
+
|
127
|
+
Demo App: https://github.com/hooopo/petri_flow_demo
|
128
|
+
|
24
129
|
## Contributing
|
25
130
|
Contribution directions go here.
|
26
131
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Wf
|
4
|
-
class ApplicationController <
|
4
|
+
class ApplicationController < ::ApplicationController
|
5
5
|
protect_from_forgery with: :exception
|
6
|
-
helper_method :
|
6
|
+
helper_method :wf_current_user
|
7
7
|
|
8
8
|
breadcrumb "Home", :root_path
|
9
9
|
|
10
|
-
def
|
11
|
-
|
10
|
+
def wf_current_user
|
11
|
+
current_user
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -16,7 +16,7 @@ module Wf
|
|
16
16
|
|
17
17
|
def create
|
18
18
|
@workitem = Wf::Workitem.find(params[:workitem_id])
|
19
|
-
Wf::CaseCommand::AddComment.call(@workitem, params[:comment][:body],
|
19
|
+
Wf::CaseCommand::AddComment.call(@workitem, params[:comment][:body], wf_current_user)
|
20
20
|
redirect_to workitem_path(@workitem), notice: "Comment Added."
|
21
21
|
end
|
22
22
|
|
@@ -12,9 +12,9 @@ module Wf
|
|
12
12
|
|
13
13
|
def index
|
14
14
|
current_party_ids = [
|
15
|
-
|
16
|
-
Wf::Workflow.org_classes.map { |org, _org_class|
|
17
|
-
].flatten.map { |x| x
|
15
|
+
wf_current_user,
|
16
|
+
Wf::Workflow.org_classes.map { |org, _org_class| wf_current_user.public_send(org) }
|
17
|
+
].flatten.map { |x| x&.party&.id }.compact
|
18
18
|
@workitems = Wf::Workitem.joins(:workitem_assignments).where(Wf::WorkitemAssignment.table_name => { party_id: current_party_ids })
|
19
19
|
@workitems = @workitems.where(state: params[:state].intern) if params[:state]
|
20
20
|
@workitems = @workitems.where(state: params[:state].intern) if params[:state].present?
|
@@ -27,7 +27,7 @@ module Wf
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def start
|
30
|
-
Wf::CaseCommand::StartWorkitem.call(@workitem,
|
30
|
+
Wf::CaseCommand::StartWorkitem.call(@workitem, wf_current_user)
|
31
31
|
breadcrumb @workitem.workflow.name, workflow_path(@workitem.workflow)
|
32
32
|
breadcrumb @workitem.case.name, workflow_case_path(@workitem.workflow, @workitem.case)
|
33
33
|
breadcrumb @workitem.name, workitem_path(@workitem)
|
@@ -42,7 +42,7 @@ module Wf
|
|
42
42
|
|
43
43
|
def finish
|
44
44
|
if @workitem.transition.form && params[:workitem][:entry]
|
45
|
-
entry = @workitem.entries.find_or_create_by!(user:
|
45
|
+
entry = @workitem.entries.find_or_create_by!(user: wf_current_user)
|
46
46
|
params[:workitem][:entry].permit!.each do |field_id, field_value|
|
47
47
|
if field = entry.field_values.where(form: @workitem.transition.form, workflow: @workitem.workflow, field_id: field_id).first
|
48
48
|
field.update!(value: field_value)
|
@@ -65,13 +65,13 @@ module Wf
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def check_start
|
68
|
-
unless @workitem.started_by?(
|
68
|
+
unless @workitem.started_by?(wf_current_user)
|
69
69
|
redirect_to workitem_path(@workitem), notice: "You can not start this workitem, Please assign to youself first."
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
def check_finish
|
74
|
-
unless @workitem.finished_by?(
|
74
|
+
unless @workitem.finished_by?(wf_current_user)
|
75
75
|
redirect_to workitem_path(@workitem), notice: "You can not the holding use of this workitem, Please assign to youself && start it first."
|
76
76
|
end
|
77
77
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
</div>
|
6
6
|
|
7
7
|
<div class="navbar-end">
|
8
|
-
<%= link_to
|
8
|
+
<%= link_to wf_current_user&.name, workitems_path %>
|
9
9
|
<%= link_to 'Forms', forms_path, class: "navbar-item #{"is-active" if controller_name == "forms"}" %>
|
10
10
|
<%= link_to 'Workflows', workflows_path, class: "navbar-item #{"is-active" if controller_name.start_with?("workflows")}" %>
|
11
11
|
</div>
|
@@ -125,15 +125,15 @@
|
|
125
125
|
<tr>
|
126
126
|
<td colspan="5">
|
127
127
|
<% if @workitem.transition.user? && (@workitem.started? || @workitem.enabled?) %>
|
128
|
-
<% if @workitem.finished_by?(
|
128
|
+
<% if @workitem.finished_by?(wf_current_user) %>
|
129
129
|
<%= link_to "Pre Finish Workitem", pre_finish_workitem_path(@workitem), class: 'btn btn-sm btn-dark' %>
|
130
|
-
<% elsif @workitem.started_by?(
|
130
|
+
<% elsif @workitem.started_by?(wf_current_user)%>
|
131
131
|
<%= link_to "Start Workitem", start_workitem_path(@workitem), method: :put, class: 'btn btn-sm btn-dark' %>
|
132
132
|
<% else %>
|
133
133
|
You can not start workitem, Please assign to youself.
|
134
134
|
<% end %>
|
135
135
|
<%= link_to "Re Assign", new_workitem_workitem_assignment_path(@workitem), class: 'btn btn-success btn-sm' %>
|
136
|
-
<%= link_to "Assign Yourself", new_workitem_workitem_assignment_path(@workitem, party_id:
|
136
|
+
<%= link_to "Assign Yourself", new_workitem_workitem_assignment_path(@workitem, party_id: wf_current_user.party&.id), class: 'btn btn-success btn-sm' %>
|
137
137
|
<%= link_to "Add Comment", new_workitem_comment_path(@workitem), class: 'btn btn-success btn-sm' %>
|
138
138
|
<% end %>
|
139
139
|
</td>
|
data/lib/wf/engine.rb
CHANGED
@@ -6,5 +6,19 @@ module Wf
|
|
6
6
|
config.autoload_paths += %W[
|
7
7
|
#{config.root}/app/models/wf/concerns
|
8
8
|
]
|
9
|
+
|
10
|
+
config.to_prepare do
|
11
|
+
require_dependency(Rails.root + "config/initializers/wf_config.rb")
|
12
|
+
rescue LoadError
|
13
|
+
puts("config/initializers/wf_config.rb not found.")
|
14
|
+
end
|
9
15
|
end
|
10
16
|
end
|
17
|
+
|
18
|
+
require "bootstrap"
|
19
|
+
require "bootstrap4-kaminari-views"
|
20
|
+
require "jquery-rails"
|
21
|
+
require "kaminari"
|
22
|
+
require "simple_command"
|
23
|
+
require "loaf"
|
24
|
+
require "graphviz"
|
data/lib/wf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: petri_flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hooopo Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bootstrap
|