-
Notifications
You must be signed in to change notification settings - Fork 0
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
Allow destroying nested attributes #184
Conversation
@@ -20,7 +20,7 @@ def call | |||
type: 'button', | |||
**options | |||
) do | |||
label | |||
label || content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow button component to have content injected. Allows us to style a button as a bootstrap icon, such as for deleting nested forms.
def validate_options!(options) | ||
opts = { allow_destroy: true }.merge(options) | ||
opts.assert_valid_keys(:allow_destroy) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow developers to toss the allow_destroy
arg at nested attributes and no-op. Raise an exception if any other options passed.
In practice, the nested attrs implementation in H3 allows all nested attributes to be destroyed.
278d25f
to
0f8c00f
Compare
<%= render Elements::Forms::TextFieldComponent.new(field_name: :text, label: I18n.t('related_links.edit.fields.text.label'), form:) %> | ||
<%= render Elements::Forms::TextFieldComponent.new(field_name: :url, label: I18n.t('related_links.edit.fields.url.label'), form:) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Divorce the related links i18n from works, since we will use them as part of collections with the same labels.
0f8c00f
to
1b03b04
Compare
fill_in('Link text', with: 'delete') | ||
fill_in('URL', with: 'me') | ||
# Test adding a new nested field | ||
click_link_or_button('+ Add another related link') | ||
fill_in('work_related_links_attributes_1_text', with: updated_related_links.first['text']) | ||
fill_in('work_related_links_attributes_1_url', with: updated_related_links.first['url']) | ||
# Test removing a nested field | ||
within('div[data-index="0"]') do | ||
find('button[data-action="click->nested-form#delete"]').click | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's how I'm testing adding and removing nested fields, but note that there's a bit of false confidence because this system spec needs work per this still-top-of-ready issue: #138
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve pending handling comment.
1b03b04
to
b9d690e
Compare
Fixes #183