combo/combo/apps/wcs/templates/combo/wcs/card.html

117 lines
5.7 KiB
HTML

{% load i18n %}
{% block cell-content %}
{% if not card_not_found %}
{% block cell-header %}
{% if title %}<h2>{{ title|force_escape }}</h2>{% endif %}
{% include "combo/asset_picture_fragment.html" %}
{% endblock %}
{% if card.id %}
{% spaceless %}
{% if cell.custom_schema %}
{% if cell.custom_schema.cells %}
<div class="cell--body">
{% with cell.get_custom_schema as custom_schema %}
<div class="{{ custom_schema.grid_class }}">
{% for item in custom_schema.cells %}
{% if item.varname == "@custom@" %}
{% if item.template %}
<div class="{{ item.cell_size|default:"" }}">
{% with card.custom_fields|get:item.template|force_escape as value %}
{% if item.display_mode == "title" %}
<h3>{{ value }}</h3>
{% elif item.display_mode == "subtitle" %}
<h4>{{ value }}</h4>
{% elif item.display_mode == "label" %}
<div class="label">{{ value }}</div>
{% elif item.display_mode == "text" %}
<div class="value">{{ value }}</div>
{% endif %}
{% endwith %}
</div>
{% endif %}
{% elif item.varname == "@link@" %}
{% firstof item.link_field item.page item.url_template as link %}
{% if item.template and link %}
<div class="{{ item.cell_size|default:"" }}">
{% with card.custom_fields|get:item.template|force_escape as link_label %}
{% if link_label %}
{% if item.link_field %}
{% with fields_by_varnames|get:item.link_field as field and card.fields|get:item.link_field as value %}
{% if field and value and field.type == 'file' %}
<div class="value"><a href="{% make_public_url url=value.url %}"{% if item.display_mode == 'button' %} class="pk-button"{% endif %} download="{{ value.filename }}">{{ link_label }}</a></div>
{% endif %}
{% endwith %}
{% else %}
{% with item.page|default:item.url_template as url_key %}
{% with card.urls|get:url_key|force_escape as link_url %}
{% if link_url %}
<div class="value"><a href="{{ link_url }}"{% if item.display_mode == 'button' %} class="pk-button"{% endif %}>{{ link_label }}</a></div>
{% endif %}
{% endwith %}
{% endwith %}
{% endif %}
{% endif %}
{% endwith %}
</div>
{% endif %}
{% else %}
{% if item.varname %}
{% with fields_by_varnames|get:item.varname as field %}
{% if field %}
{% with card.fields|get:item.varname as value %}
{% if value or item.empty_value != '@skip@' %}
<div class="{{ item.cell_size|default:"" }}">
{% if item.display_mode == "title" %}
{% include "combo/wcs/card-field-as-title.html" with title_tag="h3" %}
{% elif item.display_mode == "subtitle" %}
{% include "combo/wcs/card-field-as-title.html" with title_tag="h4" %}
{% elif item.display_mode == "text" %}
{% if value or item.empty_value == '@empty@' %}
{% include "combo/wcs/card-field-as-text.html" %}
{% else %}
{% with item.empty_value as value %}
{% include "combo/wcs/card-field-as-text.html" with empty=True %}
{% endwith %}
{% endif %}
{% endif %}
</div>
{% endif %}
{% endwith %}
{% endif %}
{% endwith %}
{% endif %}
{% endif %}
{% endfor%}
</div>
{% endwith %}
</div>
{% endif %}
{% else %}
<div class="cell--body">
{% for field in schema.fields %}
{% if 'varname' in field and field.varname %}
{% with card.fields|get:field.varname as value %}
<div class="card--auto-field">
<div class="label">{{ field.label }}</div>
{% include "combo/wcs/card-field-value.html" %}
</div>
{% endwith %}
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endspaceless %}
{% else %}
<div class="cell--body">
<p>{% trans 'Unknown Card' %}</p>
</div>
{% endif %}
{% endif %}
{% endblock %}