petri_flow 0.1.5 → 0.1.6

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: fbde18cce71cef5defd61e81def61a22161d86f65a9bcf9e4747f801fb20347a
4
- data.tar.gz: b3815dfe29977ccef329d79f907cb39d2b95b3c27cabce139ee6ea6d7a1d904a
3
+ metadata.gz: 5fab8df9f2e3aab0e596f470cab3b32c81bd395d9693a761c64b671b78c01a7e
4
+ data.tar.gz: befe8793cab6a2b5f07ab2cd7f80621832949354557dbdb7d54ea07ee4cdb8e8
5
5
  SHA512:
6
- metadata.gz: e09272dfd04c097eb21caa9a5d3493f39e4f30ade13d8d77546f64a23743f2d382a177e97c53e9cb8b77d860a863cb93d506099471cb0698b938eb2ede731e7c
7
- data.tar.gz: d1ab085bbb1ac92833f653dd8f84011e4a2c052e440577262e1663bfc145589a032e49ea9011422d7b4d15196b95da22f0ffd494835f8c35bb75948d93dca84f
6
+ metadata.gz: 9e959b6a9e7283e0546fba60f1284c43f633850f175ae41ec57f68dd7bf794e9f3130c1ffdb5a51630c1a7a588b30615b7e70a4029436c2f4cc27b315c81eb4a
7
+ data.tar.gz: 742a8b6b01db351fd78ec40df6b3bcb96415f46a1c24cc6c8429a2261101764028ed146bd9b2d2798cb8a5b8875839ac53759476c0ae29aadd1e03f2f2a75f9c
data/README.md CHANGED
@@ -74,16 +74,8 @@ Add wf_config:
74
74
 
75
75
  ```ruby
76
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
77
+ Wf.user_class = "::User"
78
+ Wf.org_classes = { group: "::Group" }
87
79
  ```
88
80
 
89
81
  Set parties:
@@ -13,7 +13,7 @@ module Wf
13
13
  def index
14
14
  current_party_ids = [
15
15
  wf_current_user,
16
- Wf::Workflow.org_classes.map { |org, _org_class| wf_current_user&.public_send(org) }
16
+ Wf.org_classes.map { |org, _org_class| wf_current_user&.public_send(org) }
17
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]
@@ -11,7 +11,7 @@ module Wf::CaseCommand
11
11
  def call
12
12
  raise("The workitem is not in state #{workitem.state}") unless workitem.started?
13
13
  Wf::ApplicationRecord.transaction do
14
- workitem.update!(state: :canceled, :canceled_at: Time.zone.now)
14
+ workitem.update!(state: :canceled, canceled_at: Time.zone.now)
15
15
  ReleaseToken.call(workitem)
16
16
  SweepAutomaticTransitions.call(workitem.case)
17
17
  end
@@ -16,6 +16,6 @@
16
16
  module Wf
17
17
  class Comment < ApplicationRecord
18
18
  belongs_to :workitem
19
- belongs_to :user, class_name: Wf::Workflow.user_class.to_s
19
+ belongs_to :user, class_name: Wf.user_class.to_s
20
20
  end
21
21
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # == Schema Information
3
4
  #
4
5
  # Table name: wf_entries
@@ -15,7 +16,7 @@
15
16
  module Wf
16
17
  class Entry < ApplicationRecord
17
18
  belongs_to :form
18
- belongs_to :user, class_name: Wf::Workflow.user_class.to_s
19
+ belongs_to :user, class_name: Wf.user_class.to_s
19
20
  belongs_to :workitem
20
21
  has_many :field_values
21
22
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # == Schema Information
3
4
  #
4
5
  # Table name: wf_field_values
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # == Schema Information
3
4
  #
4
5
  # Table name: wf_transitions
@@ -25,61 +25,6 @@ module Wf
25
25
 
26
26
  validates :name, presence: true
27
27
 
28
- # TODO: move to config
29
- def self.enable_callbacks
30
- [Wf::Callbacks::EnableDefault]
31
- end
32
-
33
- def self.fire_callbacks
34
- [Wf::Callbacks::FireDefault]
35
- end
36
-
37
- def self.assignment_callbacks
38
- [Wf::Callbacks::AssignmentDefault]
39
- end
40
-
41
- def self.unassignment_callbacks
42
- [Wf::Callbacks::UnassignmentDefault]
43
- end
44
-
45
- def self.notification_callbacks
46
- [Wf::Callbacks::NotificationDefault]
47
- end
48
-
49
- def self.deadline_callbacks
50
- [Wf::Callbacks::DeadlineDefault]
51
- end
52
-
53
- def self.time_callbacks
54
- [Wf::Callbacks::TimeDefault]
55
- end
56
-
57
- def self.hold_timeout_callbacks
58
- [Wf::Callbacks::HoldTimeoutDefault]
59
- end
60
-
61
- def self.form_class
62
- "::Wf::Form"
63
- end
64
-
65
- def self.entry_class
66
- "::Wf::Entry"
67
- end
68
-
69
- def self.field_class
70
- "::Wf::Field"
71
- end
72
-
73
- def self.user_class
74
- "::Wf::User"
75
- end
76
-
77
- def self.org_classes
78
- {
79
- group: "::Wf::Group"
80
- }
81
- end
82
-
83
28
  after_save do
84
29
  do_validate!
85
30
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # == Schema Information
3
4
  #
4
5
  # Table name: wf_workitems
@@ -25,11 +26,11 @@ module Wf
25
26
  belongs_to :workflow
26
27
  belongs_to :transition
27
28
  belongs_to :case
28
- belongs_to :holding_user, foreign_key: :holding_user_id, class_name: Workflow.user_class.to_s, optional: true
29
+ belongs_to :holding_user, foreign_key: :holding_user_id, class_name: Wf.user_class.to_s, optional: true
29
30
  has_many :workitem_assignments
