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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94179569c7519230838683fb177f10d5ba283b8443540929a9a73bd8883f342a
4
- data.tar.gz: b8fefcc3f627b62f78c54ccfa8f9336593d3aba6604fabdb5054e391c2021796
3
+ metadata.gz: 0b63de997ab1759fc0d4ebf282bfd6994fcc5724f5536acccf5d75f0f7de4526
4
+ data.tar.gz: 46c06f8c268cd939872634a583a384a9a0deae3a0c39de010f714a57b92fcbb1
5
5
  SHA512:
6
- metadata.gz: 9dcd057186dffe1eca9374c6186194af78418ca4252a32ef614e8c4e65924f144fdc60210e59f548af30193351b5df587cac376d4750486333eb0a7fe133e7af
7
- data.tar.gz: 7126f1b8186a29fc709d5886199523a8a748625f0b3e154fd3a3904a1c4dd380c2439eb69400e97856980a3a75613b96a35a3750f47ed133153404649332dfee
6
+ metadata.gz: 6c22fec00a31eeb2026cc3f1c488da4bac9353c0cb275819b360a31b51c2b459ab4ee326e09194ee4d9eb6edbfcab08d50695ead0b1424c296a0300b403565ee
7
+ data.tar.gz: bb80c81ea18f8fcbae114af7b6fee30b0fca83112a9b32b87a882efb3116c056c428a6042c4cafbeeedf8d62b2428d881d19e9f9b67440f8a7dc0549c2f74840
data/README.md CHANGED
@@ -1,26 +1,131 @@
1
- # Wf
2
- Short description and motivation.
1
+ # Petri Flow
3
2
 
4
- ## Usage
5
- How to use my plugin.
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
- Or install it yourself as:
20
- ```bash
21
- $ gem install wf
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 < ActionController::Base
4
+ class ApplicationController < ::ApplicationController
5
5
  protect_from_forgery with: :exception
6
- helper_method :current_user
6
+ helper_method :wf_current_user
7
7
 
8
8
  breadcrumb "Home", :root_path
9
9
 
10
- def current_user
11
- Wf::User.first
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], current_user)
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
- current_user,
16
- Wf::Workflow.org_classes.map { |org, _org_class| current_user.public_send(org) }
17
- ].flatten.map { |x| x.party&.id }
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, current_user)
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: current_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?(current_user)
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?(current_user)
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 current_user&.name, workitems_path %>
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?(current_user) %>
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?(current_user)%>
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: current_user.party&.id), class: 'btn btn-success btn-sm' %>
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wf
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
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.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-06 00:00:00.000000000 Z
11
+ date: 2020-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap