{% extends 'TopxiaWebBundle::layout.html.twig' %}

{% block title %}私信 - {{ parent() }}{% endblock %}
{% set script_controller = 'message/conversation-list' %}

{% block content %}
<div class="row row-8">
  <div class="col-md-8 col-md-offset-2">
    <div class="panel panel-default panel-page">
      <div class="panel-heading">
        {# <a class="btn btn-primary pull-right" href="{{ path('message_send') }}">写私信</a>  hidden by wenqin #}
        <h2>私信</h2>
      </div>

      <ul class="media-list conversation-list">
        {% for conversation in conversations %}
          {% set fromUser = users[conversation.fromId] %}
          <li class="media" data-url="{{ path('message_conversation_show', {conversationId:conversation.id })}}">
            {{ web_macro.user_avatar(fromUser, 'pull-left media-object') }}
            <div class="media-body">
              <h4 class="media-heading">
                {% if conversation.latestMessageUserId == app.user.id %}
                  发给
                {% endif  %}
                {{ web_macro.user_link(fromUser) }}:
                {{conversation.latestMessageContent|plain_text(40)}}

                {% if conversation.unreadNum > 0 %}
                  <span class="text-warning">({{conversation.unreadNum}}条未读)</span>
                {% endif %}
              </h4>

              <div class="conversation-footer clearfix">
                <span class="pull-left">{{ conversation.latestMessageTime|smart_time }}</span>
                <span class="pull-right">共{{ conversation.messageNum }}条</span>
                <div class="actions pull-right">
                  <a class="delete-conversation-btn text-muted" href="javascript:" data-url="{{ path('message_conversation_delete', {conversationId:conversation.id })}}">删除</a>
                  <span class="text-muted mhm">|</span> 
                </div>
              </div>
            </div>
          </li>
        {% else %}
          <li class="empty">暂无私信</li>
        {% endfor %}
      </ul>

      {{ web_macro.paginator(paginator) }}

    </div><!-- /panel -->
  </div>
</div>

{% endblock %}