{#- The dialogs of the documents' pages, on the Abilian Design System. Imported `with context`: they read `g.community`, `csrf` and `url_for`. On a folder's page, those that act on one item are filled from its row by `vite/src/documents/folder.js`; on a document's page, from the document. The move and change-owner dialogs act on the selection: on a document's page, the document alone. -#} {#- A dialog holding a form: a title, the fields, Cancel and the button that sends it. -#} {% macro form_dialog(id, title, submit, action="", value=none, attrs={}, form_id=none) -%}
{{ csrf.field() }}

{{ title }}

{{ caller() }}
{%- endmacro %} {#- A name, checked for uniqueness in the folder as it is typed (`name-check.js`), and a description. -#} {% macro name_fields(prefix, title="", description="", title_class="", description_class="") %} {% set check_url = url_for(".check_valid_name", community_id=g.community.slug) %}
{% endmacro %} {#- What is done in a folder: uploading, a new folder, editing it or a subfolder. -#} {% macro folder_dialogs(folder) %} {% set folder_post = url_for(".folder_post", community_id=g.community.slug, folder_id=folder.id) %} {#- Files are sent one at a time as soon as "Upload" is pressed (`upload-dialog.js`). -#}
{{ csrf.field() }}
    {% call form_dialog("modal-new-folder", _("New folder in ā€œ%(name)sā€", name=folder.title), _("Create folder"), folder_post, "new", {"data-no-enter": "", "data-name-check-action": "new", "data-renames": folder.id}) %} {{ name_fields("new-folder") }} {% endcall %} {#- Opened on the folder shown, or on a subfolder, which it is filled from. -#} {% call form_dialog("modal-edit-folder", _("Edit folder properties"), _("Save changes"), folder_post, "edit", {"data-no-enter": "", "data-name-check-action": "folder-edit", "data-renames": folder.id}, "modal-editfolder-form") %} {{ name_fields("edit-folder", folder.title, folder.description or "", "form-folder-title", "form-folder-description") }} {% endcall %} {% endmacro %} {#- What is done to a document: editing it, a new version, sending it. Given `doc`, they act on it; without, on the row they are opened from. -#} {% macro document_dialogs(doc=none) %} {% set kw = {"community_id": g.community.slug, "doc_id": doc.id} if doc else none %} {% call form_dialog("modal-edit", _("Edit document properties"), _("Save changes"), url_for(".document_edit", **kw) if doc else "", "edit", {"data-no-enter": "", "data-name-check-action": "document-edit", "data-renames": doc.id if doc else none}, "modal-edit-form") %} {{ name_fields("edit-document", doc.title if doc else "", doc.description or "" if doc else "", "form-document-title", "form-document-description") }} {% endcall %} {% call form_dialog("modal-upload-new-version", _("Upload new version"), _("Upload"), url_for(".document_upload", **kw) if doc else "", form_id="modal-replace-form") %} {% endcall %} {% call form_dialog("modal-send-by-email", _("Send by email"), _("Send"), url_for(".document_send", **kw) if doc else "", form_id="modal-email-form") %}
    {% endcall %} {% endmacro %} {#- Lists the folders to move into (`folder.js` fetches them), starting from `folder`, and posts the selection to it. -#} {% macro move_dialog(folder) %} {% endmacro %} {% macro change_owner_dialog(folder) %} {% call form_dialog("modal-change-owner", _("Change owner of selected files"), _("Change owner"), url_for(".folder_post", community_id=g.community.slug, folder_id=folder.id), "change-owner") %}
    {% endcall %} {% endmacro %}