Skip to content

Commit

Permalink
chore: Incorporate latest version of django-nested-admin that inclu…
Browse files Browse the repository at this point in the history
…des fix for the tabular inline form's heading
  • Loading branch information
drikusroor committed Sep 2, 2024
1 parent e48d47a commit 5947160
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 32 deletions.
29 changes: 0 additions & 29 deletions backend/experiment/static/block_admin.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

document.addEventListener("DOMContentLoaded", (event) => {

fixHeadings();

// Get experiment id from URL
match = window.location.href.match(/\/experiment\/block\/(.+)\/change/);
experiment_id = match && match[1];
Expand Down Expand Up @@ -46,30 +44,3 @@ document.addEventListener("DOMContentLoaded", (event) => {
}
}
})

/** Function to fix the headings for tabular inline forms
* @todo TODO: Remove this `fixHeadings` function once the issue with headings is fixed in `django-nested-admin`.
* - https://github.com/theatlantic/django-nested-admin/issues/261
* - https://github.com/theatlantic/django-nested-admin/pull/259
*/
function fixHeadings() {
// Find the h2 element
const h2Elements = document.querySelectorAll('.tabular h2.inline-heading');

for (const h2Element of h2Elements) {

// Get the next sibling node (which should be the text node)
const textNode = h2Element.nextSibling;

console.log(h2Element, textNode);

// Check if the next sibling is a text node and contains non-whitespace content
if (textNode && textNode.nodeType === Node.TEXT_NODE && textNode.textContent.trim()) {
// Move the text content into the h2 element
h2Element.textContent = textNode.textContent.trim() + h2Element.textContent;

// Remove the original text node
textNode.remove();
}
}
}
2 changes: 1 addition & 1 deletion backend/requirements.in/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ genbadge[coverage]
django-markup[all_filter_dependencies]

# Nested inline forms
django-nested-admin
django-nested-admin>=4.1.1
2 changes: 1 addition & 1 deletion backend/requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ django-inline-actions==2.4.0
# via -r requirements.in/base.txt
django-markup[all-filter-dependencies,all_filter_dependencies]==1.8.1
# via -r requirements.in/base.txt
django-nested-admin==4.1.0
django-nested-admin==4.1.1
# via -r requirements.in/base.txt
docutils==0.20.1
# via
Expand Down
2 changes: 1 addition & 1 deletion backend/requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ django-inline-actions==2.4.0
# via -r requirements.in/base.txt
django-markup[all-filter-dependencies,all_filter_dependencies]==1.8.1
# via -r requirements.in/base.txt
django-nested-admin==4.1.0
django-nested-admin==4.1.1
# via -r requirements.in/base.txt
docutils==0.20.1
# via
Expand Down

0 comments on commit 5947160

Please sign in to comment.