summaryrefslogtreecommitdiff
path: root/app/views/pms/index.html.erb
blob: 056b371800594a3b8711b5186a6a3dbb806ecd9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<h1> Your Conversations </h1>

<%= link_to 'Start a new conversation', new_pm_path %>
<br>

<h3>Unread Conversations</h3>
<% conversations = current_user.mailbox.conversations %>

<table>
  <col width="150">
  <col width="250">
  <col width="300">
  <tbody>
    <%# if conversations.reject { |c| c.is_unread?(current_user) && (c.receipts_for current_user).last.message.sender != current_user }.empty? %>
      <tr>
        <tr>
          <td><b>With</b></td>
          <td><b>Subject</b></td>
          <td><b>Body</b></td>
        </tr>
        <% conversations.each do |conversation| %>
          <% receipts = conversation.receipts_for current_user %>
          <% if conversation.is_unread?(current_user) && receipts.last.message.sender != current_user %>
            <% message = receipts.last.message %>
            <tr>
            <td>
              <% people = conversation.participants %>
              <% people.each do |person| %>
                <% unless person == current_user %>
                  <%= truncate(person.user_name, length: 20) %>
                <% end %>
              <% end %>
            </td>
            <td><%= truncate(conversation.subject, length: 30) %></td>
            <td><%= truncate(message.body, length: 42) %></td>
            <td><%= link_to 'View', @pms.find_by(conversation: conversation) %></td>
            </tr>
          <% end %>
        <% end %>
      </tr>
    <%# else %>
      
    <%# end %>
  </tbody>
</table>

<br>
<h3>Read Conversations</h3>
<% conversations = current_user.mailbox.conversations %>

<table>
  <col width="150">
  <col width="250">
  <col width="300">
  <tbody>
    <%# if conversations.reject { |c| c.is_read?(current_user) || (c.receipts_for current_user).last.message.sender == current_user }.empty? %>
      <tr>
        <tr>
          <td><b>With</b></td>
          <td><b>Subject</b></td>
          <td><b>Body</b></td>
        </tr>
        <% conversations.each do |conversation| %>
          <% receipts = conversation.receipts_for current_user %>
          <% if conversation.is_read?(current_user) || receipts.last.message.sender == current_user  %>
            <% message = receipts.last.message %>
            <tr>
            <td>
              <% people = conversation.participants %>
              <% people.each do |person| %>
                <% unless person == current_user %>
                  <%= truncate(person.user_name, length: 20) %>
                <% end %>
              <% end %>
            </td>
            <td><%= truncate(conversation.subject, length: 30) %></td>
            <td><%= truncate(message.body, length: 42) %></td>
            <td><%= link_to 'View', @pms.find_by(conversation: conversation) %></td>
            </tr>
          <% end %>
        <% end %>
      </tr>
    <% #else %>
      
    <% #end %>
  </tbody>
</table>