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

Making taxon form to render attachment definitions dynamically #3308

Merged

Conversation

softr8
Copy link
Contributor

@softr8 softr8 commented Aug 21, 2019

Description
Solidus now allows to inject easily more attachment definitions via
configurable modules (#3237), if a user adds a new attachment, it would be needed
to override the partial _form and add this new attachment, this change
takes all definitions and render the inputs dynamically.

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)

<%= image_tag f.object.icon(:mini) if f.object.icon_present? %>
<% f.object.class.attachment_definitions.each do |attachment, definition| %>
<%= f.field_container attachment do %>
<%= f.label attachment %><br />

Choose a reason for hiding this comment

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

Tag br is a void element, it must end with > and not />.

@spaghetticode
Copy link
Member

@softr8 can you please handle the small nitpick from Hound?

Apart from that, I think this is a great improvement, thank you for noticing that there was room for it 👍 ❤️

@softr8 softr8 force-pushed the dynamic-taxon-attachment-definitions branch from 7cfc7b5 to 746fde7 Compare August 23, 2019 15:05
Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

There's something I'd like to discuss, in the meantime thanks for the contribution @softr8!

<%= f.label :icon %><br />
<%= f.file_field :icon %>
<%= image_tag f.object.icon(:mini) if f.object.icon_present? %>
<% f.object.class.attachment_definitions.each do |attachment, definition| %>
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this work for Paperclip only? I don't think ActiveStorage has a attachment_definitions class method. Maybe we should also make this partial loaded conditionally if we are using the paperclip adapter, similar to what we do for payment method partials. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aha!! Good idea, just adjusted my code to support multiple attachment adapters 👍

@softr8 softr8 force-pushed the dynamic-taxon-attachment-definitions branch from 746fde7 to 7bf0161 Compare August 28, 2019 16:32
Solidus now allows to inject easily more attachment definitions via
configurable modules, if a user adds a new attachment, it would have
to override the partial _form to add this new attachment, this change
takes all definitions and render the inputs dinalycally, it also allows
to specify what partial to render depending on the attachment adapter.
@softr8 softr8 force-pushed the dynamic-taxon-attachment-definitions branch from 7bf0161 to 333c192 Compare August 29, 2019 15:51
Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Thanks, this is a great change!

Copy link
Member

@spaghetticode spaghetticode left a comment

Choose a reason for hiding this comment

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

@softr8 thank you 👍

@kennyadsl kennyadsl merged commit 58533d2 into solidusio:master Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants