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

Fixed issue where SortableGenericInlines would break whenever adding blank inline forms #266

Merged
merged 2 commits into from
Sep 4, 2014

Conversation

sixthgear
Copy link
Contributor

This is because inline fieldset names append the names of the generic relation fields as defined in models.py. For instance, instead of being called "model_set-n-field" they'd be called
"app-model-content_type-object_id-n-field" reflecting the names of the generic type and id fields. I replaced the string split on '-' with a regexp split that looks for the -n- pattern instead.

This appears to work in Chrome for both regular and generic relations.

…blank inline forms.

This is because inline fieldset names append the names of the generic relation fields as defined in models.py. For instance, instead of being called "model_set-n-field" they'd be called
"app-model-content_type-object_id-n-field" reflecting the names of the generic type and id fields. I replaced the string split on '-' with a regexp split that looks for the -n- pattern instead.

This appears to work in Chrome for both regular and generic relations.
Previously sortable.js was unable to detect whether or not a checkbox had deviated from its original value. First of all the test to find non-blank values:

$set_block.find(":input[value!=''][type!='hidden']")

would not work on a checkbox, since its value will evaluate to "on" or "off".
Secondly, the function filter_unchanged only handled select boxes and the sortable field. As a result, a checkbox in an inline form would always flag a row as "changed". This is particularily troublesome when you have extra blank forms in a formset.

The fix was to add a block in filter_unchanged to check for a checkbox field, and compare its current checked property to that of defaultChecked.
@sixthgear
Copy link
Contributor Author

Added another fix for checkbox support in sortable inlines

@darklow darklow merged commit 2d97e1c into darklow:develop Sep 4, 2014
@darklow
Copy link
Owner

darklow commented Sep 4, 2014

Thank you for the fixes

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.

None yet

2 participants