petri_flow 0.1.0

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.
Files changed (153) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/config/wf_manifest.js +2 -0
  6. data/app/assets/javascripts/wf/application.js +4 -0
  7. data/app/assets/stylesheets/wf/application.scss +2 -0
  8. data/app/assets/stylesheets/wf/arcs.css +4 -0
  9. data/app/assets/stylesheets/wf/cases.css +4 -0
  10. data/app/assets/stylesheets/wf/comments.css +4 -0
  11. data/app/assets/stylesheets/wf/fields.css +4 -0
  12. data/app/assets/stylesheets/wf/forms.css +4 -0
  13. data/app/assets/stylesheets/wf/guards.css +4 -0
  14. data/app/assets/stylesheets/wf/places.css +4 -0
  15. data/app/assets/stylesheets/wf/transitions.css +4 -0
  16. data/app/assets/stylesheets/wf/workflows.css +4 -0
  17. data/app/assets/stylesheets/wf/workitem_assignments.css +4 -0
  18. data/app/assets/stylesheets/wf/workitems.css +4 -0
  19. data/app/controllers/wf/application_controller.rb +14 -0
  20. data/app/controllers/wf/arcs_controller.rb +61 -0
  21. data/app/controllers/wf/cases_controller.rb +48 -0
  22. data/app/controllers/wf/comments_controller.rb +30 -0
  23. data/app/controllers/wf/fields_controller.rb +54 -0
  24. data/app/controllers/wf/forms_controller.rb +59 -0
  25. data/app/controllers/wf/guards_controller.rb +58 -0
  26. data/app/controllers/wf/places_controller.rb +53 -0
  27. data/app/controllers/wf/transitions_controller.rb +69 -0
  28. data/app/controllers/wf/workflows_controller.rb +59 -0
  29. data/app/controllers/wf/workitem_assignments_controller.rb +30 -0
  30. data/app/controllers/wf/workitems_controller.rb +79 -0
  31. data/app/helpers/wf/application_helper.rb +6 -0
  32. data/app/helpers/wf/arcs_helper.rb +6 -0
  33. data/app/helpers/wf/cases_helper.rb +6 -0
  34. data/app/helpers/wf/comments_helper.rb +6 -0
  35. data/app/helpers/wf/fields_helper.rb +6 -0
  36. data/app/helpers/wf/forms_helper.rb +6 -0
  37. data/app/helpers/wf/guards_helper.rb +6 -0
  38. data/app/helpers/wf/places_helper.rb +6 -0
  39. data/app/helpers/wf/transitions_helper.rb +6 -0
  40. data/app/helpers/wf/workflows_helper.rb +6 -0
  41. data/app/helpers/wf/workitem_assignments_helper.rb +6 -0
  42. data/app/helpers/wf/workitems_helper.rb +6 -0
  43. data/app/jobs/wf/application_job.rb +6 -0
  44. data/app/jobs/wf/fire_timed_workitem_job.rb +15 -0
  45. data/app/mailers/wf/application_mailer.rb +8 -0
  46. data/app/models/wf/application_record.rb +7 -0
  47. data/app/models/wf/arc.rb +42 -0
  48. data/app/models/wf/callbacks/assignment_default.rb +12 -0
  49. data/app/models/wf/callbacks/deadline_default.rb +11 -0
  50. data/app/models/wf/callbacks/enable_default.rb +11 -0
  51. data/app/models/wf/callbacks/fire_default.rb +11 -0
  52. data/app/models/wf/callbacks/hold_timeout_default.rb +11 -0
  53. data/app/models/wf/callbacks/notification_default.rb +11 -0
  54. data/app/models/wf/callbacks/time_default.rb +11 -0
  55. data/app/models/wf/callbacks/unassignment_default.rb +11 -0
  56. data/app/models/wf/case.rb +44 -0
  57. data/app/models/wf/case_assignment.rb +22 -0
  58. data/app/models/wf/case_command/add_comment.rb +17 -0
  59. data/app/models/wf/case_command/add_manual_assignment.rb +17 -0
  60. data/app/models/wf/case_command/add_token.rb +20 -0
  61. data/app/models/wf/case_command/add_workitem_assignment.rb +35 -0
  62. data/app/models/wf/case_command/begin_workitem_action.rb +33 -0
  63. data/app/models/wf/case_command/cancel.rb +17 -0
  64. data/app/models/wf/case_command/cancel_workitem.rb +20 -0
  65. data/app/models/wf/case_command/clear_manual_assignments.rb +16 -0
  66. data/app/models/wf/case_command/clear_workitem_assignments.rb +20 -0
  67. data/app/models/wf/case_command/consume_token.rb +23 -0
  68. data/app/models/wf/case_command/enable_transitions.rb +33 -0
  69. data/app/models/wf/case_command/end_workitem_action.rb +25 -0
  70. data/app/models/wf/case_command/finish_workitem.rb +18 -0
  71. data/app/models/wf/case_command/finished_p.rb +28 -0
  72. data/app/models/wf/case_command/fire_message_transition.rb +20 -0
  73. data/app/models/wf/case_command/fire_transition_internal.rb +41 -0
  74. data/app/models/wf/case_command/lock_token.rb +21 -0
  75. data/app/models/wf/case_command/new.rb +17 -0
  76. data/app/models/wf/case_command/release_token.rb +20 -0
  77. data/app/models/wf/case_command/remove_manual_assignment.rb +17 -0
  78. data/app/models/wf/case_command/remove_workitem_assignment.rb +24 -0
  79. data/app/models/wf/case_command/resume.rb +17 -0
  80. data/app/models/wf/case_command/set_workitem_assignments.rb +32 -0
  81. data/app/models/wf/case_command/start_case.rb +19 -0
  82. data/app/models/wf/case_command/start_workitem.rb +26 -0
  83. data/app/models/wf/case_command/suspend.rb +17 -0
  84. data/app/models/wf/case_command/sweep_automatic_transitions.rb +31 -0
  85. data/app/models/wf/case_command/sweep_timed_transitions.rb +16 -0
  86. data/app/models/wf/case_command/workitem_action.rb +20 -0
  87. data/app/models/wf/comment.rb +21 -0
  88. data/app/models/wf/demo_target.rb +18 -0
  89. data/app/models/wf/entry.rb +33 -0
  90. data/app/models/wf/field.rb +53 -0
  91. data/app/models/wf/field_value.rb +30 -0
  92. data/app/models/wf/form.rb +18 -0
  93. data/app/models/wf/group.rb +21 -0
  94. data/app/models/wf/guard.rb +73 -0
  95. data/app/models/wf/party.rb +22 -0
  96. data/app/models/wf/place.rb +28 -0
  97. data/app/models/wf/token.rb +37 -0
  98. data/app/models/wf/transition.rb +49 -0
  99. data/app/models/wf/transition_static_assignment.rb +21 -0
  100. data/app/models/wf/user.rb +26 -0
  101. data/app/models/wf/workflow.rb +182 -0
  102. data/app/models/wf/workitem.rb +78 -0
  103. data/app/models/wf/workitem_assignment.rb +19 -0
  104. data/app/views/layouts/wf/_alert.html.erb +4 -0
  105. data/app/views/layouts/wf/_footer.html.erb +13 -0
  106. data/app/views/layouts/wf/_nav.html.erb +13 -0
  107. data/app/views/layouts/wf/_notice.html.erb +4 -0
  108. data/app/views/layouts/wf/application.html.erb +34 -0
  109. data/app/views/wf/arcs/_form.html.erb +40 -0
  110. data/app/views/wf/arcs/edit.html.erb +1 -0
  111. data/app/views/wf/arcs/new.html.erb +1 -0
  112. data/app/views/wf/arcs/show.html.erb +67 -0
  113. data/app/views/wf/cases/_form.html.erb +27 -0
  114. data/app/views/wf/cases/index.html.erb +35 -0
  115. data/app/views/wf/cases/new.html.erb +1 -0
  116. data/app/views/wf/cases/show.html.erb +113 -0
  117. data/app/views/wf/comments/new.html.erb +27 -0
  118. data/app/views/wf/fields/_form.html.erb +42 -0
  119. data/app/views/wf/fields/edit.html.erb +1 -0
  120. data/app/views/wf/fields/new.html.erb +1 -0
  121. data/app/views/wf/forms/_form.html.erb +32 -0
  122. data/app/views/wf/forms/edit.html.erb +1 -0
  123. data/app/views/wf/forms/index.html.erb +32 -0
  124. data/app/views/wf/forms/new.html.erb +1 -0
  125. data/app/views/wf/forms/show.html.erb +53 -0
  126. data/app/views/wf/guards/_form.html.erb +43 -0
  127. data/app/views/wf/guards/edit.html.erb +1 -0
  128. data/app/views/wf/guards/new.html.erb +1 -0
  129. data/app/views/wf/places/_form.html.erb +43 -0
  130. data/app/views/wf/places/edit.html.erb +1 -0
  131. data/app/views/wf/places/new.html.erb +1 -0
  132. data/app/views/wf/transitions/_form.html.erb +92 -0
  133. data/app/views/wf/transitions/edit.html.erb +1 -0
  134. data/app/views/wf/transitions/new.html.erb +1 -0
  135. data/app/views/wf/workflows/_form.html.erb +32 -0
  136. data/app/views/wf/workflows/edit.html.erb +1 -0
  137. data/app/views/wf/workflows/index.html.erb +38 -0
  138. data/app/views/wf/workflows/new.html.erb +1 -0
  139. data/app/views/wf/workflows/show.html.erb +177 -0
  140. data/app/views/wf/workitem_assignments/new.html.erb +27 -0
  141. data/app/views/wf/workitems/index.html.erb +68 -0
  142. data/app/views/wf/workitems/pre_finish.html.erb +33 -0
  143. data/app/views/wf/workitems/show.html.erb +211 -0
  144. data/config/routes.rb +30 -0
  145. data/db/migrate/20200130201043_init.rb +226 -0
  146. data/db/migrate/20200130201641_init_some_data.rb +15 -0
  147. data/db/migrate/20200131200455_create_wf_entries.rb +19 -0
  148. data/db/migrate/20200201001543_add_target_field_name_for_guard.rb +7 -0
  149. data/lib/tasks/wf_tasks.rake +5 -0
  150. data/lib/wf/engine.rb +10 -0
  151. data/lib/wf/version.rb +5 -0
  152. data/lib/wf.rb +7 -0
  153. metadata +312 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e4a0d763be74edc233a7df4e1e6bc1d682403e8e5dfc3eda7b5349d7663a825e
4
+ data.tar.gz: f85dfdb71f866b5846b9bca64c495a1dbcd9ceea864a661613a9ecb93d5d71c6
5
+ SHA512:
6
+ metadata.gz: 1d4d0b4262fd778d9c6469e313cd65df3f7386ee10675a49243751cdda47072aa38ac9d1692f28117c37e9d59350707e7e9d3200a0d6ae583beed039e5384819
7
+ data.tar.gz: 8f9231e9562b90b7f39b784588d9deb6322905cbe65af72c258b7a5e5f477dd522af0f8ca8ba4de5b70ede7e040ff8af8d80821cdbfd8725bb2777da0201a77b
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2020 Hooopo Wang
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Wf
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'wf'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install wf
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "bundler/setup"
5
+ rescue LoadError
6
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
7
+ end
8
+
9
+ require "rdoc/task"
10
+
11
+ RDoc::Task.new(:rdoc) do |rdoc|
12
+ rdoc.rdoc_dir = "rdoc"
13
+ rdoc.title = "Wf"
14
+ rdoc.options << "--line-numbers"
15
+ rdoc.rdoc_files.include("README.md")
16
+ rdoc.rdoc_files.include("lib/**/*.rb")
17
+ end
18
+
19
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
20
+ load "rails/tasks/engine.rake"
21
+
22
+ load "rails/tasks/statistics.rake"
23
+
24
+ require "bundler/gem_tasks"
25
+
26
+ require "rake/testtask"
27
+
28
+ Rake::TestTask.new(:test) do |t|
29
+ t.libs << "test"
30
+ t.pattern = "test/**/*_test.rb"
31
+ t.verbose = false
32
+ end
33
+
34
+ task default: :test
@@ -0,0 +1,2 @@
1
+ //= link_directory ../stylesheets/wf .css
2
+ //= link_directory ../javascripts/wf .js
@@ -0,0 +1,4 @@
1
+ //= require jquery3
2
+ //= require popper
3
+ //= require bootstrap
4
+ //= require rails-ujs
@@ -0,0 +1,2 @@
1
+ // Custom bootstrap variables must be set or imported *before* bootstrap.
2
+ @import "bootstrap";
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Wf
4
+ class ApplicationController < ActionController::Base
5
+ protect_from_forgery with: :exception
6
+ helper_method :current_user
7
+
8
+ breadcrumb "Home", :root_path
9
+
10
+ def current_user
11
+ Wf::User.first
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "wf/application_controller"
4
+
5
+ module Wf
6
+ class ArcsController < ApplicationController
7
+ breadcrumb "Workflows", :workflows_path
8
+
9
+ def new
10
+ @workflow = Wf::Workflow.find(params[:workflow_id])
11
+ @arc = @workflow.arcs.new
12
+ breadcrumb @workflow.name, workflow_path(@workflow)
13
+ end
14
+
15
+ def create
16
+ @workflow = Wf::Workflow.find(params[:workflow_id])
17
+ @arc = @workflow.arcs.new(arc_params)
18
+ if @arc.save
19
+ redirect_to workflow_path(@workflow), notice: "arc was successfully created."
20
+ else
21
+ render :new
22
+ end
23
+ end
24
+
25
+ def destroy
26
+ @workflow = Wf::Workflow.find(params[:workflow_id])
27
+ @arc = @workflow.arcs.find(params[:id])
28
+ @arc.destroy
29
+ render js: "window.location.reload()"
30
+ end
31
+
32
+ def show
33
+ @workflow = Wf::Workflow.find(params[:workflow_id])
34
+ @arc = @workflow.arcs.find(params[:id])
35
+ breadcrumb @workflow.name, workflow_path(@workflow)
36
+ end
37
+
38
+ def edit
39
+ @workflow = Wf::Workflow.find(params[:workflow_id])
40
+ @arc = @workflow.arcs.find(params[:id])
41
+ breadcrumb @workflow.name, workflow_path(@workflow)
42
+ breadcrumb @arc.name, workflow_arc_path(@workflow, @arc)
43
+ end
44
+
45
+ def update
46
+ @workflow = Wf::Workflow.find(params[:workflow_id])
47
+ @arc = @workflow.arcs.find(params[:id])
48
+ if @arc.update(arc_params)
49
+ redirect_to workflow_path(@workflow), notice: "arc was successfully created."
50
+ else
51
+ render :edit
52
+ end
53
+ end
54
+
55
+ private
56
+
57
+ def arc_params
58
+ params.fetch(:arc, {}).permit(:direction, :transition_id, :place_id)
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "wf/application_controller"
4
+
5
+ module Wf
6
+ class CasesController < ApplicationController
7
+ breadcrumb "Workflows", :workflows_path
8
+ def new
9
+ @workflow = Wf::Workflow.find(params[:workflow_id])
10
+ @wf_case = @workflow.cases.new
11
+ breadcrumb @workflow.name, workflow_path(@workflow)
12
+ end
13
+
14
+ def create
15
+ @workflow = Wf::Workflow.find(params[:workflow_id])
16
+ @wf_case = Wf::CaseCommand::New.call(@workflow, GlobalID::Locator.locate(case_params[:targetable])).result
17
+ Wf::CaseCommand::StartCase.call(@wf_case)
18
+ redirect_to workflow_cases_path(@workflow), notice: "case created."
19
+ end
20
+
21
+ def index
22
+ @workflow = Wf::Workflow.find(params[:workflow_id])
23
+ @cases = @workflow.cases.order("id DESC")
24
+ @cases = @cases.where(state: params[:state].intern) if params[:state].present?
25
+ @cases = @cases.page(params[:page])
26
+ breadcrumb @workflow.name, workflow_path(@workflow)
27
+ end
28
+
29
+ def show
30
+ @workflow = Wf::Workflow.find(params[:workflow_id])
31
+ @wf_case = @workflow.cases.find(params[:id])
32
+ breadcrumb @workflow.name, workflow_path(@workflow)
33
+ end
34
+
35
+ def destroy
36
+ @workflow = Wf::Workflow.find(params[:workflow_id])
37
+ @case = @workflow.cases.find(params[:id])
38
+ @case.destroy
39
+ render js: "window.location.reload()"
40
+ end
41
+
42
+ private
43
+
44
+ def case_params
45
+ params.fetch(:case, {}).permit(:targetable, :target_id, :target_type)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "wf/application_controller"
4
+
5
+ module Wf
6
+ class CommentsController < ApplicationController
7
+ breadcrumb "Workflows", :workflows_path
8
+
9
+ def new
10
+ @workitem = Wf::Workitem.find(params[:workitem_id])
11
+ @comment = @workitem.comments.new
12
+ breadcrumb @workitem.workflow.name, workflow_path(@workitem.workflow)
13
+ breadcrumb @workitem.case.name, workflow_case_path(@workitem.workflow, @workitem.case)
14
+ breadcrumb @workitem.name, workitem_path(@workitem)
15
+ end
16
+
17
+ def create
18
+ @workitem = Wf::Workitem.find(params[:workitem_id])
19
+ Wf::CaseCommand::AddComment.call(@workitem, params[:comment][:body], current_user)
20
+ redirect_to workitem_path(@workitem), notice: "Comment Added."
21
+ end
22
+
23
+ def destroy
24
+ @workitem = Wf::Workitem.find(params[:workitem_id])
25
+ @comment = @workitem.comments.find(params[:id])
26
+ @comment.destroy
27
+ render js: "window.location.reload()"
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "wf/application_controller"
4
+
5
+ module Wf
6
+ class FieldsController < ApplicationController
7
+ breadcrumb "Forms", :forms_path
8
+
9
+ def new
10
+ @form = Wf::Form.find(params[:form_id])
11
+ @field = @form.fields.new
12
+ breadcrumb @form.name, form_path(@form)
13
+ end
14
+
15
+ def create
16
+ @form = Wf::Form.find(params[:form_id])
17
+ @field = @form.fields.new(field_params)
18
+ if @field.save
19
+ redirect_to form_path(@form), notice: "field was successfully created."
20
+ else
21
+ render :new
22
+ end
23
+ end
24
+
25
+ def destroy
26
+ @form = Wf::Form.find(params[:form_id])
27
+ @field = @form.fields.find(params[:id])
28
+ @field.destroy
29
+ render js: "window.location.reload()"
30
+ end
31
+
32
+ def edit
33
+ @form = Wf::Form.find(params[:form_id])
34
+ @field = @form.fields.find(params[:id])
35
+ breadcrumb @form.name, form_path(@form)
36
+ end
37
+
38
+ def update
39
+ @form = Wf::Form.find(params[:form_id])
40
+ @field = @form.fields.find(params[:id])
41
+ if @field.update(field_params)
42
+ redirect_to form_path(@form), notice: "field was successfully created."
43
+ else
44
+ render :edit
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ def field_params
51
+ params.fetch(:field, {}).permit(:name, :form_id, :field_type, :position, :default_value)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "wf/application_controller"
4
+
5
+ module Wf
6
+ class FormsController < ApplicationController
7
+ breadcrumb "Forms", :forms_path
8
+
9
+ def index
10
+ @forms = Wf::Form.order("id DESC").page(params[:page])
11
+ end
12
+
13
+ def new
14
+ @form = Wf::Form.new
15
+ end
16
+
17
+ def edit
18
+ @form = Wf::Form.find(params[:id])
19
+ end
20
+
21
+ def show
22
+ @form = Wf::Form.find(params[:id])
23
+ end
24
+
25
+ def destroy
26
+ @form = Wf::Form.find(params[:id])
27
+ @form.destroy
28
+ respond_to do |format|
29
+ format.html { redirect_to forms_path, notice: "form was successfully deleted." }
30
+ format.js { render js: "window.location.reload();" }
31
+ end
32
+ end
33
+
34
+ def update
35
+ @form = Wf::Form.find(params[:id])
36
+ if @form.update(form_params)
37
+ redirect_to form_path(@form), notice: "form was successfully updated."
38
+ else
39
+ render :edit
40
+ end
41
+ end
42
+
43
+ def create
44
+ @form = Wf::Form.new(form_params)
45
+
46
+ if @form.save
47
+ redirect_to forms_path, notice: "form was successfully created."
48
+ else
49
+ render :new
50
+ end
51
+ end
52
+
53
+ private
54
+
55
+ def form_params
56
+ params.fetch(:form, {}).permit(:name, :description)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "wf/application_controller"
4
+
5
+ module Wf
6
+ class GuardsController < ApplicationController
7
+ breadcrumb "Workflows", :workflows_path
8
+ def new
9
+ @arc = Wf::Arc.find(params[:arc_id])
10
+ @guard = @arc.guards.new
11
+ breadcrumb @arc.workflow.name, workflow_path(@arc.workflow)
12
+ breadcrumb @arc.name, workflow_arc_path(@arc.workflow, @arc)
13
+ end
14
+
15
+ def create
16
+ @arc = Wf::Arc.find(params[:arc_id])
17
+ gp = guard_params.merge(fieldable: GlobalID::Locator.locate(guard_params[:fieldable])) if guard_params[:fieldable].present?
18
+ @guard = @arc.guards.new(gp.merge(workflow: @arc.workflow))
19
+ redirect_to workflow_arc_path(@arc.workflow, @arc), notice: "only out direction arc can set guard!" unless @arc.out?
20
+ if @guard.save
21
+ redirect_to workflow_arc_path(@arc.workflow, @arc), notice: "guard was successfully created."
22
+ else
23
+ render :new
24
+ end
25
+ end
26
+
27
+ def destroy
28
+ @arc = Wf::Arc.find(params[:arc_id])
29
+ @guard = @arc.guards.find(params[:id])
30
+ @guard.destroy
31
+ render js: "window.location.reload()"
32
+ end
33
+
34
+ def edit
35
+ @arc = Wf::Arc.find(params[:arc_id])
36
+ @guard = @arc.guards.find(params[:id])
37
+ breadcrumb @arc.workflow.name, workflow_path(@arc.workflow)
38
+ breadcrumb @arc.name, workflow_arc_path(@arc.workflow, @arc)
39
+ end
40
+
41
+ def update
42
+ @arc = Wf::Arc.find(params[:arc_id])
43
+ gp = guard_params.merge(fieldable: GlobalID::Locator.locate(guard_params[:fieldable])) if guard_params[:fieldable].present?
44
+ @guard = @arc.guards.find(params[:id])
45
+ if @guard.update(gp)
46
+ redirect_to workflow_arc_path(@arc.workflow, @arc), notice: "guard was successfully created."
47
+ else
48
+ render :edit
49
+ end
50
+ end
51
+
52
+ private
53
+
54
+ def guard_params
55
+ params.fetch(:guard, {}).permit(:fieldable, :fieldable_type, :fieldable_id, :op, :value, :exp)
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "wf/application_controller"
4
+
5
+ module Wf
6
+ class PlacesController < ApplicationController
7
+ breadcrumb "Workflows", :workflows_path
8
+ def new
9
+ @workflow = Wf::Workflow.find(params[:workflow_id])
10
+ @place = @workflow.places.new
11
+ breadcrumb @workflow.name, workflow_path(@workflow)
12
+ end
13
+
14
+ def create
15
+ @workflow = Wf::Workflow.find(params[:workflow_id])
16
+ @place = @workflow.places.new(place_params)
17
+ if @place.save
18
+ redirect_to workflow_path(@workflow), notice: "place was successfully created."
19
+ else
20
+ render :new
21
+ end
22
+ end
23
+
24
+ def destroy
25
+ @workflow = Wf::Workflow.find(params[:workflow_id])
26
+ @place = @workflow.places.find(params[:id])
27
+ @place.destroy
28
+ render js: "window.location.reload()"
29
+ end
30
+
31
+ def edit
32
+ @workflow = Wf::Workflow.find(params[:workflow_id])
33
+ @place = @workflow.places.find(params[:id])
34
+ breadcrumb @workflow.name, workflow_path(@workflow)
35
+ end
36
+
37
+ def update
38
+ @workflow = Wf::Workflow.find(params[:workflow_id])
39
+ @place = @workflow.places.find(params[:id])
40
+ if @place.update(place_params)
41
+ redirect_to workflow_path(@workflow), notice: "place was successfully created."
42
+ else
43
+ render :edit
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def place_params
50
+ params.fetch(:place, {}).permit(:name, :description, :place_type, :sort_order)
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "wf/application_controller"
4
+
5
+ module Wf
6
+ class TransitionsController < ApplicationController
7
+ breadcrumb "Workflows", :workflows_path
8
+
9
+ def new
10
+ @workflow = Wf::Workflow.find(params[:workflow_id])
11
+ @transition = @workflow.transitions.new
12
+ breadcrumb @workflow.name, workflow_path(@workflow)
13
+ end
14
+
15
+ def create
16
+ @workflow = Wf::Workflow.find(params[:workflow_id])
17
+ @transition = @workflow.transitions.new(transition_params)
18
+ if @transition.save
19
+ redirect_to workflow_path(@workflow), notice: "transition was successfully created."
20
+ else
21
+ render :new
22
+ end
23
+ end
24
+
25
+ def edit
26
+ @workflow = Wf::Workflow.find(params[:workflow_id])
27
+ @transition = @workflow.transitions.find(params[:id])
28
+ breadcrumb @workflow.name, workflow_path(@workflow)
29
+ end
30
+
31
+ def destroy
32
+ @workflow = Wf::Workflow.find(params[:workflow_id])
33
+ @transition = @workflow.transitions.find(params[:id])
34
+ @transition.destroy
35
+ render js: "window.location.reload()"
36
+ end
37
+
38
+ def update
39
+ @workflow = Wf::Workflow.find(params[:workflow_id])
40
+ @transition = @workflow.transitions.find(params[:id])
41
+ if @transition.update(transition_params)
42
+ redirect_to workflow_path(@workflow), notice: "transition was successfully updated."
43
+ else
44
+ render :edit
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ def transition_params
51
+ params.fetch(:transition, {}).permit(
52
+ :name,
53
+ :description,
54
+ :trigger_limit,
55
+ :trigger_type,
56
+ :sort_order,
57
+ :form_id,
58
+ :enable_callback,
59
+ :fire_callback,
60
+ :time_callback,
61
+ :hold_timeout_callback,
62
+ :assignment_callback,
63
+ :unassignment_callback,
64
+ :notification_callback,
65
+ :deadline_callback
66
+ )
67
+ end
68
+ end
69
+ end