-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add context to Page #2457
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
base: main
Are you sure you want to change the base?
Add context to Page #2457
Changes from all commits
4da8b3e
0c7ca09
e9c22c1
2f13702
0366849
ce0fdec
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,7 +26,9 @@ def associated_collection(order = self.order) | |||||||||
| associated_dashboard, | ||||||||||
| order: order, | ||||||||||
| collection_attributes: options[:collection_attributes] | ||||||||||
| ) | ||||||||||
| ).tap do |page| | ||||||||||
| page.context = context | ||||||||||
| end | ||||||||||
| end | ||||||||||
|
|
||||||||||
| def attribute_key | ||||||||||
|
|
@@ -76,7 +78,7 @@ def more_than_limit? | |||||||||
| end | ||||||||||
|
|
||||||||||
| def data | ||||||||||
| @data ||= associated_class.none | ||||||||||
| super || associated_class.none | ||||||||||
| end | ||||||||||
|
|
||||||||||
| def order_from_params(params) | ||||||||||
|
|
@@ -106,12 +108,11 @@ def includes | |||||||||
| end | ||||||||||
|
|
||||||||||
| def candidate_resources | ||||||||||
| if options.key?(:includes) | ||||||||||
| includes = options.fetch(:includes) | ||||||||||
| associated_class.includes(*includes).all | ||||||||||
| else | ||||||||||
| associated_class.all | ||||||||||
| end | ||||||||||
| scope = options[:scope] ? options[:scope].call(self) : associated_class.all | ||||||||||
| scope = scope.includes(*options.fetch(:includes)) if options.key?(:includes) | ||||||||||
|
Collaborator
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 was fiddling with this and I think we can make this work without a conditional:
Suggested change
|
||||||||||
|
|
||||||||||
| order = options.delete(:order) | ||||||||||
| order ? scope.reorder(order) : scope | ||||||||||
|
Comment on lines
+114
to
+115
Collaborator
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. Good call with By the way: do we need to
Suggested change
|
||||||||||
| end | ||||||||||
|
|
||||||||||
| def display_candidate_resource(resource) | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,11 +27,19 @@ def item_associations | |
| dashboard.try(:item_associations) || [] | ||
| end | ||
|
|
||
| attr_accessor :context | ||
|
|
||
| private | ||
|
|
||
| def attribute_field(dashboard, resource, attribute_name, page) | ||
| field = dashboard.attribute_type_for(attribute_name) | ||
| field.new(attribute_name, nil, page, resource: resource) | ||
| field.new(attribute_name, nil, page, resource: resource).tap do |f| | ||
| f.context = context | ||
| end | ||
| end | ||
|
|
||
| def get_attribute_value(resource, attribute_name) | ||
| resource.public_send(attribute_name) | ||
|
Comment on lines
+39
to
+42
Collaborator
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. Is this method used for anything? |
||
| end | ||
|
|
||
| attr_reader :dashboard, :options | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.