Skip to content

Commit

Permalink
gfk grappelli widget: adjusted duplication fix
Browse files Browse the repository at this point in the history
There are some edge cases with the fix in 125890c for generic foreign
key widgets. The issue seems to be that grappelli switched to an init /
update style implementation for that widget in
static/grappelli/js/jquery.grp_related_generic.js -- the only way to
resolve it is to copy lines 56,57 of the update_lookup function from
there which just removes these elements before re-adding them.

Closes Pull Request #41
  • Loading branch information
sbussetti authored and fdintino committed May 26, 2016
1 parent 87bc645 commit 5f47a75
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion nested_admin/static/nested_admin/dist/nested_admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nested_admin/static/nested_admin/dist/nested_admin.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion nested_admin/static/nested_admin/dist/nested_admin.min.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion nested_admin/static/nested_admin/src/nested-admin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@ DJNesting.initRelatedFields = function(prefix, groupData) {
.find('input[name^="' + prefix + '"][name$="' + objectId + '"]')
.each(function() {
var $this = $(this);
if ($this.next('a').hasClass('related-lookup')) return;
var id = $this.attr('id');
var idRegex = new RegExp('(\\-\\d+\\-)' + objectId + '$');
var [, index] = id.match(idRegex) || [];
if (index) {
if ($this.hasClass('grp-has-related-lookup')) {
$this.parent().find('a.related-lookup').remove();
$this.parent().find('.grp-placeholder-related-generic').remove();
}
$this.grp_related_generic({
content_type: '#id_' + prefix + index + contentType,
object_id: '#id_' + prefix + index + objectId,
Expand Down

0 comments on commit 5f47a75

Please sign in to comment.