easy_flow 0.23.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: 81c0c3c1f15a0c2791aef81b34ea0e04562ccb4b6a4b79ed7299c044d8f6a523
4
- data.tar.gz: f60e7006ea24aa9f1f5e316caadd710ec4ce0be74379c8bb1fc1be2ab68cd0ca
3
+ metadata.gz: 420a32e8886e881ee02d50a95fef57640e8a2d540d1d73313b2a9fdd66206d6b
4
+ data.tar.gz: 380a7ef18cf5f6af36ff32d5573a5ee7e70b680582e147ec30ede62d23635e5b
5
5
  SHA512:
6
- metadata.gz: f42450ecaf979014f966086feb96cbb82d0d1104f6043f0d2542e3c841973f19fd43075d935256102951bdc273bb856ed0bce9da1c4cf4b1c5b8597d635b8f45
7
- data.tar.gz: 66418965532ea2a4eb09f71ed575fb7279e9fa06864005be4ab606820115a918bbe86c9013fdce16f6f5509dd8193c6583bcccdfc7efaf4be6ec47237c9c0611
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
@@ -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 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 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.23.0"
2
+ VERSION = "0.24.0"
3
3
  end
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.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -166,6 +166,8 @@ files:
166
166
  - db/migrate/20261007120000_add_parent_run_to_easy_flow_runs.rb
167
167
  - db/migrate/20261011130000_keep_step_visits_whole_in_easy_flow_runs.rb
168
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
169
171
  - lib/easy_flow.rb
170
172
  - lib/easy_flow/engine.rb
171
173
  - lib/easy_flow/host.rb