{% load l10n i18n %}
{% load action_item_extras %}
{% comment %}

 	Renders a single list-item for a listgroup of action items.

 	The list-item has a popover to display details of the action item.

 	popover is contained in "data-content" attr

 {% endcomment %}


<a id="actionitem-{{action_identifier}}"
tabindex="{{ tabindex }}"
class="list-group-item list-group-item-{{ action_item.label_color }}"
href="javascript://" data-toggle="popover" data-placement="auto" data-html="true" title="{{ popover_title|default:'Action Item'}}" role="button"
data-content="
<div class='list-group'>
<div class='list-group-item list-group-item-default'><p><small>{{ action_item.action_identifier }}</small></p>
<span class='label label-{% if action_item.status == OPEN %}info{% elif action_item.status == NEW %}warning{% else %}default{% endif %}'>{{ action_item.get_status_display }}</span>
<span class='label label-{% if action_item.priority == HIGH_PRIORITY %}danger{% else %}warning{% endif %}'>{{ action_item.get_priority_display|title }}</span>
<h6>{{ action_item.display_name|default:'alert' }}</h6>
<p class='text text-muted'>{% render_action_item_reason action_item %}</p>
{% if action_item.instructions %}<p class='text text-muted'><small>{{ action_item.instructions|truncatechars:250 }}</small></p>{% endif %}
<p class='text text-muted'>
	<small>{%  trans "Opened on" %} {{ report_datetime }}. {% if date_last_updated %}{% trans "Last updated on" %} {{date_last_updated}} {% if user_last_updated %}{% trans "by" %} {{user_last_updated}}{% endif %}{% else %}{% trans "This action item has not been updated." %}{% endif %}</small>
</p>
</div>

{% render_popover_list_item  action_item=action_item action_item_type="reference" appointment=appointment %}

{% if action_item.parent_reference_obj and action_item.related_reference_obj and action_item.parent_reference_obj.action_identifier == action_item.related_reference_obj.action_identifier  %}
  {% render_popover_list_item  action_item=action_item action_item_type="parent" appointment=appointment %}
{% else %}
  {% if action_item.parent_reference_obj %}
    {% render_popover_list_item  action_item=action_item action_item_type="parent" appointment=appointment %}
  {% endif %}
  {% if action_item.related_reference_obj %}
    {% render_popover_list_item  action_item=action_item action_item_type="related" appointment=appointment %}
  {% endif %}
{% endif %}

{% render_action_item_button  action_item=action_item label="Action item" color="default" appointment=appointment %}

">
<i class="fas fa-caret-left" aria-hidden="true"></i>
<span class="text text-{{ action_item_color }}" title="{% trans "Click to see more" %} ...">
<small>{{ action_item.display_name }} {{ action_age }}</small>
</span>
</a>
