Skip to content

Commit

Permalink
No drag-drop uploads in raw-id-fields popups
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Jul 1, 2024
1 parent f25e26c commit 548362b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Next version
- Switched from ESLint to biome.
- Dropped the inline upload form in the cabinet foreign key widget. It was
extremely slow when having many folders and many cabinet foreign keys.
- Disabled the drag-drop uploading of files in raw ID field popups.


0.14 (2024-02-02)
Expand Down
5 changes: 5 additions & 0 deletions cabinet/static/cabinet/cabinet.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ django.jQuery(($) => {
document.getElementById("cabinet-folder-list").innerHTML,
)

if (window.location.href.includes("_popup=")) {
// No drag-drop uploads in raw ID fields
return
}

let dragCounter = 0
const results = $(".results")
const folder = window.location.href.match(/folder__id__exact=(\d+)/)
Expand Down
4 changes: 4 additions & 0 deletions cabinet/templates/admin/cabinet/file/change_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
</a>
</li>
{% if not is_popup %}
<li id="cabinet-upload">
<a href="#" class="addlink">{% trans "Upload multiple files" %}</a>
<input type="file" multiple style="display:none">
</li>
{% endif %}
{% endif %}
{% endblock %}

{% block result_list %}
Expand Down Expand Up @@ -111,7 +113,9 @@
</tr>
{% endfor %}
</script>
{% if not is_popup %}
<p class="cabinet-upload-hint">
{% trans "Upload files by dropping them into the list above." %}
</p>
{% endif %}
{% endblock %}

0 comments on commit 548362b

Please sign in to comment.