mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-28 21:54:14 -04:00
fix tags editor in Snapshot list view
This commit is contained in:
parent
849b4963a1
commit
267964881c
3 changed files with 24 additions and 17 deletions
|
@ -155,25 +155,26 @@ class TagInline(admin.TabularInline):
|
||||||
)
|
)
|
||||||
|
|
||||||
from django.contrib.admin.helpers import ActionForm
|
from django.contrib.admin.helpers import ActionForm
|
||||||
from django.contrib.admin.widgets import AutocompleteSelectMultiple
|
from django.contrib.admin.widgets import FilteredSelectMultiple
|
||||||
|
|
||||||
class AutocompleteTags:
|
# class AutocompleteTags:
|
||||||
model = Tag
|
# model = Tag
|
||||||
search_fields = ['name']
|
# search_fields = ['name']
|
||||||
name = 'tags'
|
# name = 'name'
|
||||||
remote_field = TagInline
|
# # source_field = 'name'
|
||||||
|
# remote_field = Tag._meta.get_field('name')
|
||||||
|
|
||||||
class AutocompleteTagsAdminStub:
|
# class AutocompleteTagsAdminStub:
|
||||||
name = 'admin'
|
# name = 'admin'
|
||||||
|
|
||||||
|
|
||||||
class SnapshotActionForm(ActionForm):
|
class SnapshotActionForm(ActionForm):
|
||||||
tags = forms.ModelMultipleChoiceField(
|
tags = forms.ModelMultipleChoiceField(
|
||||||
queryset=Tag.objects.all(),
|
queryset=Tag.objects.all(),
|
||||||
required=False,
|
required=False,
|
||||||
widget=AutocompleteSelectMultiple(
|
widget=FilteredSelectMultiple(
|
||||||
AutocompleteTags(),
|
'core_tag__name',
|
||||||
AutocompleteTagsAdminStub(),
|
False,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -235,9 +236,8 @@ class SnapshotAdmin(SearchResultsAdminMixin, admin.ModelAdmin):
|
||||||
fields = ('url', 'created_by', 'title', *readonly_fields)
|
fields = ('url', 'created_by', 'title', *readonly_fields)
|
||||||
ordering = ['-added']
|
ordering = ['-added']
|
||||||
actions = ['add_tags', 'remove_tags', 'update_titles', 'update_snapshots', 'resnapshot_snapshot', 'overwrite_snapshots', 'delete_snapshots']
|
actions = ['add_tags', 'remove_tags', 'update_titles', 'update_snapshots', 'resnapshot_snapshot', 'overwrite_snapshots', 'delete_snapshots']
|
||||||
# autocomplete_fields = ['tags']
|
autocomplete_fields = ['tags']
|
||||||
inlines = [TagInline, ArchiveResultInline]
|
inlines = [TagInline, ArchiveResultInline]
|
||||||
# inlines = [ArchiveResultInline]
|
|
||||||
list_per_page = SNAPSHOTS_PER_PAGE
|
list_per_page = SNAPSHOTS_PER_PAGE
|
||||||
|
|
||||||
action_form = SnapshotActionForm
|
action_form = SnapshotActionForm
|
||||||
|
|
|
@ -45,6 +45,13 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
<script
|
||||||
|
src="https://code.jquery.com/jquery-3.7.1.slim.min.js"
|
||||||
|
integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8="
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="{% static "admin.css" %}">
|
<link rel="stylesheet" type="text/css" href="{% static "admin.css" %}">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -264,6 +271,7 @@
|
||||||
.appendTo(buttons)
|
.appendTo(buttons)
|
||||||
})
|
})
|
||||||
console.log('Converted', buttons.children().length, 'admin actions from dropdown to buttons')
|
console.log('Converted', buttons.children().length, 'admin actions from dropdown to buttons')
|
||||||
|
jQuery('select[multiple]').select2();
|
||||||
}
|
}
|
||||||
function fixInlineAddRow() {
|
function fixInlineAddRow() {
|
||||||
$('#id_snapshottag-MAX_NUM_FORMS').val('1000')
|
$('#id_snapshottag-MAX_NUM_FORMS').val('1000')
|
||||||
|
|
|
@ -116,7 +116,6 @@ body.model-snapshot.change-list #content .object-tools {
|
||||||
margin-right: 0px;
|
margin-right: 0px;
|
||||||
width: auto;
|
width: auto;
|
||||||
max-height: 40px;
|
max-height: 40px;
|
||||||
overflow: hidden;
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
@media (max-width: 1000px) {
|
@media (max-width: 1000px) {
|
||||||
|
@ -166,14 +165,14 @@ body.model-snapshot.change-list #content .object-tools {
|
||||||
margin-right: 25px;
|
margin-right: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#content #changelist .actions .select2-selection {
|
#content #changelist .actions > label {
|
||||||
max-height: 25px;
|
max-height: 25px;
|
||||||
}
|
}
|
||||||
#content #changelist .actions .select2-container--admin-autocomplete.select2-container {
|
#content #changelist .actions > label {
|
||||||
width: auto !important;
|
width: auto !important;
|
||||||
min-width: 90px;
|
min-width: 90px;
|
||||||
}
|
}
|
||||||
#content #changelist .actions .select2-selection__rendered .select2-selection__choice {
|
#content #changelist .actions > label > select {
|
||||||
margin-top: 3px;
|
margin-top: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue