petri_flow 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8edfa5f265e495edad2726cb2d812e0dea76978623cc7f9e0c03d2aaa27c7e90
4
- data.tar.gz: 8d4b8737d9fb6d4b36977d873a078d57cbba1bbffebe0d357a12e62904de4025
3
+ metadata.gz: 4f413b92f6d4f452aa139f22ca407fce87cb4b8ca39b8afc3c2b09df509c8def
4
+ data.tar.gz: 14a8a81e41d3581a5225c7a21d8ec0a56146886b986ada2d902521256c1da6ad
5
5
  SHA512:
6
- metadata.gz: 36a38a82bc4b3b45b0879c5019e52417589a5868192828854091b9ead9e8f34384c7063325e0d1405e6bcfe18c318f11451630226354e0f966a2277ed5ba4e2f
7
- data.tar.gz: 8b7d014f64cfd03d7d794d87f2556c115a4b095e23dbdb4b5e67f73f7e62b4f44924769c73ad66dec1b9362264f64df7e09fe7f92df549a044f8e62c9aa91498
6
+ metadata.gz: 360f40f0da4d06be85a0a2f463c89ed0759e0137d356609fc28f80ae674118d11882d64f063755c33dd903a32868b7343c300ec941ca6eb86cb1aa3bda53375a
7
+ data.tar.gz: 10ed23928c6cec4cf125bc02b39aef86efa6c9131632148cc2be7f366e05a66a1974825b77c9a8939fd995e30a609b51ce66f4f5a4212c7b77409aad550f85ae
@@ -72,7 +72,8 @@ module Wf
72
72
  :deadline_callback,
73
73
  :sub_workflow_id,
74
74
  :multiple_instance,
75
- :finish_condition
75
+ :finish_condition,
76
+ :dynamic_assign_by_id
76
77
  )
77
78
  end
78
79
  end
@@ -37,6 +37,11 @@ module Wf
37
37
  end
38
38
 
39
39
  def finish
40
+ if dynamic_assignments = params.dig(:workitem, :dynamic_assignments)
41
+ dynamic_assignments.permit!.each do |t_id, party_id|
42
+ Wf::CaseCommand::AddManualAssignment.call(@workitem.case, @workitem.workflow.transitions.find(t_id), Wf::Party.find(party_id))
43
+ end
44
+ end
40
45
  if @workitem.transition.form && params[:workitem][:entry]
41
46
  form = @workitem.transition.form
42
47
  cmd = Wf::CaseCommand::CreateEntry.call(form, @workitem, wf_current_user, params[:workitem][:entry].permit!)
@@ -25,6 +25,7 @@
25
25
  # sub_workflow_id :integer
26
26
  # multiple_instance :boolean default("false")
27
27
  # finish_condition :string default("Wf::MultipleInstances::AllFinish")
28
+ # dynamic_assign_by_id :integer
28
29
  #
29
30
 
30
31
  module Wf
@@ -36,6 +37,8 @@ module Wf
36
37
  has_many :workitems
37
38
  belongs_to :form, optional: true, polymorphic: true
38
39
  belongs_to :sub_workflow, optional: true, class_name: "Wf::Workflow"
40
+ belongs_to :dynamic_assign_by, optional: true, class_name: "Wf::Transition"
41
+ has_many :dynamic_assignments, class_name: "Wf::Transition", foreign_key: "dynamic_assign_by_id"
39
42
 
