-
-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] Fixed re-ordering templates on device add page #434
Closes #434
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from sortedm2m.forms import ( | ||
SortedCheckboxSelectMultiple as BaseSortedCheckboxSelectMultiple, | ||
) | ||
from sortedm2m.forms import SortedMultipleChoiceField as BaseSortedMultipleChoiceField | ||
|
||
|
||
class SortedCheckboxSelectMultiple(BaseSortedCheckboxSelectMultiple): | ||
class Media(BaseSortedCheckboxSelectMultiple.Media): | ||
# The django-sortedm2m library has a bug when the widget is | ||
# use in StackedInline Admin, see | ||
# https://github.com/jazzband/django-sortedm2m/pull/213 | ||
# The workaround in sortedm2m/patch_sortedm2m.js fixes the bug. | ||
# TODO: Remove this workaround when a new version of django-sortedm2m | ||
# is released. | ||
js = ( | ||
'admin/js/jquery.init.js', | ||
'sortedm2m/widget.js', | ||
'sortedm2m/jquery-ui.js', | ||
'sortedm2m/patch_sortedm2m.js', | ||
) | ||
|
||
|
||
class SortedMultipleChoiceField(BaseSortedMultipleChoiceField): | ||
widget = SortedCheckboxSelectMultiple |
6 changes: 6 additions & 0 deletions
6
openwisp_controller/config/static/sortedm2m/patch_sortedm2m.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
(function ($) { | ||
$(document).ready( function () { | ||
$('.sortedm2m-items').sortable('destroy'); | ||
}); | ||
}(django.jQuery)); |