Skip to content

Commit

Permalink
fix: Folder widget had outdated styling (#1371)
Browse files Browse the repository at this point in the history
* Update folder widget

* Remove debug log

* Satisfy eslint
  • Loading branch information
fsbraun authored Jun 28, 2023
1 parent 963a875 commit 4733fd4
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 22 deletions.
7 changes: 3 additions & 4 deletions filer/fields/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.utils.safestring import mark_safe

from ..models import Folder
from ..settings import ICON_CSS_LIB
from ..utils.compatibility import truncate_words
from ..utils.model_label import get_model_label

Expand Down Expand Up @@ -59,7 +60,6 @@ def render(self, name, value, attrs=None, renderer=None):
'object': obj,
'clear_id': '%s_clear' % css_id,
'descid': css_id_description_txt,
'noimg': 'filer/icons/nofile_32x32.png',
'foldid': css_id_folder,
'id': css_id,
}
Expand All @@ -81,9 +81,8 @@ def obj_for_value(self, value):
return obj

class Media:
js = (
'filer/js/addons/popup_handling.js',
)
css = {"all": ('filer/css/admin_filer.css',) + ICON_CSS_LIB}
js = ('filer/js/addons/popup_handling.js',)


class AdminFolderFormField(forms.ModelChoiceField):
Expand Down
3 changes: 2 additions & 1 deletion filer/private/sass/components/_drag-and-drop.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

form .form-row {
&[class*="file"],
&[class*="folder"],
&[class*="img"],
&[class*="image"],
&[class*="visual"] {
Expand Down Expand Up @@ -332,7 +333,7 @@ form .form-row {

}
&.filer-dropzone-folder .filerFile {
top: 32px !important;
top: 8px;
#id_folder_description_txt {
float: left;
}
Expand Down
2 changes: 1 addition & 1 deletion filer/static/filer/css/admin_filer.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion filer/static/filer/css/maps/admin_filer.css.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion filer/static/filer/js/addons/popup_handling.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@ if (django.jQuery) {
};
window.dismissRelatedFolderLookupPopup = function (win, chosenId, chosenName) {
var id = windowname_to_id(win.name);
var lookup = $('#' + id);
var container = lookup.closest('.filerFile');
var image = container.find('.thumbnail_img');
var clearButton = $('#id_' + id + '_clear');
var input = $('#id_' + id);
var folderName = $('#id_' + id + '_description_txt');
var folderName = container.find('.description_text');
var addFolderButton = $('#' + id);

input.val(chosenId);

image.removeClass('hidden');
folderName.text(chosenName);
clearButton.removeClass('hidden');
addFolderButton.addClass('hidden');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<td class="column-checkbox">
{% if filer_admin_context.pick_folder and item.file_type == 'Folder' %}
<a class="insertlink insertlinkButton"
href="#" onclick="opener.dismissRelatedFolderLookupPopup(window, '{{ subfolder.pk|safe }}', '{{ subfolder.quoted_logical_path }}'); return false;" >
href="#" onclick="opener.dismissRelatedFolderLookupPopup(window, '{{ subfolder.pk|safe }}', '{{ subfolder.pretty_logical_path }}'); return false;" >
<span class="fa fa-arrow-left filer-icon cms-icon-select"></span>
</a>
{% elif action_form and item.pk and not is_popup %}
Expand Down
28 changes: 15 additions & 13 deletions filer/templates/admin/filer/widgets/admin_folder.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
{% spaceless %}
<div class="filer-dropzone filer-dropzone-folder">
<span class="filerFile">
<img src="{% static "filer/icons/folder.svg" %}" class="thumbnail_img{% if not object %} hidden{% endif %}"/>
<span id="{{ span_id }}" style="margin-left: 15px;">
{% trans "Folder" %}:
{% if object %}
{{ object.pretty_logical_path }}
{% else %}
{% trans "none selected" %}
{% endif %}
<span class="description_text">
{% if object %}
{{ object.pretty_logical_path }}
{% endif %}
</span>
</span>
<a href="{{ lookup_url }}" class="related-lookup{% if object %} hidden{% endif %}" id="{{ lookup_name }}" title="{% trans 'Lookup' %}">
{% trans "Add Folder" %}
<span class="fa fa-search cms-icon cms-icon-search"></span>&nbsp;
{% trans "Choose Folder" %}
</a>

<img id="{{ clear_id }}" src="{% static 'filer/img/icon_deletelink.gif' %}" width="10" height="10" alt="{% trans 'Clear' %}" title="{% trans 'Clear' %}" class="filerClearer{% if not object %} hidden{% endif %}">
{{ hidden_input }}
<a class="filerClearer {% if not object %}hidden{% endif %}" id="{{ clear_id }}" title="{% translate 'Clear' %}" href="#">
<span class="fa fa-close filer-icon filer-icon-remove-selection"></span>
</a>
<div class="hidden">{{ hidden_input }}</div>
</span>
</div>
<script type="text/javascript">
Expand All @@ -26,13 +28,13 @@
(function ($) {
var clearButton = $('#{{ clear_id }}');
var input = $('#{{ id }}');
var folderName = $('#{{ descid }}');
var folderName = $('#{{ descid }} .description_text');
var addFolderButton = $('#{{ lookup_name }}');

clearButton.on('click', function () {
folderName.text('{% trans "Folder" %}: {% trans "none selected" %}');
folderName.text('');
input.removeAttr('value');

folderName.closest('.filerFile').find('img').addClass('hidden');
clearButton.addClass('hidden');
addFolderButton.removeClass('hidden');
});
Expand Down

0 comments on commit 4733fd4

Please sign in to comment.