40
43
  enum trigger_type: {
41
44
  user: 0,
@@ -34,11 +34,6 @@
34
34
  <%= f.text_field :trigger_limit, class: "form-control", placeholder: "Trigger Limit" %>
35
35
  </div>
36
36
 
37
- <div class="form-group">
38
- <%= f.label :sort_order, class: "label" %>
39
- <%= f.text_field :sort_order, class: "form-control", placeholder: "Sort Order" %>
40
- </div>
41
-
42
37
  <div class="form-group">
43
38
  <%= f.label :trigger_type, class: "label" %>
44
39
  <%= f.select :trigger_type, Wf::Transition.trigger_types.keys, {}, class: "form-control custom-select", placeholder: "Trigger Type" %>
@@ -55,6 +50,7 @@
55
50
  <%= f.select :sub_workflow_id, options_for_select(Wf::Workflow.valid.all.map{|x| [x.name, x.id]} || []), {include_blank: 'Start a sub workflow?'}, class: "form-control custom-select", placeholder: "Sub Workflow" %>
56
51
  </div>
57
52
  </div>
53
+ </div>
58
54
 
59
55
  <div class="card">
60
56
  <h5 class="card-header">Dynimac Form</h5>
@@ -66,6 +62,16 @@
66
62
  </div>
67
63
  </div>
68
64
 
65
+ <div class="card">
66
+ <h5 class="card-header">Dynamic Assign By</h5>
67
+ <div class="card-body">
68
+ <div class="form-group">
69
+ <%= f.label :dynamic_assign_by, class: "label" %>
70
+ <%= f.select :dynamic_assign_by_id, options_for_select(@workflow.transitions.where("id != ?", @transition.id).all.map{|x| [x.name, x.id]} || []), {include_blank: 'What other transition you want to do the assignment for this transition?'}, class: "form-control custom-select" %>
71
+ </div>
72
+ </div>
73
+ </div>
74
+
69
75
  <div class="card">
70
76
  <h5 class="card-header">Callbacks</h5>
71
77
  <div class="card-body">
@@ -45,6 +45,17 @@
45
45
  </td>
46
46
  </tr>
47
47
 
48
+ <tr>
49
+ <th>Dynamic Assign By</th>
50
+ <td>
51
+ <% if @transition.dynamic_assign_by %>
52
+ <%= link_to @transition.dynamic_assign_by.name, workflow_transition_path(@workflow, @transition.dynamic_assign_by_id) %>
53
+ <% else %>
54
+ No
55
+ <% end %>
56
+ </td>
57
+ </tr>
58
+
48
59
  <tr>
49
60
  <th scope="row">Multiple Instance?</th>
50
61
  <td><%= @transition.multiple_instance %></td>
@@ -126,7 +126,7 @@
126
126
  <% @workflow.transitions.each do |transition| %>
127
127
  <tr>
128
128
  <td><%= transition.id %></td>
129
- <td><%= transition.name %></td>
129
+ <td><%= link_to transition.name, workflow_transition_path(@workflow, transition) %></td>
130
130
  <td><%= transition.description %></td>
131
131
  <td><%= transition.trigger_limit %></td>
132
132
  <td><%= transition.trigger_type %></td>
@@ -16,6 +16,16 @@
16
16
  </article>
17
17
  <% end %>
18
18
 
19
+ <% @workitem.transition.dynamic_assignments.each do |tt| %>
20
+ <%= f.fields_for :dynamic_assignments do |ff| %>
21
+ <div class="form-group">
22
+ <%= ff.label "Assign #{tt.name}", class: "label" %>
23
+ <%= ff.select tt.id, Wf::Party.all.map{|x| [x.party_name, x.id]}, {}, class: "form-control custom-select" %>
24
+ </div>
25
+ <% end %>
26
+ <% end %>
27
+
28
+
19
29
  <% if @workitem.transition.form %>
20
30
  <%= f.fields_for :entry do |ff| %>
21
31
  <% @workitem.transition.form.fields.each do |field| %>
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddDynamicAssignBy < ActiveRecord::Migration[6.0]
4
+ def change
5
+ add_column :wf_transitions, :dynamic_assign_by_id, :bigint, comment: "dynamic assign by other transition", index: true
6
+ end
7
+ end
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.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petri_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hooopo Wang
@@ -361,6 +361,7 @@ files:
361
361
  - db/migrate/20200220070839_remove_unused_column.rb
362
362
  - db/migrate/20200220072512_add_sub_workflow.rb
363
363
  - db/migrate/20200222150432_add_multi_instance.rb
364
+ - db/migrate/20200226195134_add_dynamic_assign_by.rb
364
365
  - lib/tasks/wf_tasks.rake
365
366
  - lib/wf.rb
366
367
  - lib/wf/engine.rb