{% import "components/ui/v1.html" as ui_v1 %} {% macro render(title, items, kind, actionUrl, toolbarUrl='', toolbarLabel='', emptyLabel='') %}

{{ title }}

{{ _('Drag the handle or use the move buttons to reorder. On the handle, use Arrow Up, Arrow Down, Home, or End.') }} {{ _('Use the move buttons to reorder.') }}

{% if toolbarUrl %} {{ toolbarLabel }} {% endif %}
{% if items.length %}
    {% for item in items %} {% if kind == 'course' %} {% set itemId = item.docId %} {% set itemEditUrl = url('course_edit', cid=item.docId) %} {% set itemMeta = _('{0} enrolled').format(item.attend|default(0)) %} {% elif kind == 'section' %} {% set itemId = item.docId %} {% set itemEditUrl = url('course_section_edit', cid=cdoc.docId, csid=item.docId) %} {% set itemMeta = _('{0} subsections').format(item.dag.length if item.dag else 0) %} {% else %} {% set itemId = item._id %} {% set itemEditUrl = url('course_subsec_edit', cid=cdoc.docId, csid=csdoc.docId, ssid=item._id) %} {% set itemMeta = _('{0} problems').format(item.pids.length if item.pids else 0) %} {% endif %}
  1. {{ ui_v1.sortable_handle(_('Drag to reorder') ~ ': ' ~ item.title, 'course-structure-help-' ~ kind, items.length > 1, 'nojs--hide') }} {{ ui_v1.sortable_index(loop.index) }}
    {{ item.title }}
    {{ itemMeta }}
    {{ ui_v1.sortable_action(_('Move Up'), _('Move Up') ~ ': ' ~ item.title, action='up', disabled=loop.first, button_type='submit', name='move', value=itemId ~ ':up') }} {{ ui_v1.sortable_action(_('Move Down'), _('Move Down') ~ ': ' ~ item.title, action='down', disabled=loop.last, button_type='submit', name='move', value=itemId ~ ':down') }} {{ ui_v1.sortable_action(_('Edit'), _('Edit') ~ ': ' ~ item.title, href=itemEditUrl) }}
  2. {% endfor %}
{% else %} {{ ui_v1.empty_state(emptyLabel) }} {% endif %}

{% endmacro %}