30
31
  has_many :parties, through: :workitem_assignments, source: "party"
31
32
  has_many :comments
32
- has_many :entries, class_name: Wf::Workflow.entry_class.to_s
33
+ has_many :entries, class_name: Wf.entry_class.to_s
33
34
 
34
35
  enum state: {
35
36
  enabled: 0,
@@ -43,47 +43,47 @@
43
43
 
44
44
  <div class="form-group">
45
45
  <%= f.label :form, class: "label" %>
46
- <%= f.select :form, options_for_select(Wf::Workflow.form_class.constantize.all.map{|x| [x.name, x.to_global_id]} || [], selected: f.object&.form&.to_global_id), {include_blank: 'user can input from custom form?'}, class: "form-control custom-select", placeholder: "Form" %>
46
+ <%= f.select :form, options_for_select(Wf.form_class.constantize.all.map{|x| [x.name, x.to_global_id]} || [], selected: f.object&.form&.to_global_id), {include_blank: 'user can input from custom form?'}, class: "form-control custom-select", placeholder: "Form" %>
47
47
  </div>
48
48
 
49
49
  <div class="form-group">
50
50
  <%= f.label :enable_callback, class: "label" %>
51
- <%= f.select :enable_callback, Wf::Workflow.enable_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
51
+ <%= f.select :enable_callback, Wf.enable_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
52
52
  </div>
53
53
 
54
54
  <div class="form-group">
55
55
  <%= f.label :fire_callback, class: "label" %>
56
- <%= f.select :fire_callback, Wf::Workflow.fire_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
56
+ <%= f.select :fire_callback, Wf.fire_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
57
57
  </div>
58
58
 
59
59
  <div class="form-group">
60
60
  <%= f.label :deadline_callback, class: "label" %>
61
- <%= f.select :deadline_callback, Wf::Workflow.deadline_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
61
+ <%= f.select :deadline_callback, Wf.deadline_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
62
62
  </div>
63
63
 
64
64
  <div class="form-group">
65
65
  <%= f.label :time_callback, class: "label" %>
66
- <%= f.select :time_callback, Wf::Workflow.time_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
66
+ <%= f.select :time_callback, Wf.time_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
67
67
  </div>
68
68
 
69
69
  <div class="form-group">
70
70
  <%= f.label :hold_timeout_callback, class: "label" %>
71
- <%= f.select :hold_timeout_callback, Wf::Workflow.hold_timeout_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
71
+ <%= f.select :hold_timeout_callback, Wf.hold_timeout_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
72
72
  </div>
73
73
 
74
74
  <div class="form-group">
75
75
  <%= f.label :assignment_callback, class: "label" %>
76
- <%= f.select :assignment_callback, Wf::Workflow.assignment_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
76
+ <%= f.select :assignment_callback, Wf.assignment_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
77
77
  </div>
78
78
 
79
79
  <div class="form-group">
80
80
  <%= f.label :unassignment_callback, class: "label" %>
81
- <%= f.select :unassignment_callback, Wf::Workflow.unassignment_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
81
+ <%= f.select :unassignment_callback, Wf.unassignment_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
82
82
  </div>
83
83
 
84
84
  <div class="form-group">
85
85
  <%= f.label :notification_callback, class: "label" %>
86
- <%= f.select :notification_callback, Wf::Workflow.notification_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
86
+ <%= f.select :notification_callback, Wf.notification_callbacks, {}, class: "form-control custom-select", placeholder: "Callback" %>
87
87
  </div>
88
88
 
89
89
  <div class="form-group">
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.5"
4
+ VERSION = "0.1.6"
5
5
  end
data/lib/wf.rb CHANGED
@@ -3,5 +3,35 @@
3
3
  require "wf/engine"
4
4
 
5
5
  module Wf
6
- # Your code goes here...
6
+ class << self
7
+ attr_accessor :enable_callbacks
8
+ attr_accessor :fire_callbacks
9
+ attr_accessor :assignment_callbacks
10
+ attr_accessor :unassignment_callbacks
11
+ attr_accessor :notification_callbacks
12
+ attr_accessor :time_callbacks
13
+ attr_accessor :deadline_callbacks
14
+ attr_accessor :hold_timeout_callbacks
15
+
16
+ attr_accessor :form_class
17
+ attr_accessor :entry_class
18
+ attr_accessor :field_class
19
+
20
+ attr_accessor :user_class
21
+ attr_accessor :org_classes
22
+ end
23
+
24
+ self.enable_callbacks = ["Wf::Callbacks::EnableDefault"]
25
+ self.fire_callbacks = ["Wf::Callbacks::FireDefault"]
26
+ self.assignment_callbacks = ["Wf::Callbacks::AssignmentDefault"]
27
+ self.unassignment_callbacks = ["Wf::Callbacks::UnassignmentDefault"]
28
+ self.notification_callbacks = ["Wf::Callbacks::NotificationDefault"]
29
+ self.deadline_callbacks = ["Wf::Callbacks::DeadlineDefault"]
30
+ self.time_callbacks = ["Wf::Callbacks::TimeDefault"]
31
+ self.hold_timeout_callbacks = ["Wf::Callbacks::HoldTimeoutDefault"]
32
+ self.form_class = "::Wf::Form"
33
+ self.entry_class = "::Wf::Entry"
34
+ self.field_class = "::Wf::Field"
35
+ self.user_class = "::Wf::User"
36
+ self.org_classes = { group: "::Wf::Group" }
7
37
  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.5
4
+ version: 0.1.6
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-14 00:00:00.000000000 Z
11
+ date: 2020-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap