rails_workflow 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/rails_workflow/application.css +24 -0
  3. data/app/concerns/rails_workflow/uuid.rb +14 -0
  4. data/app/controllers/rails_workflow/process_templates_controller.rb +16 -1
  5. data/app/models/rails_workflow/operation_template.rb +1 -0
  6. data/app/models/rails_workflow/process_template.rb +1 -1
  7. data/app/serializers/rails_workflow/operation_template_serializer.rb +21 -0
  8. data/app/serializers/rails_workflow/process_template_serializer.rb +18 -0
  9. data/app/services/rails_workflow/process_importer.rb +48 -0
  10. data/app/views/layouts/rails_workflow/application.html.slim +4 -0
  11. data/app/views/rails_workflow/operation_templates/index.html.slim +5 -0
  12. data/app/views/rails_workflow/process_templates/index.html.slim +6 -0
  13. data/app/views/rails_workflow/process_templates/show.html.slim +4 -0
  14. data/config/routes.rb +6 -0
  15. data/db/migrate/20150625034602_create_workflow_processes.rb +155 -0
  16. data/lib/generators/rails_workflow/install/templates/create_workflow_processes.rb +6 -0
  17. data/lib/rails_workflow/engine.rb +0 -7
  18. data/lib/rails_workflow/version.rb +1 -1
  19. data/spec/dummy/config/database.yml +1 -0
  20. data/spec/dummy/db/schema.rb +21 -1
  21. data/spec/dummy/log/development.log +7473 -0
  22. data/spec/dummy/log/test.log +31181 -0
  23. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/-cNdg6xLQjPAHFTRtOoBfAptyWK2nbmR-B8538vn0m0.cache +0 -0
  24. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/0A85mLO2yQXgE-Xdv2lnk94Pn7ZBKbb395XTzJKV_Og.cache +0 -0
  25. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/1bDPFQYYoZ92zSB_1Yewvj1RrGqNGHrTLYXW0V5XGcY.cache +0 -0
  26. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/1cSadEsdvgbYVlwWFSz3sKp25fkzC-xVxgUc49F62v0.cache +2 -0
  27. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/24A_q61u0FknKVkLONfljEp25IY2WZHFuoVFMh2C5XQ.cache +1 -0
  28. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/2h6CVU6OZJKhr8ozzLs0MpQNuZUa1B4lxli92LoM9IU.cache +0 -0
  29. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/2vtf3xYze_e_euHmn-hKXkaf1N9QFJcfLQ-thqQIpCM.cache +1 -0
  30. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/30oJ0uLM-lbfz_v5bVAPmVdKcoeaFd_n37s_T5D15JY.cache +1 -0
  31. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/46-vkCu8PWZkn9ZpLVB6W8jVaWTksXpo9C0pokYYF_A.cache +1 -0
  32. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/4EtnSo_Th82xV24bpCIVtDFM3mQAswdprew5ls10Rw8.cache +0 -0
  33. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/5n3X-EDmHz8Tabsmi6-vMUhAyWF7Gw52rszLxx9gfEc.cache +0 -0
  34. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/7cfFiFYfzhZS4ja6Lua5PgRvHYPpPgrYERFDXUE4tt0.cache +1 -0
  35. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/86AMcjHILhoW6Ydej6dJPi-AtDF33ET69o8FBWHA5eM.cache +2 -0
  36. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/8cROEJzplYgaGRvO8FMhFa7NGr-X4rOQowoNRr7QkCA.cache +0 -0
  37. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/95rP4g0XwNe-jvOqVuhu8Aq8XnGx0_spZMRUnxVK4rQ.cache +1 -0
  38. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/AWh8nMypPHxQw9Jr-wy_Ti105yIAGvfdr3QmUaUVvyY.cache +0 -0
  39. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/CRTcOVUp4lPo5eHQH6Rv4wMyMvTo7k_lPzToh5-nN34.cache +1 -0
  40. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/EnSWJJBNk0fqZ5cK_U7gHwW9i-s_oNZxGerZtV3-8so.cache +1 -0
  41. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/FYJVLwODNp0hdl9eA2qte_tSZOshT-N3KyjceYcuJbE.cache +1 -0
  42. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/G79nJLeD-JPKH7BjujHFHLDqPEjk6NgXv7IMD9B7PEs.cache +1 -0
  43. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Gn-Obq1PaNoJjfbeHqV1mmsxYof67dxMJzt-7KWCA48.cache +2 -0
  44. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/H8B55t5wL8VTMMrw5mOHFSjEaYKkN1D9PMoKe3R0RYI.cache +2 -0
  45. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/IxcWKLw03vNA2GQULE41i9svYR3iaSNNPXs1vHpv-Ds.cache +1 -0
  46. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/JykP3tRDo-dlwhLKWakjPkzSd14YgwGxAvrNKD5g0jM.cache +0 -0
  47. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/LUB3K5uHpYLWu3JABZJclGoeG8gryFjVimUu54PrzC0.cache +1 -0
  48. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/MojUcybBaIO_LmmWHShBfQptMlsM8gfJ0jdRQsV64Sg.cache +1 -0
  49. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/NcxzHeUmBpIvB4SnqkgIrLvvSbWe6akmo7QzyV2ORKE.cache +1 -0
  50. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/QWvkvBZbmkuqLhpn_vDx-JdpXZfo3qajx9AiIDBW0MI.cache +0 -0
  51. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/QlF1LVJmzEjJZ_XZrtnSh3X_vOj6pfd7ES9j5A_JyK4.cache +1 -0
  52. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Rpryrbij45d-lz4W3WrxrsTkdQ4PLPkXrUVotjrh_uU.cache +1 -0
  53. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/U97QhK4FCXzO0jWdgHCUs9mKclGsDOvUv-rjJ68LtPE.cache +2 -0
  54. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/UdrBpa1nvvNBDj_Wy8z1Hrh-qnm94uDYtuDdv_JCLDo.cache +2 -0
  55. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/UtLA-9KECN-IQLSaz0KtV384hgZlykIi_Eas1xZMpuM.cache +0 -0
  56. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/WDbX-T1fI0qdGGAalYwtkmbYOKeUrY1cUQxGHktQyZ8.cache +2 -0
  57. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/WndJZZR2EZGyBpBGjSuHU0zqovCkbYzUz4L6oP1Ze_k.cache +3 -0
  58. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/XMjRE3gJ4NZRRE6iDIDAX4dTpceH_TkVRIWJdx0Ypao.cache +1 -0
  59. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/YXURUnPPzEpUalltB2Fi-rL3KVnQMg483z6V2360TqI.cache +0 -0
  60. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/YaO8NY6DL0H3_SRhUt78Lqzwmle9sy6JWmLBmxv48SY.cache +1 -0
  61. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Yq0QHHdCrq_cV2ueoB42XQS4VMnkDlHa2rNRxYjZATQ.cache +1 -0
  62. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/YtFIywV6ZZgq77LB_X-cAC2ijoIWIcT578cwrj3o-l4.cache +0 -0
  63. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/_YSKxiD1-YmqmjZ9fuGFg3dWe8fdnoASHnNvcnjGdLI.cache +2 -0
  64. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/_aG03Ap0NF9pgU2hfYFlc9KccAHGw-bNghz6LgYHY8c.cache +1 -0
  65. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/_dLtoV1obg-lz2082zkn2rdha3Hl-YT07tXj47vY4QY.cache +1 -0
  66. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/atN-fkru6IQAezOmasmVvSoTv3Wv72-pNWph5Kw1eBg.cache +1 -0
  67. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/bbPo8s_sB37tJ7kJ4RyzM1KGetASkM6MVO-_m2-VARQ.cache +1 -0
  68. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/bxTdMStWbzJOMAWrAuzYml52rNuPMmFEUnGTD5sFRRg.cache +0 -0
  69. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/d3FTq4GqvXRsts7pyCDvVH9MLT4LTeS9abXTkRYucz0.cache +0 -0
  70. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/d74krkF9Cd951GUgf_6nbkGYsEBI7ku_mLdYDQCGKpQ.cache +1 -0
  71. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/dBH2ix-2urXggwjcPF_y9QNab57c1hw-jtuehm_5qNA.cache +1 -0
  72. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/f0YSbcKLuCO_hlGwGTvnMJttQjrjw-5gUaWDW-Q4zao.cache +1 -0
  73. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/fxvrIgOxjrSSIGQmqyPAWYTFbDypc0DKG4TJd6Y2Mtw.cache +1 -0
  74. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/isc6UFf-rgvcpTogrWLXYRSLSGvPFKpnUHgCc0qA7Eg.cache +2 -0
  75. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/izr8yqsAK6K92dIGZRKuDiMiZx4ck5SLfH2r2p6FKDc.cache +2 -0
  76. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/jb6230tpxJ8f-mwEQKE0G4dCUxfkoVIG5DtGM87NezE.cache +2 -0
  77. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lCtDEw-I_xDrdP07iggk7gupVD08C-Z2m8_LngxMB64.cache +1 -0
  78. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lV_yi5oqwDSeg6tJ38Vh9vFbzYtSZoeZJAsPCcCL_WY.cache +1 -0
  79. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/m_KoMFPYzMsgBl6U9ks26UHmvQWIfpSaOS7Vz18VY-M.cache +2 -0
  80. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/mdh0IkLFG7jg5eqrWxc9ZIZuOXetyWUgv4b6RNnEKD0.cache +1 -0
  81. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/mwaSsWk6l38Phmm1l-Mgdj6ald6IxKV2zIJu_9SvFoc.cache +1 -0
  82. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/oD5Ypm1kW3mrhrVFsYB7MbyWZ_RqxHR7br1kOkw62zw.cache +2 -0
  83. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/oZP725oqyU-YncLimGuiBNv6yPK1aWRZm7ukFxhkd_M.cache +0 -0
  84. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/p2jG3M5u64qLdKO9yIuV5gCiI4zZKrGUpQoVR7Z--ow.cache +0 -0
  85. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/rPmABz0raf_Mu_97pCTl8Uya3_-Jhe4A2SkK-nd8bVQ.cache +0 -0
  86. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/rWDXz_CSbq9uDD0fKrOSsVptQq39bguaHY6In8DDSWQ.cache +1 -0
  87. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/rf5Isz_x5fsKXcFFa5fhiiuv82UJ4KmXMgmIHuzUm6Y.cache +2 -0
  88. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/teXUFwvXVeqbgfbn2XHcbyqpH-zEiAqiBS6ChPrGd7g.cache +1 -0
  89. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/u3rOpKGjiC2TUdXscpbvWV1mIX6a2ke3AzOs3P399Tg.cache +1 -0
  90. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/uye7NSNO_OcSvQUrsq7lNhTRLM836fZvnJ0jL6RDA4I.cache +4 -0
  91. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/uzXujFw3PjvZJwMgNJrA5ag6Z9fiNHspr6c7jgM7Ks4.cache +3 -0
  92. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/v8aDJ_EQvR3Q6nybmTZaPNVTXWtIcyrkLx7Urs8Phd4.cache +1 -0
  93. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/vhgYr1BLQ040FQlkDqVMCHf-0R_4EuvRHHlkm4QddB0.cache +1 -0
  94. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/vtQhRwbOcptuIq7UX7gB7Rr4LnXCHg8aUOy4KguJIK8.cache +0 -0
  95. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/w1AI9gwwe3XLpBUYzoRc-UP-V17niN55m8unhZ2UErY.cache +0 -0
  96. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/yYaAYovuuNuS764JTyJfia3YbEwE6D9I0WtXfJF-9cI.cache +0 -0
  97. data/spec/dummy/tmp/pids/server.pid +1 -0
  98. data/spec/services/process_importer_spec.rb +60 -0
  99. data/spec/support/jsons/process_template.json +91 -0
  100. metadata +189 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 893a6a3e14e7217742d45741be44769220f99871
4
- data.tar.gz: 31a32021e3f545687726f713ee34b0302e2e29be
3
+ metadata.gz: 0a4a91bde072f32b2d60750cd516e78436d0f40c
4
+ data.tar.gz: ad83c4e78cdb420eab39a914602b10cddbdf1c6f
5
5
  SHA512:
6
- metadata.gz: 43979534a048ffaca99fa76e71bbe5f513857ebc2f65d05142433fcb0235bae5a3855164f775e6141339ffd6d41bb3d3471c4ad871067bd1a116b75c14e6764c
7
- data.tar.gz: 7ba7700fd44f0feb760c86f36cdf3ef6ce818f5ae9e839121cb003a15fdb5591c0abc8ef872449f33bcd7f00d693ae0245b10566e221ec823487e201d8d888ad
6
+ metadata.gz: 263eda34d917a4f69ffa40dd16d6570bdad760c6512f256bd915b167622d7ce14d1820ff3b321ff1407bfd70d76e1aaf916d68551ed79a14e2881bafb6d5aa08
7
+ data.tar.gz: d9e44b26185ee60e66b48b01dbeda448be9ca018ec7db78dd7d2d7fda4e846697eac12466f02e263503c97617b846b1153c3a13dc8a7a3f064c1caefec5f6c25
@@ -195,3 +195,27 @@ body {
195
195
  .alert {
196
196
  border-radius: 4px;
197
197
  }
198
+
199
+ .btn-file {
200
+ position: relative;
201
+ overflow: hidden;
202
+ }
203
+ .btn-file input[type=file] {
204
+ position: absolute;
205
+ top: 0;
206
+ right: 0;
207
+ min-width: 100%;
208
+ min-height: 100%;
209
+ font-size: 100px;
210
+ text-align: right;
211
+ filter: alpha(opacity=0);
212
+ opacity: 0;
213
+ outline: none;
214
+ background: white;
215
+ cursor: inherit;
216
+ display: block;
217
+ }
218
+
219
+ .float-right {
220
+ float: right;
221
+ }
@@ -0,0 +1,14 @@
1
+ module RailsWorkflow::Uuid
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_save :generate_guid
6
+ end
7
+
8
+ def generate_guid
9
+ if uuid.blank?
10
+ self.uuid = Guid.new.to_s
11
+ end
12
+
13
+ end
14
+ end
@@ -1,7 +1,7 @@
1
1
  module RailsWorkflow
2
2
  class ProcessTemplatesController < ::ActionController::Base
3
3
  layout 'rails_workflow/application'
4
- respond_to :html
4
+ respond_to :html, :json
5
5
 
6
6
  before_action :set_process_template, only: [:show, :edit, :update, :destroy]
7
7
 
@@ -9,6 +9,21 @@ module RailsWorkflow
9
9
  @config_section_active = true
10
10
  end
11
11
 
12
+ def upload
13
+ uploaded = params[:import_file]
14
+
15
+ json = JSON.parse(uploaded.read)
16
+
17
+ importer = RailsWorkflow::ProcessImporter.new(json)
18
+ importer.process
19
+
20
+ redirect_to process_templates_path
21
+ end
22
+
23
+ def export
24
+ template = ProcessTemplate.find(params[:id])
25
+ send_data render_to_string(json: template, serializer: ProcessTemplateSerializer), filename: "#{template.title}.json"
26
+ end
12
27
 
13
28
  def index
14
29
  @process_templates = ProcessTemplateDecorator.
@@ -1,6 +1,7 @@
1
1
  module RailsWorkflow
2
2
  class OperationTemplate < ActiveRecord::Base
3
3
  include OperationStatus
4
+ include RailsWorkflow::Uuid
4
5
  include OperationTemplates::Dependencies
5
6
  include OperationTemplates::Assignments
6
7
  include OperationTemplates::DefaultBuilder
@@ -1,7 +1,7 @@
1
1
  module RailsWorkflow
2
2
  class ProcessTemplate < ActiveRecord::Base
3
3
  include ProcessTemplates::DefaultBuilder
4
-
4
+ include RailsWorkflow::Uuid
5
5
  has_many :operations, :class_name => 'OperationTemplate'
6
6
 
7
7
 
@@ -0,0 +1,21 @@
1
+ module RailsWorkflow
2
+ class OperationTemplateSerializer < ActiveModel::Serializer
3
+ attributes :uuid, :title, :source, :dependencies, :operation_class,
4
+ :async, :assignment_id, :assignment_type, :kind, :role, :group, :instruction,
5
+ :is_background, :type, :partial_name, :version, :tag
6
+
7
+ has_one :child_process, serializer: RailsWorkflow::OperationTemplateSerializer
8
+
9
+ def dependencies
10
+ object.dependencies.each do |d|
11
+ d['uuid'] = OperationTemplate.find(d['id']).uuid
12
+ d.delete("id")
13
+ end
14
+ end
15
+
16
+ def operation_class
17
+ object.read_attribute :operation_class
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ module RailsWorkflow
2
+ class ProcessTemplateSerializer < ActiveModel::Serializer
3
+ attributes :uuid, :title, :source,
4
+ :manager_class, :process_class, :type,
5
+ :partial_name, :version, :tag
6
+
7
+ has_many :operations, serializer: RailsWorkflow::OperationTemplateSerializer
8
+
9
+
10
+ def process_class
11
+ object.read_attribute :process_class
12
+ end
13
+
14
+ def manager_class
15
+ object.read_attribute :manager_class
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,48 @@
1
+ module RailsWorkflow
2
+ class ProcessImporter
3
+ def initialize json
4
+ @json = json['process_template']
5
+ end
6
+
7
+ def process
8
+ process = ProcessTemplate.
9
+ where(uuid: @json['uuid']).first_or_create!
10
+
11
+ process.attributes = @json.except('operations')
12
+ process.save
13
+
14
+ operations = []
15
+ ids_to_delete = process.operations.pluck(:id)
16
+
17
+ @json['operations'].each do |operation_json|
18
+
19
+ operation = process.
20
+ operations.where(uuid: operation_json['uuid']).first_or_create!
21
+
22
+ operation.attributes = operation_json
23
+ operation.save
24
+
25
+ ids_to_delete.delete(operation.id)
26
+ operations << operation
27
+ end
28
+
29
+
30
+ OperationTemplate.delete(ids_to_delete) if ids_to_delete.present?
31
+
32
+
33
+ operations.each do |operation|
34
+ operation.dependencies.each do |d|
35
+ d['id'] = OperationTemplate.
36
+ find_by_uuid(operation['uuid']).try(:id)
37
+
38
+ d.delete("uuid")
39
+ end
40
+
41
+ operation.save
42
+ end
43
+
44
+
45
+ end
46
+ end
47
+ end
48
+
@@ -48,4 +48,8 @@ body
48
48
  | &nbsp;&bull;
49
49
  span<>= mail_to "max.madzhuga@gmail.com", "Contact me", subject: "Workflow Support"
50
50
  | &bull;
51
+ span<>
52
+ a href="https://twitter.com/max_madzhuga" @max_madzhuga
53
+ | &bull;
54
+
51
55
  span<>= link_to "Rails Workflow Site", 'http://madzhuga.github.io/rails_workflow/'
@@ -69,6 +69,11 @@ ol.breadcrumb.alert-warning
69
69
  li
70
70
  = link_to value[:title], new_template_path.call(type)
71
71
 
72
+
73
+ br
74
+ br
75
+ .btn-group
76
+ = link_to 'Export', export_process_template_path(@process_template), class: "btn btn-primary"
72
77
  br
73
78
  br
74
79
  .btn-group
@@ -10,6 +10,12 @@ ol.breadcrumb.alert-warning
10
10
  h1.panel-title Templates Configuration
11
11
 
12
12
  .panel-body
13
+ .float-right
14
+ = form_tag({action: :upload}, multipart: true) do
15
+ span.btn.btn-default.btn-file<>
16
+ | Select File to Import
17
+ = file_field_tag 'import_file'
18
+ = submit_tag 'Send File', class: 'btn btn-success'
13
19
 
14
20
  table.table.table-striped.table-hover
15
21
  thead
@@ -58,6 +58,10 @@ ol.breadcrumb.alert-warning
58
58
  = link_to 'Edit', edit_process_template_path(@process_template), class: "btn btn-primary"
59
59
  br
60
60
  br
61
+ .btn-group
62
+ = link_to 'Export', export_process_template_path(@process_template), class: "btn btn-primary"
63
+ br
64
+ br
61
65
  .btn-group
62
66
  = link_to 'Operations', process_template_operation_templates_path(@process_template), class: "btn btn-primary"
63
67
 
data/config/routes.rb CHANGED
@@ -28,6 +28,12 @@ RailsWorkflow::Engine.routes.draw do
28
28
 
29
29
  resources :process_templates, path: 'config' do
30
30
  resources :operation_templates
31
+ member do
32
+ get :export
33
+ end
34
+ collection do
35
+ post :upload
36
+ end
31
37
  end
32
38
  root to: 'operations#index'
33
39
  end
@@ -0,0 +1,155 @@
1
+ class CreateWorkflowProcesses < ActiveRecord::Migration
2
+ def change
3
+ create_tables
4
+ create_columns
5
+ check_json_columns
6
+ create_indexes
7
+ end
8
+
9
+ def create_tables
10
+ [
11
+ [:workflow_processes, :rails_workflow_processes],
12
+ [:workflow_operations, :rails_workflow_operations],
13
+ [:workflow_process_templates, :rails_workflow_process_templates],
14
+ [:workflow_operation_templates, :rails_workflow_operation_templates],
15
+ [:workflow_contexts, :rails_workflow_contexts],
16
+ [:workflow_errors, :rails_workflow_errors]
17
+ ].map do |names|
18
+ if table_exists? names[0]
19
+ rename_table names[0], names[1]
20
+ end
21
+
22
+ create_table names[1] unless table_exists? names[1]
23
+ end
24
+
25
+ end
26
+
27
+ def create_indexes
28
+ [
29
+ [:rails_workflow_contexts, [:parent_id, :parent_type]],
30
+ [:rails_workflow_errors, [:parent_id, :parent_type]],
31
+ [:rails_workflow_operation_templates, :process_template_id],
32
+ [:rails_workflow_operation_templates, :uuid],
33
+ [:rails_workflow_process_templates, :uuid],
34
+ [:rails_workflow_operations, :process_id],
35
+ [:rails_workflow_operations, :template_id]
36
+ ].each do |idx|
37
+ unless index_exists? idx[0], idx[1]
38
+ add_index idx[0], idx[1]
39
+ end
40
+ end
41
+ end
42
+
43
+ def create_columns
44
+ {
45
+ :rails_workflow_contexts => [
46
+ [:integer, :parent_id],
47
+ [:string, :parent_type],
48
+ [:json, :body],
49
+ [:datetime, :created_at],
50
+ [:datetime, :updated_at],
51
+ ],
52
+
53
+ :rails_workflow_errors => [
54
+ [:string, :message],
55
+ [:text, :stack_trace],
56
+ [:integer, :parent_id],
57
+ [:string, :parent_type],
58
+ [:datetime, :created_at],
59
+ [:datetime, :updated_at],
60
+ [:boolean, :resolved]
61
+ ],
62
+
63
+ :rails_workflow_operation_templates => [
64
+ [:string, :title],
65
+ [:string, :version],
66
+ [:uuid, :uuid],
67
+ [:string, :tag],
68
+ [:text, :source],
69
+ [:json, :dependencies],
70
+ [:string, :operation_class],
71
+ [:integer, :process_template_id],
72
+ [:datetime, :created_at],
73
+ [:datetime, :updated_at],
74
+ [:boolean, :async],
75
+ [:integer, :child_process_id],
76
+ [:integer, :assignment_id],
77
+ [:string, :assignment_type],
78
+ [:string, :kind],
79
+ [:string, :role],
80
+ [:string, :group],
81
+ [:text, :instruction],
82
+ [:boolean, :is_background],
83
+ [:string, :type],
84
+ [:string, :partial_name],
85
+ ],
86
+
87
+ :rails_workflow_operations => [
88
+ [:integer, :status],
89
+ [:boolean, :async],
90
+ [:string, :version],
91
+ [:string, :tag],
92
+ [:string, :title],
93
+ [:datetime, :created_at],
94
+ [:datetime, :updated_at],
95
+ [:integer, :process_id],
96
+ [:integer, :template_id],
97
+ [:json, :dependencies],
98
+ [:integer, :child_process_id],
99
+ [:integer, :assignment_id],
100
+ [:string, :assignment_type],
101
+ [:datetime, :assigned_at],
102
+ [:string, :type],
103
+ [:boolean, :is_active],
104
+ [:datetime, :completed_at],
105
+ [:boolean, :is_background]
106
+ ],
107
+
108
+ :rails_workflow_process_templates => [
109
+ [:string, :title],
110
+ [:text, :source],
111
+ [:uuid, :uuid],
112
+ [:string, :version],
113
+ [:string, :tag],
114
+ [:string, :manager_class],
115
+ [:string, :process_class],
116
+ [:datetime, :created_at],
117
+ [:datetime, :updated_at],
118
+ [:string, :type],
119
+ [:string, :partial_name]
120
+ ],
121
+
122
+ :rails_workflow_processes => [
123
+ [:integer, :status],
124
+ [:string, :version],
125
+ [:string, :tag],
126
+ [:boolean, :async],
127
+ [:string, :title],
128
+ [:datetime, :created_at],
129
+ [:datetime, :updated_at],
130
+ [:integer, :template_id],
131
+ [:string, :type]
132
+ ]
133
+ }.each do |table, columns|
134
+ columns.map do |column|
135
+ unless column_exists? table, column[1]
136
+ add_column table, column[1], column[0]
137
+ end
138
+ end
139
+
140
+ end
141
+
142
+ end
143
+
144
+ def check_json_columns
145
+ [
146
+ [RailsWorkflow::Operation, :dependencies],
147
+ [RailsWorkflow::OperationTemplate, :dependencies],
148
+ [RailsWorkflow::Context, :body]
149
+ ].map do |check|
150
+ if check[0].columns_hash[check[1].to_s].sql_type != "json"
151
+ change_column check[0].table_name, check[1], "JSON USING #{check[1]}::JSON"
152
+ end
153
+ end
154
+ end
155
+ end
@@ -29,6 +29,8 @@ class CreateWorkflowProcesses < ActiveRecord::Migration
29
29
  [:rails_workflow_contexts, [:parent_id, :parent_type]],
30
30
  [:rails_workflow_errors, [:parent_id, :parent_type]],
31
31
  [:rails_workflow_operation_templates, :process_template_id],
32
+ [:rails_workflow_operation_templates, :uuid],
33
+ [:rails_workflow_process_templates, :uuid],
32
34
  [:rails_workflow_operations, :process_id],
33
35
  [:rails_workflow_operations, :template_id]
34
36
  ].each do |idx|
