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 {
|
.notification-body {
|
||||||
margin-left: 50px;
|
margin-left: 50px;
|
||||||
|
line-height: 20px;
|
||||||
|
|
||||||
.in-bold {
|
.in-bold {
|
||||||
font-family: 'din-medium', Sans-Serif;
|
font-family: 'din-medium', Sans-Serif;
|
||||||
|
@ -130,9 +131,35 @@ $unread_notifications_dot_size: 8px;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.notificationPage .notification-body {
|
.notificationPage {
|
||||||
p, div {
|
.thirty-two-avatar {
|
||||||
margin: 1em auto;
|
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 = AccessRequest.find(params[:request_id])
|
||||||
request.approve
|
request.approve
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
format.json do
|
format.json do
|
||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
|
@ -72,6 +73,7 @@ class AccessController < ApplicationController
|
||||||
request = AccessRequest.find(params[:request_id])
|
request = AccessRequest.find(params[:request_id])
|
||||||
request.deny
|
request.deny
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
format.json do
|
format.json do
|
||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,18 @@ class NotificationsController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@receipt.update(is_read: true)
|
@receipt.update(is_read: true)
|
||||||
respond_to do |format|
|
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
|
format.json do
|
||||||
render json: @notification.as_json.merge(
|
render json: @notification.as_json.merge(
|
||||||
is_read: @receipt.is_read
|
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>
|
||||||
<div class="notification-body">
|
<div class="notification-body">
|
||||||
<div class="in-bold"><%= notification.sender.name %></div>
|
<div class="in-bold"><%= notification.sender.name %></div>
|
||||||
<%=
|
<%
|
||||||
case notification.notification_code
|
case notification.notification_code
|
||||||
when MAP_ACCESS_APPROVED
|
when MAP_ACCESS_APPROVED %>
|
||||||
map = notification.notified_object.map
|
<% map = notification.notified_object.map %>
|
||||||
output = 'granted your request to edit map <span class="in-bold">' + map.name + '</span>'
|
granted your request to edit map <span class="in-bold"><%= map.name %></span>
|
||||||
when MAP_ACCESS_REQUEST
|
<% when MAP_ACCESS_REQUEST %>
|
||||||
map = notification.notified_object.map
|
<% 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>'
|
wants permission to map with you on <span class="in-bold"><%= map.name %></span>
|
||||||
when MAP_INVITE_TO_EDIT
|
<% if !notification.notified_object.answered %>
|
||||||
map = notification.notified_object.map
|
<div class="action">Offer a response</div>
|
||||||
output = 'gave you edit access to map <span class="in-bold">' + map.name + '</span>'
|
<% end %>
|
||||||
when TOPIC_ADDED_TO_MAP
|
<% when MAP_INVITE_TO_EDIT %>
|
||||||
topic = notification.notified_object.eventable
|
<% map = notification.notified_object.map %>
|
||||||
map = notification.notified_object.map
|
gave you edit access to map <span class="in-bold"><%= map.name %></span>
|
||||||
output = 'added topic <span class="in-bold">' + topic.name + '</span> to map <span class="in-bold">' + map.name + '</span>'
|
<% when TOPIC_ADDED_TO_MAP %>
|
||||||
when TOPIC_CONNECTED_1
|
<% topic = notification.notified_object.eventable
|
||||||
topic1 = notification.notified_object.topic1
|
map = notification.notified_object.map %>
|
||||||
topic2 = notification.notified_object.topic2
|
added topic <span class="in-bold"><%= topic.name %></span> to map <span class="in-bold"><%= map.name %></span>
|
||||||
output = 'connected <span class="in-bold">' + topic1.name + '</span> to <span class="in-bold">' + topic2.name + '</span>'
|
<% when TOPIC_CONNECTED_1 %>
|
||||||
when TOPIC_CONNECTED_2
|
<% topic1 = notification.notified_object.topic1
|
||||||
topic1 = notification.notified_object.topic1
|
topic2 = notification.notified_object.topic2 %>
|
||||||
topic2 = notification.notified_object.topic2
|
connected <span class="in-bold"><%= topic1.name %></span> to <span class="in-bold"><%= topic2.name %></span>
|
||||||
output = 'connected <span class="in-bold">' + topic2.name + '</span> to <span class="in-bold">' + topic1.name + '</span>'
|
<% when TOPIC_CONNECTED_2 %>
|
||||||
when MESSAGE_FROM_DEVS
|
<% topic1 = notification.notified_object.topic1
|
||||||
output = notification.subject
|
topic2 = notification.notified_object.topic2 %>
|
||||||
end
|
connected <span class="in-bold"><%= topic2.name %></span> to <span class="in-bold"><%= topic1.name %></span>
|
||||||
raw output
|
<% when MESSAGE_FROM_DEVS %>
|
||||||
%>
|
<%= notification.subject %>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="notification-read-unread">
|
<div class="notification-read-unread">
|
||||||
|
|
|
@ -6,10 +6,48 @@
|
||||||
<%= link_to 'Back to notifications', notifications_path %>
|
<%= link_to 'Back to notifications', notifications_path %>
|
||||||
</div>
|
</div>
|
||||||
<div class="centerContent notificationPage">
|
<div class="centerContent notificationPage">
|
||||||
<h2 class="notification-title"><%= @notification.subject %></h4>
|
<h2 class="notification-title">
|
||||||
<div class="notification-body">
|
<% case @notification.notification_code
|
||||||
<%= raw @notification.body %>
|
when MAP_ACCESS_REQUEST
|
||||||
</div>
|
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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,11 @@ Metamaps::Application.routes.draw do
|
||||||
default: { format: :json }
|
default: { format: :json }
|
||||||
post 'approve_access/:request_id',
|
post 'approve_access/:request_id',
|
||||||
to: 'access#approve_access_post',
|
to: 'access#approve_access_post',
|
||||||
|
as: :approve_access_post,
|
||||||
default: { format: :json }
|
default: { format: :json }
|
||||||
post 'deny_access/:request_id',
|
post 'deny_access/:request_id',
|
||||||
to: 'access#deny_access_post',
|
to: 'access#deny_access_post',
|
||||||
|
as: :deny_access_post,
|
||||||
default: { format: :json }
|
default: { format: :json }
|
||||||
|
|
||||||
post :access, to: 'access#access', default: { format: :json }
|
post :access, to: 'access#access', default: { format: :json }
|
||||||
|
|
Loading…
Add table
Reference in a new issue