easy_flow 0.22.0 → 0.24.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c1b56b170c92f6fa9d7c2edc9864de42dfaef4dc97d41822442ca289722a91e
4
- data.tar.gz: b4aa7640c10adcac242e412837870517ad688c463624d7f53dea366e4b6d0e96
3
+ metadata.gz: 420a32e8886e881ee02d50a95fef57640e8a2d540d1d73313b2a9fdd66206d6b
4
+ data.tar.gz: 380a7ef18cf5f6af36ff32d5573a5ee7e70b680582e147ec30ede62d23635e5b
5
5
  SHA512:
6
- metadata.gz: 6a9ea816b147d6782cdc106113aeae7d95b0396679f920203afafad68f130a5895efb9ba0a020a7c55438260c2d8a782d58399a2aefd97574467be10255b5fe8
7
- data.tar.gz: 1084833772e7cea7306b369543e362d46fa552222bb398ae1bd0edc7d52aa4d7bc20ddeaac3021f301d2b9e65c662e195a489e96d09653b3b54840ffd345f364
6
+ metadata.gz: ccb487775af4e1ec1737ac27be7a46a6bb53fd804c14c8ed41b7ba8102d5001fc61311d55830ae5570178df79cbca3223071d255c5b812a2b1f30e1a86e2eb23
7
+ data.tar.gz: 01445f50ff3f85db4b67c38e66911bc8960ea9d17741af9c5f144d5b2320e14d649d44c335f35385844706e2aca312f2ef9ffe6308bfd49d0f07bd9d6af6badf
@@ -6,7 +6,7 @@ module EasyFlow
6
6
  private
7
7
 
8
8
  def canvas_payload(flow)
9
- Canvas.new(canvas_document(flow), host: flow_host, flows: hosted_flows.order(:title), flow_path: ->(id) { manage_flow_path(id, from: flow.id) }, flow: flow).to_h
9
+ Canvas.new(canvas_document(flow), host: flow_host, flows: hosted_flows.order(:title), flow_path: ->(id) { manage_flow_path(hosted_flows.find_by(id: id) || id, from: flow) }, flow: flow).to_h
10
10
  .merge("undoable" => flow.edit_history.undoable?, "redoable" => flow.edit_history.redoable?,
11
11
  "changes" => listed_changes(flow), "flow" => flow_details(flow))
12
12
  end
@@ -53,7 +53,7 @@ module EasyFlow
53
53
  end
54
54
 
55
55
  def find_run(runs, address)
56
- runs.find(address)
56
+ runs.find_by_public_code!(address)
57
57
  end
58
58
 
59
59
  def start_run(flow)
@@ -83,7 +83,7 @@ module EasyFlow
83
83
  end
84
84
 
85
85
  def flow
86
- @flow ||= hosted_flows.find(params[:flow_id])
86
+ @flow ||= hosted_flows.find_by_public_code!(params[:flow_id])
87
87
  end
88
88
 
89
89
  def document
@@ -2,11 +2,11 @@ module EasyFlow
2
2
  module Manage
3
3
  class DefinitionsController < BaseController
4
4
  def edit
5
- @flow = hosted_flows.find(params[:flow_id])
5
+ @flow = hosted_flows.find_by_public_code!(params[:flow_id])
6
6
  end
7
7
 
8
8
  def update
9
- @flow = hosted_flows.find(params[:flow_id])
9
+ @flow = hosted_flows.find_by_public_code!(params[:flow_id])
10
10
  @flow.edit_history.edit_document(JSON.parse(params.require(:definition)))
11
11
  redirect_to manage_flow_path(@flow), notice: "Definition saved."
12
12
  end
@@ -21,23 +21,23 @@ module EasyFlow
21
21
  end
22
22
 
23
23
  def show
24
- @flow = hosted_flows.find(params[:id])
25
- @parent = hosted_flows.find_by(id: params[:from])
24
+ @flow = hosted_flows.find_by_public_code!(params[:id])
25
+ @parent = parent_flow
26
26
  @canvas = canvas_payload(@flow)
27
27
  end
28
28
 
29
29
  def edit
30
- @flow = hosted_flows.find(params[:id])
30
+ @flow = hosted_flows.find_by_public_code!(params[:id])
31
31
  end
32
32
 
33
33
  def update
34
- @flow = hosted_flows.find(params[:id])
34
+ @flow = hosted_flows.find_by_public_code!(params[:id])
35
35
  @flow.update!(flow_params)
36
36
  redirect_to manage_flow_path(@flow), notice: "Saved."
37
37
  end
38
38
 
39
39
  def destroy
40
- flow = hosted_flows.find(params[:id])
40
+ flow = hosted_flows.find_by_public_code!(params[:id])
41
41
  return redirect_to manage_flows_path, alert: flow.errors.full_messages.to_sentence unless flow.destroy
42
42
 
43
43
  redirect_to manage_flows_path, notice: "Flow removed."
@@ -45,6 +45,12 @@ module EasyFlow
45
45
 
46
46
  private
47
47
 
48
+ def parent_flow
49
+ hosted_flows.find_by_public_code!(params[:from]) if params[:from].present?
50
+ rescue ActiveRecord::RecordNotFound
51
+ nil
52
+ end
53
+
48
54
  def ordered_flows
49
55
  hosted_flows.order(:slug)
50
56
  end
@@ -27,7 +27,7 @@ module EasyFlow
27
27
  end
28
28
 
29
29
  def previewed
30
- @previewed ||= hosted_flows.find(params[:flow_id])
30
+ @previewed ||= hosted_flows.find_by_public_code!(params[:flow_id])
31
31
  end
