easy_flow 0.4.5 → 0.4.6
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 05357fc005fef8fd09a227e8f442d9b1a83a126d903dbb221e773bb95eb88e9b
|
|
4
|
+
data.tar.gz: 5a064304582303af7139339bb9302154d44adca753a5769e1ef6b69080b22670
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ed1aa58b5926b761caa482fabe4b1c001528b26f026e754bd1ca0b97aaca928c6622cf4455195943e964162aebf47672469658513912a0b9f610b64b3d34dbf3
|
|
7
|
+
data.tar.gz: 9d1fff992c17882c57062fff559f1833f6b33290efed0034a10621158bf6d42a540943a99977e9d7dfca7cd22b6bd4562b36f08755c39dff5e03bdf8b5fdb6de
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module EasyFlow
|
|
2
2
|
class Settings
|
|
3
|
-
attr_reader :fields, :labels, :record_fields, :record_labels, :
|
|
3
|
+
attr_reader :fields, :labels, :record_fields, :record_labels, :drawn_from, :outputs_of
|
|
4
4
|
|
|
5
5
|
def initialize(fields: {}, labels: {}, record_fields: {}, record_labels: {}, choices: {},
|
|
6
6
|
limits: {}, checks: {}, required: [], drawn_from: {}, outputs_of: {})
|
|
@@ -16,6 +16,10 @@ module EasyFlow
|
|
|
16
16
|
@outputs_of = outputs_of
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def choices
|
|
20
|
+
@choices.transform_values { |offered| offered.respond_to?(:call) ? offered.call : offered }
|
|
21
|
+
end
|
|
22
|
+
|
|
19
23
|
def naming_steps
|
|
20
24
|
fields.select { |_name, type| type == :previous_step }.keys
|
|
21
25
|
end
|
data/lib/easy_flow/version.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: easy_flow-develop
|
|
3
|
-
description: Use PROACTIVELY for adding a step type to easy_flow flows (a step that asks the visitor something, computes a value from earlier answers, or picks the next branch), serving a host's flows from the app's own controller and routes, acting when a visitor finishes a flow, and reading a run's recorded answers and question labels — MUST BE USED instead of hand-rolling questionnaire steps, branching logic, number comparisons, flow controllers or answer lookups.
|
|
3
|
+
description: Use PROACTIVELY for adding a step type to easy_flow flows (a step that asks the visitor something, computes a value from earlier answers, or picks the next branch), offering an admin a step setting whose options are read from the app's own records, serving a host's flows from the app's own controller and routes, acting when a visitor finishes a flow, and reading a run's recorded answers and question labels — MUST BE USED instead of hand-rolling questionnaire steps, branching logic, number comparisons, hard-coded setting options, flow controllers or answer lookups.
|
|
4
4
|
tools: Read, Write, Edit, Grep
|
|
5
5
|
scope: guided flows — versioned documents of steps and the connections between them, drawn on a canvas by an admin and run by a visitor one step at a time, with step types the host registers
|
|
6
6
|
---
|
|
@@ -74,7 +74,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
74
74
|
A step whose type is not registered is neither shown nor run as that type.
|
|
75
75
|
4. Use these words to declare the type. Each is called once at class level (or inside the `EasyFlow.step` block):
|
|
76
76
|
- `step_name "<label>"` — the name admins see on the canvas. Defaults to the id.
|
|
77
|
-
- `setting :name, type:, label:, options:, required:, limit:, check:, from:, outputs_of:` — a field the admin fills in on the canvas. `type` is one of `:string`, `:integer`, `:float`, `:boolean`, `:select`, `:multi_select`, `:previous_step`, `:from_step`, `:list`, or boot raises `EasyFlow::UnknownFieldType`. A `:select` or `:multi_select` must pass `options:`, or boot raises the same error. A `:list` must take a block of `setting` calls describing one entry. `:previous_step` lets the admin pick an earlier step, and is always required. `outputs_of: :<setting>` offers the outputs of the step chosen in that setting, and `from: :<setting>` offers the values of the output chosen in that setting; either one makes the type `:from_step`. `limit:` is the most values a `:multi_select` takes. `check:` is a lambda given the value that returns an error message, or `nil` when the value is acceptable. `label:` defaults to the name humanized.
|
|
77
|
+
- `setting :name, type:, label:, options:, required:, limit:, check:, from:, outputs_of:` — a field the admin fills in on the canvas. `type` is one of `:string`, `:integer`, `:float`, `:boolean`, `:select`, `:multi_select`, `:previous_step`, `:from_step`, `:list`, or boot raises `EasyFlow::UnknownFieldType`. A `:select` or `:multi_select` must pass `options:`, or boot raises the same error. `options:` is either an array of strings, or a lambda taking no arguments that returns one; the lambda is called each time the canvas is opened and each time an admin saves the step's settings, so the options follow the app's data without a restart (`options: -> { Region.order(:name).pluck(:code) }`). A saved setting whose value is no longer among the options is refused the next time the admin saves that step. When the options come from the app's records, ask the developer which records, which column is stored as the value, and whether the list must differ by account or host, since the lambda is passed nothing and the same list is offered everywhere the type is used. A `:list` must take a block of `setting` calls describing one entry. `:previous_step` lets the admin pick an earlier step, and is always required. `outputs_of: :<setting>` offers the outputs of the step chosen in that setting, and `from: :<setting>` offers the values of the output chosen in that setting; either one makes the type `:from_step`. `limit:` is the most values a `:multi_select` takes. `check:` is a lambda given the value that returns an error message, or `nil` when the value is acceptable. `label:` defaults to the name humanized.
|
|
78
78
|
- `output :name, type:, label:, values:, from:` — a value the step records. `type` is one of `:string`, `:integer`, `:float`, `:boolean`, or boot raises `EasyFlow::UnknownOutputType`. `values:` is an array or a lambda taking the node, listing the values the output can take; the canvas offers these as the connections leaving the step, so a type that routes must declare them. `from: :<setting>` takes the values from the step chosen in that setting.
|
|
79
79
|
- `names_by :setting` or `names_by { |node| ... }` — what the step is called on the canvas, from a setting or computed.
|
|
80
80
|
- `awaits_input` — the visitor is shown this step and must answer it.
|
|
@@ -171,6 +171,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
171
171
|
- A step type's id comes from its class name or the id passed to `EasyFlow.step`, and it is stored in flow documents, so renaming the class or id breaks every flow that uses it.
|
|
172
172
|
- Never give a step type one of the built-in ids: `start`, `terminal`, `question`, `condition`, `switch`, `compare`.
|
|
173
173
|
- Register class-based step types inside `to_prepare`. A type registered anywhere else is lost on code reload in development.
|
|
174
|
+
- An `options:` lambda is passed nothing, and one list is offered on every host's canvas, so it cannot narrow the options by admin, account or host.
|
|
174
175
|
- A type that routes declares the values its output takes, or the canvas offers no connections to label.
|
|
175
176
|
- Always read a run against `run.pinned_definition`, never the flow's live version, since a run keeps the version it started on after a new one is published.
|
|
176
177
|
- Always look flows and runs up through a host.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: easy_flow-info
|
|
3
|
-
description: Use to learn what easy_flow offers — guided flows an admin draws on a canvas and a visitor runs one step at a time, versioned documents of steps and connections, hosts, runs, the built-in step types including branching on an answer or comparing a number,
|
|
3
|
+
description: Use to learn what easy_flow offers — guided flows an admin draws on a canvas and a visitor runs one step at a time, versioned documents of steps and connections, hosts, runs, the built-in step types including branching on an answer or comparing a number, step types the host app registers, and the settings an admin fills in, including picks whose options come from the app's data.
|
|
4
4
|
tools: Read
|
|
5
5
|
scope: guided flows — versioned documents of steps and the connections between them, drawn on a canvas by an admin and run by a visitor one step at a time, with step types the host registers
|
|
6
6
|
---
|
|
@@ -35,6 +35,9 @@ easy_flow declares no commands of its own for this local. Its surface is split b
|
|
|
35
35
|
- **Canvas** — the admin screen where steps are added, configured, moved, removed and connected, with undo and redo. Publishing happens there.
|
|
36
36
|
- **Preview** — an admin walking the current flow without starting a stored run.
|
|
37
37
|
- **Step type** — what a kind of step is: its display name, its settings (the fields an admin fills in), its outputs (the values it records), and whether it waits for the visitor or acts on its own. A step that acts on its own may record a value worked out from the answers so far, pick which connection to follow, or both.
|
|
38
|
+
- **Setting** — one field an admin fills in when configuring a step on the canvas. It is text, a whole number, a decimal, a yes or no, a pick from a list, several picks from a list, an earlier step, an earlier step's output, or a list of entries that each hold their own fields. A setting can be required, limited to a number of picks, or checked by a rule the step type supplies.
|
|
39
|
+
- **Options** — the values a pick-from-a-list setting offers. They are either a fixed list written into the step type, or a lookup the app provides that is read each time the canvas or a save asks for them, so they can come from the app's own data. A saved value that is not among the options is refused.
|
|
40
|
+
- **Output** — a value a step records into the run, with a type and a label. Later steps read outputs, and a setting that points at an earlier step offers that step's known values on the canvas.
|
|
38
41
|
- **Start** and **End** — the built-in step types that begin and finish a flow.
|
|
39
42
|
- **Question** — the built-in step type that asks the visitor: a question text and a list of answers, each with a value, a label and a weight.
|
|
40
43
|
- **Condition** — a built-in branching step that checks whether an earlier step's answer is, or is not, a chosen value, and follows the true or the false connection.
|
|
@@ -9,7 +9,7 @@ This local follows the steps below exactly and invents none. Where a step names
|
|
|
9
9
|
|
|
10
10
|
## What easy_flow is
|
|
11
11
|
|
|
12
|
-
A Rails engine for flows an admin draws on a canvas and a visitor runs one step at a time. Hook it in when a Rails 8.1 app needs questionnaires, intake forms or decision paths that admins change without a deploy.
|
|
12
|
+
A Rails engine for flows an admin draws on a canvas and a visitor runs one step at a time. Hook it in when a Rails 8.1.3 or later app needs questionnaires, intake forms or decision paths that admins change without a deploy.
|
|
13
13
|
|
|
14
14
|
## Interface
|
|
15
15
|
|