Skip to content
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

feature: radio field #3425

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

thiagoyoussef
Copy link
Contributor

@thiagoyoussef thiagoyoussef commented Nov 14, 2024

Description

Fixes #3140

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

CleanShot 2024-11-14 at 16 30 34@2x

Copy link

codeclimate bot commented Nov 14, 2024

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

View more on Code Climate.

Copy link
Collaborator

@adrianthedev adrianthedev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!
Thank you!

@@ -10,7 +10,7 @@ class Avo::Resources::Person < Avo::BaseResource

def fields
field :name, as: :text, link_to_record: true, sortable: true, stacked: true
field :type, as: ::Pluggy::Fields::RadioField, name: "Type", options: {Spouse: "Spouse", Sibling: "Sibling"}, include_blank: true, filterable: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@@ -0,0 +1,60 @@
require "rails_helper"

RSpec.describe "RadioField", type: :system do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can get away with a feature test instead of a system one.

Copy link
Contributor

@Paul-Bob Paul-Bob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! Thank you @thiagoyoussef !

@@ -10,7 +10,7 @@ class Avo::Resources::Person < Avo::BaseResource

def fields
field :name, as: :text, link_to_record: true, sortable: true, stacked: true
field :type, as: ::Pluggy::Fields::RadioField, name: "Type", options: {Spouse: "Spouse", Sibling: "Sibling"}, include_blank: true, filterable: true
field :type, as: :pluggy_radio, name: "Type", options: {Spouse: "Spouse", Sibling: "Sibling"}, include_blank: true, filterable: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change really necessary? I think it's a good test for declaring fields using the constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change to use the constant then! It's not necessary, just thought would be a better practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement radio field
3 participants