32
32
 
33
33
  def admit(_flow)
@@ -7,7 +7,7 @@ module EasyFlow
7
7
  end
8
8
 
9
9
  def return
10
- flow.return_to(flow.definition_versions.find(params[:id]))
10
+ flow.return_to(flow.definition_versions.find_by_public_code!(params[:id]))
11
11
 
12
12
  redirect_to manage_flow_path(flow), notice: "The flow is back to that version."
13
13
  end
@@ -15,7 +15,7 @@ module EasyFlow
15
15
  private
16
16
 
17
17
  def flow
18
- @flow ||= hosted_flows.find(params[:flow_id])
18
+ @flow ||= hosted_flows.find_by_public_code!(params[:flow_id])
19
19
  end
20
20
  end
21
21
  end
@@ -2,6 +2,8 @@ module EasyFlow
2
2
  class Definition < ApplicationRecord
3
3
  self.table_name = "easy_flow_definitions"
4
4
 
5
+ has_public_code
6
+
5
7
  enum :status, { active: "active", hidden: "hidden", inactive: "inactive" }
6
8
  enum :kind, { scored: "scored", guide: "guide" }
7
9
  enum :persists, { unsaved: "unsaved", each_step: "each_step", on_finish: "on_finish" }
@@ -2,6 +2,8 @@ module EasyFlow
2
2
  class Run < ApplicationRecord
3
3
  self.table_name = "easy_flow_runs"
4
4
 
5
+ has_public_code
6
+
5
7
  belongs_to :flow, class_name: "EasyFlow::Definition"
6
8
  belongs_to :definition_version, class_name: "EasyFlow::Version"
7
9
  belongs_to :owner, polymorphic: true, optional: true
@@ -2,6 +2,8 @@ module EasyFlow
2
2
  class Version < ApplicationRecord
3
3
  self.table_name = "easy_flow_versions"
4
4
 
5
+ has_public_code
6
+
5
7
  enum :status, { draft: "draft", live: "live", superseded: "superseded",
6
8
  retired: "retired", withdrawn: "withdrawn" }
7
9
 
@@ -0,0 +1,17 @@
1
+ class AddPublicCodeToEasyFlowRuns < ActiveRecord::Migration[8.1]
2
+ class Run < ActiveRecord::Base
3
+ self.table_name = "easy_flow_runs"
4
+ end
5
+
6
+ def up
7
+ add_column :easy_flow_runs, :public_code, :string
8
+ Run.reset_column_information
9
+ Run.find_each { |run| run.update_columns(public_code: PublicCode.generate) }
10
+ change_column_null :easy_flow_runs, :public_code, false
11
+ add_index :easy_flow_runs, :public_code, unique: true
12
+ end
13
+
14
+ def down
15
+ remove_column :easy_flow_runs, :public_code
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class AddPublicCodeToEasyFlowDefinitions < ActiveRecord::Migration[8.1]
2
+ class Record < ActiveRecord::Base
3
+ self.table_name = "easy_flow_definitions"
4
+ end
5
+
6
+ def up
7
+ add_column :easy_flow_definitions, :public_code, :string
8
+ Record.reset_column_information
9
+ Record.find_each { |record| record.update_columns(public_code: PublicCode.generate) }
10
+ change_column_null :easy_flow_definitions, :public_code, false
11
+ add_index :easy_flow_definitions, :public_code, unique: true
12
+ end
13
+
14
+ def down
15
+ remove_column :easy_flow_definitions, :public_code
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class AddPublicCodeToEasyFlowVersions < ActiveRecord::Migration[8.1]
2
+ class Record < ActiveRecord::Base
3
+ self.table_name = "easy_flow_versions"
4
+ end
5
+
6
+ def up
7
+ add_column :easy_flow_versions, :public_code, :string
8
+ Record.reset_column_information
9
+ Record.find_each { |record| record.update_columns(public_code: PublicCode.generate) }
10
+ change_column_null :easy_flow_versions, :public_code, false
11
+ add_index :easy_flow_versions, :public_code, unique: true
12
+ end
13
+
14
+ def down
15
+ remove_column :easy_flow_versions, :public_code
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module EasyFlow
2
- VERSION = "0.22.0"
2
+ VERSION = "0.24.0"
3
3
  end
data/lib/easy_flow.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "json"
2
+ require "public_code"
2
3
  require "easy_flow/version"
3
4
  require "easy_flow/host"
4
5
  require "easy_flow/unset_host"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -23,6 +23,20 @@ dependencies:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: 8.1.3
26
+ - !ruby/object:Gem::Dependency
27
+ name: public_code
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.2'
26
40
  - !ruby/object:Gem::Dependency
27
41
  name: keystone_ui-react
28
42
  requirement: !ruby/object:Gem::Requirement
@@ -151,6 +165,9 @@ files:
151
165
  - db/migrate/20261001120000_add_owner_to_easy_flow_definitions.rb
152
166
  - db/migrate/20261007120000_add_parent_run_to_easy_flow_runs.rb
153
167
  - db/migrate/20261011130000_keep_step_visits_whole_in_easy_flow_runs.rb
168
+ - db/migrate/20261012200000_add_public_code_to_easy_flow_runs.rb
169
+ - db/migrate/20261012210000_add_public_code_to_easy_flow_definitions.rb
170
+ - db/migrate/20261012210100_add_public_code_to_easy_flow_versions.rb
154
171
  - lib/easy_flow.rb
155
172
  - lib/easy_flow/engine.rb
156
173
  - lib/easy_flow/host.rb