combo/combo/data/templates/combo/manager/link-list-cell-form.html

60 lines
2.5 KiB
HTML

{% extends "combo/cell_form.html" %}
{% load i18n %}
{% block cell-form %}
{{ form.as_p }}
{% with cell.get_items_with_prefetch as links %}
{% if links %}
<p><label>{% trans "Links:" %}</label></p>
<div>
<ul class="objects-list list-of-links" id="list-of-links-{{ cell.pk }}"
data-link-list-order-url="{% url 'combo-manager-link-list-order' page_pk=page.pk cell_reference=cell.get_reference %}">
{% for link in links %}
<li data-link-item-id="{{ link.pk }}"><span class="handle"></span>
<span title="{{ link }}">
{{ link|truncatechars:100 }}
{% with link.get_invalid_reason as invalid_reason %}
{% if invalid_reason %}
<span class="invalid">{{ invalid_reason }} -
{% if cell.get_validity_info.invalid_datetime|datetime_in_past %}
{% blocktrans with link.get_validity_info.invalid_datetime|date:"DATETIME_FORMAT" as invalidity_date %}This link is no longer displayed since {{ invalidity_date }}.{% endblocktrans %}
{% else %}
{% blocktrans with link.get_validity_info.invalid_datetime|timeuntil as invalidity_delay %}This link will no longer be displayed in {{ invalidity_delay }}.{% endblocktrans %}
{% endif %}
</span>
{% endif %}
{% endwith %}
</span>
<a rel="popup" title="{% trans "Edit" %}" class="link-action-icon edit" href="{% url 'combo-manager-page-list-cell-edit-link' page_pk=page.id cell_reference=cell.get_reference link_cell_reference=link.get_reference %}">{% trans "Edit" %}</a>
<a rel="popup" title="{% trans "Delete" %}" class="link-action-icon delete" href="{% url 'combo-manager-page-list-cell-delete-link' page_pk=page.id cell_reference=cell.get_reference link_cell_reference=link.get_reference %}">{% trans "Delete" %}</a>
</li>
{% endfor %}
</ul>
</div>
<script>
$(function () {
$('#list-of-links-{{ cell.pk }}').sortable({
handle: '.handle',
update: function(event, ui) {
var new_order = Object();
$(this).find('li').each(function(i, x) {
var suffix = $(x).data('link-item-id');
new_order['pos_' + suffix] = i;
});
$.ajax({
url: $(this).data('link-list-order-url'),
data: new_order
});
}
});
});
</script>
{% endif %}
{% endwith %}
<div class="buttons">
{% for klass in cell.get_link_cell_classes %}
<a rel="popup" href="{% url 'combo-manager-page-list-cell-add-link' page_pk=page.id cell_reference=cell.get_reference link_code=klass.add_as_link_code %}">{{ klass.add_as_link_label }}</a> {% if not forloop.last %}|{% endif %}
{% endfor %}
</div>
{% endblock %}