{#- A folder: its path, its subfolders and documents in one table (or as tiles), a bar for what applies to the selection; the community's folders beside it. Drawn in `mockups/templates/folder.html`. The card is the selection's form: what is ticked goes with Download, Move, Delete. The filter and the view switch belong to forms of their own, outside it. -#} {% extends "ads_community.html" %} {% set folder_post = url_for(".folder_post", community_id=g.community.slug, folder_id=folder.id) %} {% block page_title %}{{ folder.title }} · {{ _("Documents") }} · {{ g.community.name }}{% endblock %} {#- What `folder.js` reads to fill a dialog from a row: hidden, unnamed, never sent. -#} {% macro item_data(obj) -%} {% if obj.is_folder -%} {%- else -%} {%- endif %} {%- endmacro %} {#- What can be done to one item. Download, Move and Delete tick it alone and do what the selection's buttons do. -#} {% macro item_menu(obj) %}
{{ icon("dots") }}
{% if obj.is_folder %} {{ icon("folders") }}{{ _("Everything in it") }} {% if may_manage %}{{ icon("shield-lock") }}{{ _("Permissions") }}{% endif %} {% if may_write %}{% endif %} {% else %} {{ icon("download") }}{{ _("Download") }} {% if may_write %} {#- A document someone else locked takes no version from another (`document_upload`). -#} {% if obj.lock is none or obj.lock.is_owner(current_user) %} {% endif %} {% endif %} {% endif %} {% if may_write %}
{% endif %}
{{ item_data(obj) }} {% endmacro %} {% macro select_box(obj) -%} {%- endmacro %} {#- A folder's size is what it holds. -#} {% macro size(obj) -%} {% if obj.is_folder %}{{ ngettext("%(num)d item", "%(num)d items", counts[obj.id]) }}{% else %}{{ obj.content_length | filesize }}{% endif %} {%- endmacro %} {#- The tree: a folder with subfolders has a button that shows or hides them (a `
` holding only its summary; `theme.css` shows the list that follows). -#} {% macro tree_nodes(nodes) %} {% for node in nodes %}
  • {%- if node.children %}
    {{ icon("chevron-right") }}
    {%- else %}{% endif -%} {{ folder_icon() }}{{ node.folder.title }}
    {% if node.children %}{% endif %}
  • {% endfor %} {% endmacro %} {% block content %}
    {{ csrf.field() }} {#- The folder, and what to do in it or to it. -#}
    {% if breadcrumbs | length > 1 %}
      {% for crumb in breadcrumbs[:-1] %}
    1. {{ crumb.label }}
    2. {% endfor %}
    {% endif %}

    {{ folder_icon() }}{{ folder.title }}

    {% if folder.description %}

    {{ folder.description }}

    {% endif %}
    {% if may_write %} {% endif %}
    {{ icon("dots-vertical") }}
    {{ icon("folders") }}{{ _("Everything in it") }} {% if may_write %}{% endif %} {% if may_manage and breadcrumbs | length > 1 %}{{ icon("shield-lock") }}{{ _("Permissions") }}{% endif %}
    {{ item_data(folder) }}
    {#- At rest: filter the folder, choose how to see it. Once something is ticked, what applies to the selection takes their place (ADS's datatable does the switch). -#}
    {{ icon("filter") }} {{ ngettext("%(num)d item", "%(num)d items", listing.total) }} {% if listing.search %}{{ _("Show all") }}{% endif %}
    {{ _("Selection") }} {% if may_write %} {% endif %} {% if may_manage %} {% endif %} {% if may_write %} {% endif %}
    {% if not children %}
    {%- if listing.search %}{{ _("Nothing in this folder has these words in its name.") }} {%- elif may_write %}{{ _("This folder is empty. Upload files into it, or create a folder.") }} {%- else %}{{ _("This folder is empty.") }}{% endif -%}
    {% elif gallery %}
    {% else %}
    {{ m.sort_th(listing, "title", _("Name")) }} {{ m.sort_th(listing, "size", _("Size"), "ads-end ads-col--secondary") }} {{ m.sort_th(listing, "owner", _("Owner"), "ads-col--secondary") }} {{ m.sort_th(listing, "age", _("Added"), "ads-end") }} {% for obj in children %} {% endfor %}
    {{ _("Actions") }}
    {{ select_box(obj) }} {%- if obj.is_folder %}{{ folder_icon() }}{{ obj.title }} {%- else %}{{ file_icon(obj.title) }}{{ obj.title }}{% endif -%} {{ size(obj) }} {% if obj.owner %}{{ m.avatar(obj.owner, "ads-avatar--xs") }}{% endif %} {{ m.time(obj.created_at) }} {{ item_menu(obj) }}
    {% endif %} {{ m.pagination(listing) }}
    {#- The forms that controls of the card belong to through their `form` attribute. -#} {% endblock %} {% block overlays %} {% import "documents/_dialogs.html" as dialogs with context %} {% if may_write %}{{ dialogs.folder_dialogs(folder) }}{{ dialogs.document_dialogs() }}{{ dialogs.move_dialog(folder) }}{% endif %} {% if may_manage %}{{ dialogs.change_owner_dialog(folder) }}{% endif %} {% endblock %}