From a6e9ef2d92dbb345e774ea78fa8e9824b9a781e7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 11:33:46 +1200 Subject: [PATCH] Notifications responsiveness --- app/views/members/_follow_buttons.haml | 6 +++ app/views/members/show.html.haml | 8 +-- app/views/notifications/_form.html.haml | 44 ++++++++-------- .../notifications/_notification.html.haml | 2 +- app/views/notifications/index.html.haml | 52 ++++++++----------- app/views/notifications/reply.html.haml | 4 +- app/views/notifications/show.html.haml | 14 +++-- 7 files changed, 66 insertions(+), 64 deletions(-) create mode 100644 app/views/members/_follow_buttons.haml diff --git a/app/views/members/_follow_buttons.haml b/app/views/members/_follow_buttons.haml new file mode 100644 index 000000000..82a2b7d88 --- /dev/null +++ b/app/views/members/_follow_buttons.haml @@ -0,0 +1,6 @@ +- if current_member && current_member != member # must be logged in, can't follow yourself + - follow = current_member.get_follow(member) + - if !follow && can?(:create, Follow) # not already following + = link_to 'Follow', follows_path(followed: member), method: :post, class: 'btn btn-block' + - if follow && can?(:destroy, follow) # already following + = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-block' \ No newline at end of file diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 536b0c688..8031e151a 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -43,12 +43,8 @@ = icon('fas', 'envelope') Send message - - if current_member && current_member != @member # must be logged in, can't follow yourself - - follow = current_member.get_follow(@member) - - if !follow && can?(:create, Follow) # not already following - = link_to 'Follow', follows_path(followed: @member), method: :post, class: 'btn btn-block' - - if follow && can?(:destroy, follow) # already following - = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-block' + = render 'members/follow_buttons', member: @member + = render "stats", member: @member .card-footer = render "contact", member: @member, twitter_auth: @twitter_auth, diff --git a/app/views/notifications/_form.html.haml b/app/views/notifications/_form.html.haml index 23c844813..5f5880a93 100644 --- a/app/views/notifications/_form.html.haml +++ b/app/views/notifications/_form.html.haml @@ -1,24 +1,26 @@ -= form_for @notification do |f| - - if @notification.errors.any? - #error_explanation - %h2 - = pluralize(@post.errors.size, "error") - prohibited this message from being sent: - %ul - - @notification.errors.full_messages.each do |msg| - %li= msg += bootstrap_form_for @notification do |f| + .card + .card-body + - if @notification.errors.any? + #error_explanation + %h2 + = pluralize(@post.errors.size, "error") + prohibited this message from being sent: + %ul + - @notification.errors.full_messages.each do |msg| + %li= msg - .field - = f.hidden_field :recipient_id, value: @recipient.id + .field + = f.hidden_field :recipient_id, value: @recipient.id - %p - To: - = link_to @recipient, @recipient - = label_tag :notification, "Subject:" - = f.text_field :subject, value: @subject, class: 'form-control', maxlength: 255 - = label_tag :body, "Type your message here:" - = f.text_area :body, rows: 12, class: 'form-control' - %span.help-block - = render partial: "shared/markdown_help" + %p + To + = link_to @recipient, @recipient + = render 'members/tiny', member: @recipient + = f.text_field :subject, value: @subject, class: 'form-control', maxlength: 255 + = f.text_area :body, rows: 12, label: "Type your message here" + %span.help-block= render partial: "shared/markdown_help" + .card-footer - = f.submit "Send", class: 'btn btn-primary' + = link_to 'cancel', notifications_path, class: 'btn' + .float-right= f.submit "Send", class: 'btn btn-primary' diff --git a/app/views/notifications/_notification.html.haml b/app/views/notifications/_notification.html.haml index 898bfe736..881b93c50 100644 --- a/app/views/notifications/_notification.html.haml +++ b/app/views/notifications/_notification.html.haml @@ -1,4 +1,4 @@ -%p +%p.text-muted From = link_to notification.sender, notification.sender on diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index 8dc28b27b..39a7ccea6 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -4,35 +4,27 @@ .alert.alert-success{role: "alert"} You have no messages. - else = paginate @notifications, theme: 'twitter-bootstrap-3' - %table.table.table-striped - %thead - %tr - %th From - %th Subject - %th Date - %th + .index-cards - @notifications.each do |n| - - if can? :read, n - %tr - %td - - if n.sender.present? - - if n.read - = link_to n.sender, member_path(n.sender) - - else - %strong= link_to n.sender, member_path(n.sender) - - else - *deleted member* - %td - - if n.read - = link_to n.subject, notification_path(n) - - else - %strong= link_to n.subject, notification_path(n) - %td - - if n.read - = n.created_at - - else - %strong= n.created_at - %td - = link_to 'Delete', n, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default background-danger btn-xs' - = paginate @notifications, theme: 'twitter-bootstrap-3' + .card.message + .card-body + .row + .col-6 + %p= link_to n.subject, notification_path(n) + %p + - if n.read + = n.created_at + - else + %strong= n.created_at + .col-6 + = render 'members/tiny', member: n.sender + = n.sender + = render 'members/follow_buttons', member: n.sender + .card-footer + = link_to 'Read', n, class: 'btn btn-primary' + = link_to 'Reply', reply_link(n), class: 'btn btn-secondary' + = link_to n, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-danger btn-xs' do + = delete_icon + = t('buttons.delete') + = paginate @notifications \ No newline at end of file diff --git a/app/views/notifications/reply.html.haml b/app/views/notifications/reply.html.haml index a363fe8bc..5cd3b8478 100644 --- a/app/views/notifications/reply.html.haml +++ b/app/views/notifications/reply.html.haml @@ -1,6 +1,6 @@ = content_for :title, "Send a message to #{@recipient}" -= render @sender_notification - +.card + .card-body= render @sender_notification = render 'form' diff --git a/app/views/notifications/show.html.haml b/app/views/notifications/show.html.haml index e506f3bac..fd4241eae 100644 --- a/app/views/notifications/show.html.haml +++ b/app/views/notifications/show.html.haml @@ -1,7 +1,13 @@ = content_for :title, @notification.subject -= render @notification +.card + .card-header + .card-title= @notification.subject + .card-body + = render @notification -%p - = link_to 'Delete', @notification, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default' - = link_to 'Reply', @reply_link, class: 'btn btn-primary' + .card-footer + = link_to 'Reply', @reply_link, class: 'btn btn-primary' + = link_to @notification, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-danger' do + = delete_icon + = t('buttons.delete')