easy_flow 0.24.0 → 0.25.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: 420a32e8886e881ee02d50a95fef57640e8a2d540d1d73313b2a9fdd66206d6b
4
- data.tar.gz: 380a7ef18cf5f6af36ff32d5573a5ee7e70b680582e147ec30ede62d23635e5b
3
+ metadata.gz: f7f3a5cbb2c164df9c3c513c7de107dcb30123987e5392853e76554c242aff84
4
+ data.tar.gz: 320ffff05f4107aa8573b2be17a41b5a4e7aa49759b6228c74f7cd7905501b5a
5
5
  SHA512:
6
- metadata.gz: ccb487775af4e1ec1737ac27be7a46a6bb53fd804c14c8ed41b7ba8102d5001fc61311d55830ae5570178df79cbca3223071d255c5b812a2b1f30e1a86e2eb23
7
- data.tar.gz: 01445f50ff3f85db4b67c38e66911bc8960ea9d17741af9c5f144d5b2320e14d649d44c335f35385844706e2aca312f2ef9ffe6308bfd49d0f07bd9d6af6badf
6
+ metadata.gz: 40887692880f1f9f468d11818cac2912b2debb61bdce99a2e238d9be4338c4c915e61df7db046938f371c97eaf2e296ee2c8985a1a930960ef9ffc4bd45a25cb
7
+ data.tar.gz: e01daf58e09f740dd57a5e3690028755abd7c5b77f604bdf765c60637f0fb8974852eab79ed6ebc200225cca7ac4471fde33a75420ad7e00f87cd4ab786ac7f4
@@ -1,6 +1,6 @@
1
1
  module EasyFlow
2
2
  class FlowsController < ApplicationController
3
- helper_method :flow_start_path, :flow_step_path, :previewing?, :step_form, :carries_answers?
3
+ helper_method :flow_start_path, :flow_step_path, :previewing?, :step_form, :carries_answers?, :flow_address
4
4
 
5
5
  def show
6
6
  @flow = flow
@@ -60,6 +60,12 @@ module EasyFlow
60
60
  Run.start(flow)
61
61
  end
62
62
 
63
+ def flow_address(slug)
64
+ return slug unless flow_host.finds_flows_across_owners
65
+
66
+ (run&.flow || flow).public_code
67
+ end
68
+
63
69
  def flow_start_path(slug)
64
70
  flow_routes.flow_path(slug)
65
71
  end
@@ -75,7 +81,7 @@ module EasyFlow
75
81
  def step_form
76
82
  return { url: run_location(run), method: :patch } if run
77
83
 
78
- { url: flow_step_path(@guide.slug), method: :get }
84
+ { url: flow_step_path(flow_address(@guide.slug)), method: :get }
79
85
  end
80
86
 
81
87
  def carries_answers?
@@ -109,13 +115,25 @@ module EasyFlow
109
115
  end
110
116
 
111
117
  def admitted_run
112
- found = find_run(Run.where(flow: hosted_flows), params[:id])
118
+ found = find_run(Run.where(flow: visited_flows), params[:id])
113
119
 
114
120
  Admission.of_run(found, permitted: permitted?(found.flow))
115
121
  end
116
122
 
117
123
  def flow
118
- @stored_flow ||= admit(hosted_flows.find_by(slug: params[:slug]))
124
+ @stored_flow ||= admit(visited_flow)
125
+ end
126
+
127
+ def visited_flow
128
+ return hosted_flows.find_by(slug: params[:slug]) unless flow_host.finds_flows_across_owners
129
+
130
+ visited_flows.find_by_public_code!(params[:slug])
131
+ rescue ActiveRecord::RecordNotFound
132
+ nil
133
+ end
134
+
135
+ def visited_flows
136
+ flow_host.finds_flows_across_owners ? flow_host.flows : hosted_flows
119
137
  end
120
138
 
121
139
  def flowing_definition(flow)
@@ -1,6 +1,6 @@
1
1
  <% content_for(:title, "Complete") %>
2
2
 
3
- <% starting_over = flow_start_path(@guide.slug) %>
3
+ <% starting_over = flow_start_path(flow_address(@guide.slug)) %>
4
4
 
5
5
  <%= ui_page(max_width: :md) do %>
6
6
  <%= ui_page_header(title: "That's everything", subtitle: "Thanks — here's what you told us") do |header| %>
@@ -6,11 +6,11 @@
6
6
  <%= ui_section do %>
7
7
  <div class="flex flex-wrap items-center gap-3">
8
8
  <% if @flow.each_step? && @flow.definition.present? && !previewing? %>
9
- <%= ui_form(action: flow_routes.flow_runs_path(@flow.slug), method: :post) do %>
9
+ <%= ui_form(action: flow_routes.flow_runs_path(flow_address(@flow.slug)), method: :post) do %>
10
10
  <%= ui_button(label: @flow.start_label.presence || "Start", type: :submit) %>
11
11
  <% end %>
12
12
  <% else %>
13
- <%= ui_button(label: @flow.start_label.presence || "Start", href: flow_step_path(@flow.slug)) %>
13
+ <%= ui_button(label: @flow.start_label.presence || "Start", href: flow_step_path(flow_address(@flow.slug))) %>
14
14
  <% end %>
15
15
  </div>
16
16
  <% end %>
@@ -1,7 +1,7 @@
1
1
  <% content_for(:title, @guide.headline) %>
2
2
 
3
3
  <%= ui_page(max_width: :md) do %>
4
- <%= link_to "← Start over", flow_start_path(@guide.slug), class: "text-sm text-accent-600 hover:text-accent-700" %>
4
+ <%= link_to "← Start over", flow_start_path(flow_address(@guide.slug)), class: "text-sm text-accent-600 hover:text-accent-700" %>
5
5
 
6
6
  <div class="mt-6 mb-6">
7
7
  <%= ui_progress(value: @answers.size, max: [ @guide.steps_on_path(@answers).size, 1 ].max, label: "Question #{@answers.size + 1}") %>
@@ -14,7 +14,7 @@
14
14
  <% if @waiting %>
15
15
  <p class="ks-hint">Waiting for <%= @waiting %>.</p>
16
16
  <% if carries_answers? %>
17
- <div class="mt-4"><%= ui_button(label: "Check again", href: "#{flow_step_path(@guide.slug)}?#{{ answers: @answers, completed_at: @progress.completed_at.transform_values(&:iso8601) }.to_query}", variant: :secondary) %></div>
17
+ <div class="mt-4"><%= ui_button(label: "Check again", href: "#{flow_step_path(flow_address(@guide.slug))}?#{{ answers: @answers, completed_at: @progress.completed_at.transform_values(&:iso8601) }.to_query}", variant: :secondary) %></div>
18
18
  <% end %>
19
19
  <% else %>
20
20
  <%= form_with url: step_form[:url], method: step_form[:method], multipart: true, data: { turbo: false } do %>
@@ -2,7 +2,7 @@ module EasyFlow
2
2
  class Host
3
3
  attr_reader :name
4
4
  attr_writer :layout, :admin_layout, :offers, :allowed_answers
5
- attr_accessor :admin_authentication_method, :visitor_authorization_method, :refusal_method, :owner_method
5
+ attr_accessor :admin_authentication_method, :visitor_authorization_method, :refusal_method, :owner_method, :finds_flows_across_owners
6
6
 
7
7
  def initialize(name)
8
8
  @name = name.to_s
@@ -1,3 +1,3 @@
1
1
  module EasyFlow
2
- VERSION = "0.24.0"
2
+ VERSION = "0.25.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.24.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider