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

Сompatibility for django-grappelli #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
*.log
*.pot
*.pyc
Expand Down
23 changes: 14 additions & 9 deletions orderable/templates/admin/orderable_change_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
{
cursor: pointer;
}

/*Fix for grappelli*/
.ui-sortable {
float: inherit !important;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder -- is there a less aggressive way than !important to get this to work?

}
</style>

{% endblock %}
Expand All @@ -20,9 +25,13 @@
// Only add the drag-n-drop reordering if this is not a paginated object (determined by the presense of a span, which isn't the best way to do it…)
if ($("p.paginator > span"))
{
// Check grappelli prefix
var grappelli_prefix = window.grappelli === undefined ? "" : "grp-";

var table_select = $("#" + grappelli_prefix + "changelist table tbody");

// Steal the draghandle's id and apply to the row
$("#changelist table tbody tr").each(function() {
table_select.find("tr").each(function() {
var id = $(".sorthandle", this).attr("id");
$(this).attr("id", id);
$(".sorthandle", this).attr("id", "");
Expand All @@ -34,12 +43,12 @@
$(".sorthandle").html("<img src='{{ STATIC_URL }}admin/img/drag_handle.gif' width='11' height='11' alt='Drag to reorder' />");

// Force a width onto all the tds (so they drag nicely)
$("#changelist table tbody tr > *").each(function() {
table_select.find("tr > *").each(function() {
$(this).width($(this).width())
});

// Do the draggable
$("#changelist table tbody").sortable({
table_select.sortable({
'axis': 'y',
// 'containment': 'parent',
'cursor': 'crosshair',
Expand All @@ -51,7 +60,7 @@
cereal += '&csrfmiddlewaretoken=' + $("input[name=csrfmiddlewaretoken]").val();

var classflip = 1;
$("#changelist table tbody tr").each(function() {
table_select.find("tr").each(function() {
// redraw the tabel striping
$(this).removeClass("row1 row2");
if (classflip) {
Expand All @@ -68,11 +77,7 @@
$.ajax({
url: "reorder/",
type: "POST",
data: cereal/*,
success: function(feedback) {
console.log(feedback);
// $('data').html(feedback);
}*/
data: cereal
});
}

Expand Down