Skip to content

Commit d576115

Browse files
committed
adjusted data access following feedback from keith
1 parent 84cddeb commit d576115

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

docs/api/components/smart_collection.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,22 +201,14 @@ def collection_config
201201
rerender_on: "success",
202202
columns: {
203203
price_in_euro: {
204-
heading: 'Price in €',
205-
slot: method(:price_in_euro_column_slot),
206-
},
207-
self: {
208204
heading: 'Price in € accessed via row object',
209-
slot: method(:whole_object_column_slot),
205+
slot: method(:price_in_euro_column_slot) # slots ALWAYS get the whole row object passed in!
210206
}
211207
}
212208
}
213209
end
214210

215-
def price_in_euro_column_slot price_in_euro
216-
bs_badge price_in_euro # or whatever you want to do with all kinds of components
217-
end
218-
219-
def whole_object_column_slot order
211+
def price_in_euro_column_slot order
220212
bs_badge order.price_in_euro # or whatever you want to do with all kinds of components
221213
end
222214
```

lib/matestack/ui/bootstrap/content/smart_collection/content.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ def table_footer
7070
def cell(data, key, value)
7171
td class: cell_class(value) do
7272
if value.is_a?(Hash) && value[:slot]
73-
value[:slot].call(data.instance_eval(key.to_s)) if value[:attribute].nil?
74-
value[:slot].call(data.instance_eval(value[:attribute].to_s)) if value[:attribute].present?
73+
value[:slot].call(data)
7574
else
7675
plain cell_text(data, key, value)
7776
end

spec/test/content/smart_collection_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@
430430
}
431431
end
432432

433-
ExamplePage.define_method(:last_name_slot_rendering) do |last_name|
434-
bs_badge last_name
433+
ExamplePage.define_method(:last_name_slot_rendering) do |customer|
434+
bs_badge customer.last_name
435435
end
436436

437437
matestack_render do

0 commit comments

Comments
 (0)