avo icon indicating copy to clipboard operation
avo copied to clipboard

feature: `association` option for association fields

Open Paul-Bob opened this issue 11 months ago • 1 comments

Description

Fixes #2559

Checklist:

  • [ ] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have added tests that prove my fix is effective or that my feature works

Screenshots & recording

Manual review steps

  1. Step 1
  2. Step 2

Manual reviewer: please leave a comment with output from the test if that's the case.

Paul-Bob avatar Mar 05 '24 12:03 Paul-Bob

Code Climate has analyzed commit 7c7fa1a2 and detected 0 issues on this pull request.

View more on Code Climate.

codeclimate[bot] avatar Mar 05 '24 12:03 codeclimate[bot]

TODO:

  • [x] docs
  • [x] PR description
  • [x] tests
  • [x] fix select all issue where it selects all from both tables

Paul-Bob avatar Mar 08 '24 07:03 Paul-Bob

Let's wait on this. I have an idea of a for_column or for_field (open to better naming) which should do the same thins as association but for any field.

field :full_name, as: :text, for_field: :name, format_using: -> {something}
field :super_name, as: :text, for_field: :name, format_using: -> {something_else}

Do you think we need something like that?

adrianthedev avatar Mar 15 '24 14:03 adrianthedev

Let's wait on this. I have an idea of a for_column or for_field (open to better naming) which should do the same thins as association but for any field.

field :full_name, as: :text, for_field: :name, format_using: -> {something}
field :super_name, as: :text, for_field: :name, format_using: -> {something_else}

Do you think we need something like that?

for_field option aims to the model attribute? I.E. both fields on your example will fetch the value from record.name?

If i understand it right I think that's interesting and is like renaming and extending the association option to all fields :ok_hand:

This opens another suggestion, a way to directly pass the value similar like the field block but applied to all views

field :full_name, as: :text, value: -> { record.name }, format_using: -> {something}
field :super_name, as: :text, value: -> { record.name }, format_using: -> {something_else}

Lets keep an eye on this PR since some logic might be reused whatever approach we follow.

Paul-Bob avatar Mar 15 '24 15:03 Paul-Bob

Actually with the value: -> { record.name } suggestion there is no need to format, is like for_field + format_using in one option

Paul-Bob avatar Mar 15 '24 15:03 Paul-Bob

This PR has been marked as stale because there was no activity for the past 15 days.

github-actions[bot] avatar Mar 31 '24 01:03 github-actions[bot]

Let's create a PoC for this and name it for_attribute or as_attribute.

adrianthedev avatar Apr 12 '24 10:04 adrianthedev

This PR has been merged into main. The functionality will be available in the next release.

Please check the release guide for more information.

github-actions[bot] avatar Apr 18 '24 09:04 github-actions[bot]