-
Notifications
You must be signed in to change notification settings - Fork 4
Fixes Strata Task to return correct value for started? if any pages are started #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8c2bb4a
cf9337f
7dd09b8
ce05048
f5a513e
665d9d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,33 @@ def completed?(record) | |
| record.valid?(@name.to_sym) | ||
| end | ||
|
|
||
| def started?(record) | ||
| @fields.any? do |field| | ||
| field_names = field.is_a?(Hash) ? field.keys : [ field ] | ||
| field_names.any? do |name| | ||
| attribute_name = started_field_name(record, name) | ||
| value = record.public_send(attribute_name) if attribute_name | ||
| # An explicit boolean false is a real user-supplied answer (e.g. a "No" | ||
| # on a yes/no question), but `false.present?` is falsy in Rails. | ||
| value == false || value.present? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Consider checking
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I not familiar with attribute_changed but it looks like it's more for in-memory tracking https://api.rubyonrails.org/classes/ActiveModel/Dirty.html From one of the examples: But I do think that's a bug - if a column has a default false value, then the changed value would return as true. |
||
| end | ||
| end | ||
| end | ||
|
|
||
| def started_field_name(record, name) | ||
| attribute_name = name.to_s | ||
| return attribute_name if record.respond_to?(attribute_name) | ||
|
|
||
| # Fields for accepts_nested_attributes_for associations are declared as | ||
| # :foo_attributes (matching the foo_attributes= setter used by form | ||
| # params), but only the bare association reader (record.foo) exists. | ||
| # Only strip the suffix when probing a nested-attributes field. | ||
| return unless attribute_name.end_with?("_attributes") | ||
|
|
||
| association_name = attribute_name.delete_suffix("_attributes") | ||
| association_name if record.respond_to?(association_name) | ||
| end | ||
|
|
||
| def edit_pathname | ||
| "edit_#{@name}" | ||
| end | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.