From 0946e2a365eed2dba4eb956c984ee837048a9be1 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Thu, 15 Dec 2016 23:57:37 -0500 Subject: [PATCH] styling of notifs list --- app/assets/stylesheets/mobile.scss.erb | 18 +++++ app/assets/stylesheets/notifications.scss.erb | 75 +++++++++++++------ app/services/notification_service.rb | 19 ++++- app/views/notifications/index.html.erb | 12 ++- 4 files changed, 95 insertions(+), 29 deletions(-) diff --git a/app/assets/stylesheets/mobile.scss.erb b/app/assets/stylesheets/mobile.scss.erb index 54004dc7..fc34168d 100644 --- a/app/assets/stylesheets/mobile.scss.erb +++ b/app/assets/stylesheets/mobile.scss.erb @@ -8,6 +8,13 @@ } } +/* when this switches to two lines */ +@media only screen and (max-width : 728px) { + .controller-notifications .notificationsPage .notification .notification-read-unread a { + margin-top: -20px !important; + } +} + @media only screen and (max-width : 390px) { .map .mapCard .mobileMetadata { width: 190px; @@ -33,6 +40,17 @@ display: none !important; } + .notificationsPage .page-header { + display: none; + } + + .controller-notifications .notificationsPage .notification .notification-read-unread { + display: block !important; + } + .controller-notifications .notificationsPage .notification .notification-date { + display: none; + } + #mobile_header { display: block; } diff --git a/app/assets/stylesheets/notifications.scss.erb b/app/assets/stylesheets/notifications.scss.erb index 5058bc62..16f96407 100644 --- a/app/assets/stylesheets/notifications.scss.erb +++ b/app/assets/stylesheets/notifications.scss.erb @@ -48,20 +48,20 @@ $unread_notifications_dot_size: 8px; padding-top: 15px; } - .notification:first-child { - border-top: none; - } - .notification:last-child { - border-bottom: 1px solid #DCDCDC; - } - .notification { padding: 10px; - border:1px solid #DCDCDC; - border-bottom: none; + position: relative; &:hover { background: #F6F6F6; + + .notification-read-unread { + display:block; + } + + .notification-date { + display: none; + } } & > a { @@ -71,27 +71,58 @@ $unread_notifications_dot_size: 8px; padding-right: 10px; } - .notification-read-unread { + .notification-actor { float: left; - width: 15%; - } - .notification-body, - .notification-subject { - display: inline-block; - vertical-align: top; + img { + width: 32px; + height: 32px; + border-radius: 16px; + } } .notification-body { - margin-left: 15px; + margin-left: 50px; + + .in-bold { + font-family: 'din-medium', Sans-Serif; + } + + .action { + background: #4fb5c0; + color: #FFF; + padding: 2px 6px; + border-radius: 3px; + display: inline-block; + margin: 5px 0; + } + } + + .notification-date { + position: absolute; + top: 50%; + right: 10px; + color: #607d8b; + font-size: 13px; + line-height: 13px; + margin-top: -6px; + } + + .notification-read-unread { + display: none; + float: left; + width: 15%; + + a { + position: absolute; + top: 50%; + margin-top: -10px; + text-align: center; + } } &.unread { - .notification-body, - .notification-subject, - .notification-read-unread { - font-family: 'din-medium', Sans-Serif; - } + background: #EEE; } } diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 05a268f4..d5ed6e00 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -10,17 +10,30 @@ class NotificationService def self.access_request(request) body = renderer.render(template: 'map_mailer/access_request_email', locals: { map: request.map, request: request }, layout: false) - request.map.user.notify(request.requested_text, body, request, false, MAILBOXER_CODE_ACCESS_REQUEST) + request.map.user.notify(request.requested_text, body, request, false, MAILBOXER_CODE_ACCESS_REQUEST, true, request.user) end def self.access_approved(request) body = renderer.render(template: 'map_mailer/access_approved_email', locals: { map: request.map }, layout: false) - receipt = request.user.notify(request.approved_text, body, request, false, MAILBOXER_CODE_ACCESS_APPROVED) + receipt = request.user.notify(request.approved_text, body, request, false, MAILBOXER_CODE_ACCESS_APPROVED, true, request.map.user) end def self.invite_to_edit(map, inviter, invited) user_map = UserMap.find_by(user: invited, map: map) body = renderer.render(template: 'map_mailer/invite_to_edit_email', locals: { map: map, inviter: inviter }, layout: false) - invited.notify(map.invited_text, body, user_map, false, MAILBOXER_CODE_INVITE_TO_EDIT) + invited.notify(map.invited_text, body, user_map, false, MAILBOXER_CODE_INVITE_TO_EDIT, true, inviter) + end + + def self.text_for_notification(notification) + if notification.notification_code == MAILBOXER_CODE_ACCESS_REQUEST + map = notification.notified_object.map + 'wants permission to map with you on ' + map.name + '  
Offer a response
' + elsif notification.notification_code == MAILBOXER_CODE_ACCESS_APPROVED + map = notification.notified_object.map + 'granted your request to edit map ' + map.name + '' + elsif notification.notification_code == MAILBOXER_CODE_INVITE_TO_EDIT + map = notification.notified_object.map + 'gave you edit access to map ' + map.name + '' + end end end diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb index ee075410..6f66eccd 100644 --- a/app/views/notifications/index.html.erb +++ b/app/views/notifications/index.html.erb @@ -4,18 +4,19 @@
    <% @notifications.each do |notification| %> <% receipt = @receipts.find_by(notification_id: notification.id) %>
  • <%= link_to notification_path(notification.id) do %> -
    - <%= notification.subject %> +
    + <%= image_tag notification.sender.image(:thirtytwo) %>
    - <%= strip_tags(notification.body).truncate(70) %> +
    <%= notification.sender.name %>
    + <%= raw NotificationService.text_for_notification(notification) %>
    <% end %>
    @@ -25,6 +26,9 @@ <%= link_to 'mark as read', mark_read_notification_path(notification.id), remote: true, method: :put %> <% end %>
    +
    + <%= notification.created_at.strftime("%b %d") %> +
  • <% end %>