2016-11-01 11:18:27 +08:00
|
|
|
<% content_for :title, 'Notifications | Metamaps' %>
|
|
|
|
<% content_for :mobile_title, 'Notifications' %>
|
|
|
|
|
|
|
|
<div id="yield">
|
|
|
|
<div class="centerContent notificationsPage">
|
2016-12-12 16:07:34 -05:00
|
|
|
<header class="page-header">
|
2016-12-15 23:57:37 -05:00
|
|
|
<h2 class="title">Notifications</h4>
|
2016-12-12 16:07:34 -05:00
|
|
|
</header>
|
2016-11-01 11:18:27 +08:00
|
|
|
<ul class="notifications">
|
2017-02-11 00:20:42 -05:00
|
|
|
<% blacklist = [MAP_ACCESS_REQUEST, MAP_ACCESS_APPROVED, MAP_INVITE_TO_EDIT] %>
|
2017-09-25 15:21:04 -04:00
|
|
|
<% notifications = @notifications.to_a.delete_if{|n| blacklist.include?(n.notification_code) && (n.notified_object.nil? || n.notified_object.map.nil?) }%>
|
2017-02-09 07:37:35 -08:00
|
|
|
<% notifications.each do |notification| %>
|
2016-11-01 11:18:27 +08:00
|
|
|
<% receipt = @receipts.find_by(notification_id: notification.id) %>
|
|
|
|
<li class="notification <%= receipt.is_read? ? 'read' : 'unread' %>" id="notification-<%= notification.id %>">
|
|
|
|
<%= link_to notification_path(notification.id) do %>
|
2016-12-15 23:57:37 -05:00
|
|
|
<div class="notification-actor">
|
|
|
|
<%= image_tag notification.sender.image(:thirtytwo) %>
|
2016-11-01 11:18:27 +08:00
|
|
|
</div>
|
|
|
|
<div class="notification-body">
|
2016-12-15 23:57:37 -05:00
|
|
|
<div class="in-bold"><%= notification.sender.name %></div>
|
2017-02-11 09:06:01 -05:00
|
|
|
<%
|
2017-02-11 00:20:42 -05:00
|
|
|
case notification.notification_code
|
2017-02-11 09:06:01 -05:00
|
|
|
when MAP_ACCESS_APPROVED %>
|
|
|
|
<% map = notification.notified_object.map %>
|
|
|
|
granted your request to edit map <span class="in-bold"><%= map.name %></span>
|
|
|
|
<% when MAP_ACCESS_REQUEST %>
|
|
|
|
<% map = notification.notified_object.map %>
|
|
|
|
wants permission to map with you on <span class="in-bold"><%= map.name %></span>
|
|
|
|
<% if !notification.notified_object.answered %>
|
|
|
|
<div class="action">Offer a response</div>
|
|
|
|
<% end %>
|
|
|
|
<% when MAP_INVITE_TO_EDIT %>
|
|
|
|
<% map = notification.notified_object.map %>
|
|
|
|
gave you edit access to map <span class="in-bold"><%= map.name %></span>
|
|
|
|
<% when TOPIC_ADDED_TO_MAP %>
|
|
|
|
<% topic = notification.notified_object.eventable
|
|
|
|
map = notification.notified_object.map %>
|
|
|
|
added topic <span class="in-bold"><%= topic.name %></span> to map <span class="in-bold"><%= map.name %></span>
|
|
|
|
<% when TOPIC_CONNECTED_1 %>
|
2017-05-13 10:49:46 -07:00
|
|
|
<% topic1 = notification.notified_object&.topic1 %>
|
|
|
|
<% topic2 = notification.notified_object&.topic2 %>
|
|
|
|
connected <span class="in-bold"><%= topic1&.name %></span> to <span class="in-bold"><%= topic2&.name %></span>
|
2017-02-11 09:06:01 -05:00
|
|
|
<% when TOPIC_CONNECTED_2 %>
|
2017-05-13 10:49:46 -07:00
|
|
|
<% topic1 = notification.notified_object&.topic1 %>
|
|
|
|
<% topic2 = notification.notified_object&.topic2 %>
|
|
|
|
connected <span class="in-bold"><%= topic2&.name %></span> to <span class="in-bold"><%= topic1&.name %></span>
|
2017-02-11 09:06:01 -05:00
|
|
|
<% when MESSAGE_FROM_DEVS %>
|
|
|
|
<%= notification.subject %>
|
|
|
|
<% end %>
|
2016-11-01 11:18:27 +08:00
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
<div class="notification-read-unread">
|
|
|
|
<% if receipt.is_read? %>
|
|
|
|
<%= link_to 'mark as unread', mark_unread_notification_path(notification.id), remote: true, method: :put %>
|
|
|
|
<% else %>
|
|
|
|
<%= link_to 'mark as read', mark_read_notification_path(notification.id), remote: true, method: :put %>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
2016-12-15 23:57:37 -05:00
|
|
|
<div class="notification-date">
|
|
|
|
<%= notification.created_at.strftime("%b %d") %>
|
|
|
|
</div>
|
2016-12-12 16:07:34 -05:00
|
|
|
<div class="clearfloat"></div>
|
2016-11-01 11:18:27 +08:00
|
|
|
</li>
|
|
|
|
<% end %>
|
2017-02-09 07:37:35 -08:00
|
|
|
<% if notifications.count == 0 %>
|
2016-12-13 02:42:33 -05:00
|
|
|
<div class="emptyInbox">
|
2016-12-15 17:34:42 -05:00
|
|
|
You have no notifications. More time for dancing.
|
2016-12-13 02:42:33 -05:00
|
|
|
</div>
|
2016-11-28 17:37:27 -05:00
|
|
|
<% end %>
|
2016-11-01 11:18:27 +08:00
|
|
|
</ul>
|
|
|
|
</div>
|
2016-12-11 17:29:48 -05:00
|
|
|
|
|
|
|
<% if @notifications.total_pages > 1 %>
|
2016-12-12 16:07:34 -05:00
|
|
|
<div class="centerContent withPadding pagination">
|
2016-12-11 17:29:48 -05:00
|
|
|
<%= paginate @notifications %>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
2016-11-01 11:18:27 +08:00
|
|
|
</div>
|