@@ -61,6 +63,8 @@ class CreateWorkflowProcesses < ActiveRecord::Migration
61
63
  :rails_workflow_operation_templates => [
62
64
  [:string, :title],
63
65
  [:string, :version],
66
+ [:uuid, :uuid],
67
+ [:string, :tag],
64
68
  [:text, :source],
65
69
  [:json, :dependencies],
66
70
  [:string, :operation_class],
@@ -104,7 +108,9 @@ class CreateWorkflowProcesses < ActiveRecord::Migration
104
108
  :rails_workflow_process_templates => [
105
109
  [:string, :title],
106
110
  [:text, :source],
111
+ [:uuid, :uuid],
107
112
  [:string, :version],
113
+ [:string, :tag],
108
114
  [:string, :manager_class],
109
115
  [:string, :process_class],
110
116
  [:datetime, :created_at],
@@ -10,13 +10,6 @@ module RailsWorkflow
10
10
  g.helper false
11
11
  end
12
12
 
13
- initializer :append_migrations do |app|
14
- unless app.root.to_s.match root.to_s
15
- config.paths["db/migrate"].expanded.each do |expanded_path|
16
- app.config.paths["db/migrate"] << expanded_path
17
- end
18
- end
19
- end
20
13
 
21
14
  end
22
15
  end
@@ -1,3 +1,3 @@
1
1
  module RailsWorkflow
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -10,6 +10,7 @@ defaults: &defaults
10
10
  development:
11
11
  <<: *defaults
12
12
  database: wf_def
13
+ # database: wf_dev
13
14
 
14
15
  test: &test
15
16
  <<: *defaults
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20150217161051) do
14
+ ActiveRecord::Schema.define(version: 20150625034602) do
15
15
 
16
16
  # These are extensions that must be enabled in order to support this database
17
17
  enable_extension "plpgsql"
@@ -44,6 +44,8 @@ ActiveRecord::Schema.define(version: 20150217161051) do
44
44
  t.boolean "resolved"
45
45
  end
46
46
 
47
+ add_index "rails_workflow_errors", ["parent_id", "parent_type"], name: "index_rails_workflow_errors_on_parent_id_and_parent_type", using: :btree
48
+
47
49
  create_table "rails_workflow_operation_templates", force: :cascade do |t|
48
50
  t.string "title"
49
51
  t.text "source"
@@ -63,8 +65,14 @@ ActiveRecord::Schema.define(version: 20150217161051) do
63
65
  t.boolean "is_background", default: true
64
66
  t.string "type"
65
67
  t.string "partial_name"
68
+ t.string "version"
69
+ t.uuid "uuid"
70
+ t.string "tag"
66
71
  end
67
72
 
73
+ add_index "rails_workflow_operation_templates", ["process_template_id"], name: "index_rails_workflow_operation_templates_on_process_template_id", using: :btree
74
+ add_index "rails_workflow_operation_templates", ["uuid"], name: "index_rails_workflow_operation_templates_on_uuid", using: :btree
75
+
68
76
  create_table "rails_workflow_operations", force: :cascade do |t|
69
77
  t.integer "status"
70
78
  t.boolean "async"
@@ -82,8 +90,13 @@ ActiveRecord::Schema.define(version: 20150217161051) do
82
90
  t.boolean "is_active"
83
91
  t.datetime "completed_at"
84
92
  t.boolean "is_background"
93
+ t.string "version"
94
+ t.string "tag"
85
95
  end
86
96
 
97
+ add_index "rails_workflow_operations", ["process_id"], name: "index_rails_workflow_operations_on_process_id", using: :btree
98
+ add_index "rails_workflow_operations", ["template_id"], name: "index_rails_workflow_operations_on_template_id", using: :btree
99
+
87
100
  create_table "rails_workflow_process_templates", force: :cascade do |t|
88
101
  t.string "title"
89
102
  t.text "source"
@@ -93,8 +106,13 @@ ActiveRecord::Schema.define(version: 20150217161051) do
93
106
  t.datetime "updated_at"
94
107
  t.string "type"
95
108
  t.string "partial_name"
109
+ t.uuid "uuid"
110
+ t.string "version"
111
+ t.string "tag"
96
112
  end
97
113
 
114
+ add_index "rails_workflow_process_templates", ["uuid"], name: "index_rails_workflow_process_templates_on_uuid", using: :btree
115
+
98
116
  create_table "rails_workflow_processes", force: :cascade do |t|
99
117
  t.integer "status"
100
118
  t.boolean "async"
@@ -103,6 +121,8 @@ ActiveRecord::Schema.define(version: 20150217161051) do
103
121
  t.datetime "updated_at"
104
122
  t.integer "template_id"
105
123
  t.string "type"
124
+ t.string "version"
125
+ t.string "tag"
106
126
  end
107
127
 
108
128
  create_table "sales_contacts", force: :cascade do |t|