Better experience of notifications. (#1066)
* all the good changes * follows * dont send duplicates * remove follow_type for now * dont add all the extra stuff we're not implementing yet * refactor * lots of fixes * notifications improvements * bad merge
This commit is contained in:
parent
b0deafc53e
commit
876c61a18e
8 changed files with 118 additions and 35 deletions
|
@ -83,6 +83,7 @@ $unread_notifications_dot_size: 8px;
|
|||
|
||||
.notification-body {
|
||||
margin-left: 50px;
|
||||
line-height: 20px;
|
||||
|
||||
.in-bold {
|
||||
font-family: 'din-medium', Sans-Serif;
|
||||
|
@ -130,9 +131,35 @@ $unread_notifications_dot_size: 8px;
|
|||
|
||||
|
||||
|
||||
.notificationPage .notification-body {
|
||||
p, div {
|
||||
margin: 1em auto;
|
||||
.notificationPage {
|
||||
.thirty-two-avatar {
|
||||
display: inline-block;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 16px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.button {
|
||||
line-height: 32px;
|
||||
|
||||
img {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
&.decline {
|
||||
background: #DB5D5D;
|
||||
&:hover {
|
||||
background: #DC4B4B;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.notification-body {
|
||||
p, div {
|
||||
margin: 1em auto;
|
||||
line-height: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ class AccessController < ApplicationController
|
|||
request = AccessRequest.find(params[:request_id])
|
||||
request.approve
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.json do
|
||||
head :ok
|
||||
end
|
||||
|
@ -72,6 +73,7 @@ class AccessController < ApplicationController
|
|||
request = AccessRequest.find(params[:request_id])
|
||||
request.deny
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.json do
|
||||
head :ok
|
||||
end
|
||||
|
|
|
@ -21,7 +21,18 @@ class NotificationsController < ApplicationController
|
|||
def show
|
||||
@receipt.update(is_read: true)
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.html do
|
||||
case @notification.notification_code
|
||||
when MAP_ACCESS_APPROVED, MAP_INVITE_TO_EDIT
|
||||
redirect_to map_path(@notification.notified_object.map)
|
||||
when TOPIC_ADDED_TO_MAP
|
||||
redirect_to map_path(@notification.notified_object.map)
|
||||
when TOPIC_CONNECTED_1
|
||||
redirect_to topic_path(@notification.notified_object.topic1)
|
||||
when TOPIC_CONNECTED_2
|
||||
redirect_to topic_path(@notification.notified_object.topic2)
|
||||
end
|
||||
end
|
||||
format.json do
|
||||
render json: @notification.as_json.merge(
|
||||
is_read: @receipt.is_read
|
||||
|
|
1
app/views/access/approve_access_post.js.erb
Normal file
1
app/views/access/approve_access_post.js.erb
Normal file
|
@ -0,0 +1 @@
|
|||
$('.main-text').text($('.requesterName').text() + ' has been shared on the map and notified.')
|
1
app/views/access/deny_access_post.js.erb
Normal file
1
app/views/access/deny_access_post.js.erb
Normal file
|
@ -0,0 +1 @@
|
|||
$('.main-text').text('Fair enough.')
|
|
@ -18,34 +18,35 @@
|
|||
</div>
|
||||
<div class="notification-body">
|
||||
<div class="in-bold"><%= notification.sender.name %></div>
|
||||
<%=
|
||||
<%
|
||||
case notification.notification_code
|
||||
when MAP_ACCESS_APPROVED
|
||||
map = notification.notified_object.map
|
||||
output = 'granted your request to edit map <span class="in-bold">' + map.name + '</span>'
|
||||
when MAP_ACCESS_REQUEST
|
||||
map = notification.notified_object.map
|
||||
output = 'wants permission to map with you on <span class="in-bold">' + map.name + '</span> <div class="action">Offer a response</div>'
|
||||
when MAP_INVITE_TO_EDIT
|
||||
map = notification.notified_object.map
|
||||
output = '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
|
||||
output = 'added topic <span class="in-bold">' + topic.name + '</span> to map <span class="in-bold">' + map.name + '</span>'
|
||||
when TOPIC_CONNECTED_1
|
||||
topic1 = notification.notified_object.topic1
|
||||
topic2 = notification.notified_object.topic2
|
||||
output = 'connected <span class="in-bold">' + topic1.name + '</span> to <span class="in-bold">' + topic2.name + '</span>'
|
||||
when TOPIC_CONNECTED_2
|
||||
topic1 = notification.notified_object.topic1
|
||||
topic2 = notification.notified_object.topic2
|
||||
output = 'connected <span class="in-bold">' + topic2.name + '</span> to <span class="in-bold">' + topic1.name + '</span>'
|
||||
when MESSAGE_FROM_DEVS
|
||||
output = notification.subject
|
||||
end
|
||||
raw output
|
||||
%>
|
||||
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 %>
|
||||
<% 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>
|
||||
<% when TOPIC_CONNECTED_2 %>
|
||||
<% 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>
|
||||
<% when MESSAGE_FROM_DEVS %>
|
||||
<%= notification.subject %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="notification-read-unread">
|
||||
|
|
|
@ -6,10 +6,48 @@
|
|||
<%= link_to 'Back to notifications', notifications_path %>
|
||||
</div>
|
||||
<div class="centerContent notificationPage">
|
||||
<h2 class="notification-title"><%= @notification.subject %></h4>
|
||||
<div class="notification-body">
|
||||
<%= raw @notification.body %>
|
||||
</div>
|
||||
<h2 class="notification-title">
|
||||
<% case @notification.notification_code
|
||||
when MAP_ACCESS_REQUEST
|
||||
request = @notification.notified_object
|
||||
map = request.map %>
|
||||
<%= image_tag @notification.sender.image(:thirtytwo), class: 'thirty-two-avatar' %> <span style='font-weight:bold;' class='requesterName'><%= request.user.name %></span> wants to collaborate on map <span style='font-weight:bold;'><%= map.name %></span>
|
||||
<% else %>
|
||||
<%= @notification.subject %>
|
||||
<% end %>
|
||||
</h2>
|
||||
<% case @notification.notification_code
|
||||
when MAP_ACCESS_REQUEST %>
|
||||
<div class="notification-body">
|
||||
<p class="main-text">
|
||||
<% if false && request.answered %>
|
||||
<% if request.approved %>
|
||||
You already responded to this access request, and allowed access.
|
||||
<% elsif !request.approved %>
|
||||
You already responded to this access request, and declined access. If you changed your mind, you can still grant
|
||||
them access by going to the map and adding them as a collaborator.
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= image_tag asset_path('ellipsis.gif'), class: 'hidden' %>
|
||||
<%= link_to 'Allow', approve_access_post_map_path(id: map.id, request_id: request.id), remote: true, method: :post, class: 'button allow' %>
|
||||
<%= link_to 'Decline', deny_access_post_map_path(id: map.id, request_id: request.id), remote: true, method: :post, class: 'button decline' %>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.notification-body .button').click(function() {
|
||||
$(this).html('<img src="<%= asset_path('ellipsis.gif') %>" />')
|
||||
})
|
||||
})
|
||||
</script>
|
||||
<% end %>
|
||||
</p>
|
||||
<%= link_to 'Go to map', map_url(map) %>
|
||||
<%= link_to 'View mapper profile', explore_path(id: request.user.id) %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="notification-body">
|
||||
<%= raw @notification.body %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -37,9 +37,11 @@ Metamaps::Application.routes.draw do
|
|||
default: { format: :json }
|
||||
post 'approve_access/:request_id',
|
||||
to: 'access#approve_access_post',
|
||||
as: :approve_access_post,
|
||||
default: { format: :json }
|
||||
post 'deny_access/:request_id',
|
||||
to: 'access#deny_access_post',
|
||||
as: :deny_access_post,
|
||||
default: { format: :json }
|
||||
|
||||
post :access, to: 'access#access', default: { format: :json }
|
||||
|
|
Loading…
Reference in a new issue