summaryrefslogtreecommitdiff
path: root/app/views/pms/index.html.erb
blob: c823efb45191bfcbeba69a3033a22b2c1be1242e (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<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>
            <% if conversation.subject == "Pay Attention!" %>
              <% conversation.mark_as_read(current_user) %>
            <% end %>
            <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>
            <% if conversation.subject != "Pay Attention!" %>
              <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>
            <% end %>
            </tr>
          <% end %>
        <% end %>
      </tr>
    <% #else %>
      
    <% #end %>
  </tbody>
</table>

<br>
<h3>Alerts</h3>
<% conversations = current_user.mailbox.conversations %>

<table>
  <col width="150">
  <col width="650">
  <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>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>
            <% if conversation.subject == "Pay Attention!" && message.sender != current_user %>
              <td>
                <% people = conversation.participants %>
                <% people.each do |person| %>
                  <% unless person == current_user %>
                    <%= truncate(person.user_name, length: 20) %>
                  <% end %>
                <% end %>
              </td>
              <td><%= truncate(message.body, length: 80) %></td>
              <td><%= link_to 'View', @pms.find_by(conversation: conversation) %></td>
            <% end %>
            </tr>
          <% end %>
        <% end %>
      </tr>
    <% #else %>
      
    <% #end %>
  </tbody>
</table>

<br>
<br>
<br>