easy_flow 0.7.0 → 0.8.1
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 +4 -4
- data/app/controllers/concerns/easy_flow/hosted.rb +6 -0
- data/app/controllers/easy_flow/flows_controller.rb +2 -2
- data/app/controllers/easy_flow/manage/canvas_controller.rb +1 -1
- data/app/controllers/easy_flow/manage/definitions_controller.rb +2 -2
- data/app/controllers/easy_flow/manage/flows_controller.rb +11 -8
- data/app/controllers/easy_flow/manage/previews_controller.rb +1 -1
- data/app/controllers/easy_flow/manage/versions_controller.rb +1 -1
- data/app/models/easy_flow/definition.rb +3 -1
- data/app/views/easy_flow/manage/flows/index.html.erb +5 -17
- data/app/views/easy_flow/manage/flows/new.html.erb +17 -0
- data/config/routes.rb +1 -1
- data/db/migrate/20261001120000_add_owner_to_easy_flow_definitions.rb +10 -0
- data/lib/easy_flow/host.rb +1 -1
- data/lib/easy_flow/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8b63728127549bbca04e9dd1ef8930a0f124c24b99b40f5eb8fcb2e1ab46071
|
|
4
|
+
data.tar.gz: e3ca65e0a6d5d094f9552d76d41d0357bb8ee623b61163a5fc14efec3f0ccf3e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0fd4374064f2b229ca0b5efa3de4531a30da99fa2707f9875aebcc9294934e499d49dcd60675e4f7dbf678ec69fe48412f3d947b9b6852afc55a2339c5451a52
|
|
7
|
+
data.tar.gz: 17f7ce19456a3df5796436692373c3e2357f5a8473ee450414b826f2a0ff9df23bda54fb7cf3ccb69f73f4124c8bdf7d91113641378bf310d518065377dd695e
|
|
@@ -17,5 +17,11 @@ module EasyFlow
|
|
|
17
17
|
def flow_host
|
|
18
18
|
@flow_host ||= EasyFlow.host_named(self.class.named_flow_host || request.path_parameters[:easy_flow_host])
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
def hosted_flows
|
|
22
|
+
return flow_host.flows unless flow_host.owner_method
|
|
23
|
+
|
|
24
|
+
flow_host.flows.where(owner: send(flow_host.owner_method))
|
|
25
|
+
end
|
|
20
26
|
end
|
|
21
27
|
end
|
|
@@ -91,13 +91,13 @@ module EasyFlow
|
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def admitted_run
|
|
94
|
-
found = Run.where(flow:
|
|
94
|
+
found = Run.where(flow: hosted_flows).find(params[:id])
|
|
95
95
|
|
|
96
96
|
Admission.of_run(found, permitted: permitted?(found.flow))
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def flow
|
|
100
|
-
@stored_flow ||= admit(
|
|
100
|
+
@stored_flow ||= admit(hosted_flows.find_by(slug: params[:slug]))
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
def flowing_definition(flow)
|
|
@@ -2,11 +2,11 @@ module EasyFlow
|
|
|
2
2
|
module Manage
|
|
3
3
|
class DefinitionsController < BaseController
|
|
4
4
|
def edit
|
|
5
|
-
@flow =
|
|
5
|
+
@flow = hosted_flows.find(params[:flow_id])
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def update
|
|
9
|
-
@flow =
|
|
9
|
+
@flow = hosted_flows.find(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
|
|
@@ -6,41 +6,44 @@ module EasyFlow
|
|
|
6
6
|
@flows = ordered_flows
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
+
def new
|
|
10
|
+
@flow = hosted_flows.new
|
|
11
|
+
end
|
|
12
|
+
|
|
9
13
|
def create
|
|
10
|
-
@flow =
|
|
14
|
+
@flow = hosted_flows.new(create_params)
|
|
11
15
|
|
|
12
16
|
if @flow.save
|
|
13
17
|
redirect_to manage_flow_path(@flow), notice: "Flow created."
|
|
14
18
|
else
|
|
15
|
-
|
|
16
|
-
render :index, status: :unprocessable_entity
|
|
19
|
+
render :new, status: :unprocessable_entity
|
|
17
20
|
end
|
|
18
21
|
end
|
|
19
22
|
|
|
20
23
|
def show
|
|
21
|
-
@flow =
|
|
24
|
+
@flow = hosted_flows.find(params[:id])
|
|
22
25
|
@canvas = canvas_payload(@flow)
|
|
23
26
|
end
|
|
24
27
|
|
|
25
28
|
def edit
|
|
26
|
-
@flow =
|
|
29
|
+
@flow = hosted_flows.find(params[:id])
|
|
27
30
|
end
|
|
28
31
|
|
|
29
32
|
def update
|
|
30
|
-
@flow =
|
|
33
|
+
@flow = hosted_flows.find(params[:id])
|
|
31
34
|
@flow.update!(flow_params)
|
|
32
35
|
redirect_to manage_flow_path(@flow), notice: "Saved."
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
def destroy
|
|
36
|
-
|
|
39
|
+
hosted_flows.find(params[:id]).destroy!
|
|
37
40
|
redirect_to manage_flows_path, notice: "Flow removed."
|
|
38
41
|
end
|
|
39
42
|
|
|
40
43
|
private
|
|
41
44
|
|
|
42
45
|
def ordered_flows
|
|
43
|
-
|
|
46
|
+
hosted_flows.order(:slug)
|
|
44
47
|
end
|
|
45
48
|
|
|
46
49
|
def create_params
|
|
@@ -6,6 +6,8 @@ module EasyFlow
|
|
|
6
6
|
enum :kind, { scored: "scored", guide: "guide" }
|
|
7
7
|
enum :persists, { unsaved: "unsaved", each_step: "each_step", on_finish: "on_finish" }
|
|
8
8
|
|
|
9
|
+
belongs_to :owner, polymorphic: true, optional: true
|
|
10
|
+
|
|
9
11
|
validates :host, :slug, presence: true
|
|
10
12
|
|
|
11
13
|
after_initialize :begin_the_flow, if: :new_record?
|
|
@@ -18,7 +20,7 @@ module EasyFlow
|
|
|
18
20
|
has_many :definition_versions, class_name: "EasyFlow::Version", foreign_key: :flow_id, dependent: :destroy
|
|
19
21
|
|
|
20
22
|
def self.upsert_definition(definition, host:)
|
|
21
|
-
find_or_initialize_by(host: host, slug: definition["slug"]).tap do |flow|
|
|
23
|
+
find_or_initialize_by(host: host, owner: nil, slug: definition["slug"]).tap do |flow|
|
|
22
24
|
flow.save!
|
|
23
25
|
flow.record_definition(definition) unless flow.definition == definition
|
|
24
26
|
end
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<%= ui_page(max_width: :xl) do %>
|
|
2
|
-
<%= ui_page_header(title: "Flows", subtitle: "Build and edit your flows") %>
|
|
2
|
+
<%= ui_page_header(title: "Flows", subtitle: "Build and edit your flows") do |header| %>
|
|
3
|
+
<% header.action do %>
|
|
4
|
+
<%= ui_button(label: "Create", href: flow_routes.new_manage_flow_path) %>
|
|
5
|
+
<% end %>
|
|
6
|
+
<% end %>
|
|
3
7
|
|
|
4
8
|
<%= ui_data_table(
|
|
5
9
|
items: @flows,
|
|
@@ -13,20 +17,4 @@
|
|
|
13
17
|
<% end %>
|
|
14
18
|
<% end %>
|
|
15
19
|
<% end %>
|
|
16
|
-
|
|
17
|
-
<%= ui_section(title: "Create a flow") do %>
|
|
18
|
-
<% if @flow&.errors&.any? %>
|
|
19
|
-
<%= ui_alert(message: @flow.errors.full_messages.to_sentence, type: :error) %>
|
|
20
|
-
<% end %>
|
|
21
|
-
|
|
22
|
-
<%= ui_form(action: flow_routes.manage_flows_path, method: :post) do %>
|
|
23
|
-
<label class="block text-sm font-medium mb-1">Slug</label>
|
|
24
|
-
<%= ui_input(name: "flow[slug]", placeholder: "e.g. business-scorecard") %>
|
|
25
|
-
|
|
26
|
-
<label class="block text-sm font-medium mb-1 mt-4">Kind</label>
|
|
27
|
-
<%= ui_select(name: "flow[kind]", options: [ [ "Scored", "scored" ], [ "Guide", "guide" ] ]) %>
|
|
28
|
-
|
|
29
|
-
<%= ui_button(label: "Create", type: :submit, variant: :secondary) %>
|
|
30
|
-
<% end %>
|
|
31
|
-
<% end %>
|
|
32
20
|
<% end %>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<%= ui_page(max_width: :md) do %>
|
|
2
|
+
<%= ui_page_header(title: "New flow") %>
|
|
3
|
+
|
|
4
|
+
<% if @flow.errors.any? %>
|
|
5
|
+
<%= ui_alert(message: @flow.errors.full_messages.to_sentence, type: :error) %>
|
|
6
|
+
<% end %>
|
|
7
|
+
|
|
8
|
+
<%= ui_form(action: flow_routes.manage_flows_path, method: :post) do %>
|
|
9
|
+
<label class="block text-sm font-medium mb-1">Slug</label>
|
|
10
|
+
<%= ui_input(name: "flow[slug]", value: @flow.slug, placeholder: "e.g. business-scorecard") %>
|
|
11
|
+
|
|
12
|
+
<label class="block text-sm font-medium mb-1 mt-4">Kind</label>
|
|
13
|
+
<%= ui_select(name: "flow[kind]", options: [ [ "Scored", "scored" ], [ "Guide", "guide" ] ], selected: @flow.kind) %>
|
|
14
|
+
|
|
15
|
+
<%= ui_button(label: "Create", type: :submit) %>
|
|
16
|
+
<% end %>
|
|
17
|
+
<% end %>
|
data/config/routes.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
EasyFlow::Engine.routes.draw do
|
|
2
2
|
namespace :manage do
|
|
3
|
-
resources :flows, only: [ :index, :create, :show, :edit, :update, :destroy ] do
|
|
3
|
+
resources :flows, only: [ :index, :new, :create, :show, :edit, :update, :destroy ] do
|
|
4
4
|
resource :definition, only: [ :edit, :update ]
|
|
5
5
|
resource :preview, only: :show, controller: "previews" do
|
|
6
6
|
get :step
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class AddOwnerToEasyFlowDefinitions < ActiveRecord::Migration[8.1]
|
|
2
|
+
def change
|
|
3
|
+
add_reference :easy_flow_definitions, :owner, polymorphic: true, index: false
|
|
4
|
+
remove_index :easy_flow_definitions, [ :host, :slug ], unique: true, name: "index_easy_flow_definitions_on_host_and_slug"
|
|
5
|
+
add_index :easy_flow_definitions, [ :host, :slug ], unique: true, where: "owner_id IS NULL",
|
|
6
|
+
name: "index_easy_flow_definitions_on_host_and_slug"
|
|
7
|
+
add_index :easy_flow_definitions, [ :host, :owner_type, :owner_id, :slug ], unique: true, where: "owner_id IS NOT NULL",
|
|
8
|
+
name: "index_easy_flow_definitions_on_host_owner_and_slug"
|
|
9
|
+
end
|
|
10
|
+
end
|
data/lib/easy_flow/host.rb
CHANGED
|
@@ -2,7 +2,7 @@ module EasyFlow
|
|
|
2
2
|
class Host
|
|
3
3
|
attr_reader :name
|
|
4
4
|
attr_writer :layout, :admin_layout, :offers
|
|
5
|
-
attr_accessor :admin_authentication_method, :visitor_authorization_method, :refusal_method
|
|
5
|
+
attr_accessor :admin_authentication_method, :visitor_authorization_method, :refusal_method, :owner_method
|
|
6
6
|
|
|
7
7
|
def initialize(name)
|
|
8
8
|
@name = name.to_s
|
data/lib/easy_flow/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.8.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tylercschneider
|
|
@@ -127,6 +127,7 @@ files:
|
|
|
127
127
|
- app/views/easy_flow/manage/definitions/edit.html.erb
|
|
128
128
|
- app/views/easy_flow/manage/flows/edit.html.erb
|
|
129
129
|
- app/views/easy_flow/manage/flows/index.html.erb
|
|
130
|
+
- app/views/easy_flow/manage/flows/new.html.erb
|
|
130
131
|
- app/views/easy_flow/manage/flows/show.html.erb
|
|
131
132
|
- app/views/easy_flow/manage/versions/index.html.erb
|
|
132
133
|
- app/views/easy_flow/steps/_choosing.html.erb
|
|
@@ -137,6 +138,7 @@ files:
|
|
|
137
138
|
- db/migrate/20260924120100_create_easy_flow_versions.rb
|
|
138
139
|
- db/migrate/20260924120200_create_easy_flow_runs.rb
|
|
139
140
|
- db/migrate/20260924130000_add_host_to_easy_flow_definitions.rb
|
|
141
|
+
- db/migrate/20261001120000_add_owner_to_easy_flow_definitions.rb
|
|
140
142
|
- lib/easy_flow.rb
|
|
141
143
|
- lib/easy_flow/engine.rb
|
|
142
144
|
- lib/easy_flow/host.rb
|