From f7c70ba55caca4b7a2b54a9eb3f1bb9e4495801c Mon Sep 17 00:00:00 2001 From: raluka Date: Mon, 21 Sep 2015 15:56:57 +0200 Subject: [PATCH] updated comment layout from upstream; added grouped_by_event behaviour to comments_dropdown and helper --- app/assets/stylesheets/osem.css.scss | 46 +++++++++++-------- app/helpers/application_helper.rb | 2 +- .../admin/comments/_all_comments.html.haml | 24 ++++------ .../admin/comments/_posted_comments.html.haml | 24 ++++------ .../admin/comments/_unread_comments.html.haml | 24 ++++------ app/views/admin/comments/index.html.haml | 19 ++++---- app/views/layouts/_navigation.html.haml | 16 ++++--- 7 files changed, 78 insertions(+), 77 deletions(-) diff --git a/app/assets/stylesheets/osem.css.scss b/app/assets/stylesheets/osem.css.scss index 83a921a6..69f0fae0 100644 --- a/app/assets/stylesheets/osem.css.scss +++ b/app/assets/stylesheets/osem.css.scss @@ -1,13 +1,13 @@ html { - position: relative; - min-height: 100%; + position: relative; + min-height: 100%; } body { - /* Margin bottom by 2 times the footer height */ - margin-bottom: 60px; - /* Margin bottom by navbar height */ - padding-top: 60px; + /* Margin bottom by 2 times the footer height */ + margin-bottom: 60px; + /* Margin bottom by navbar height */ + padding-top: 60px; } #content { @@ -15,23 +15,23 @@ body { } #footer { - position: absolute; - bottom: 0; - width: 100%; - /* Set the fixed height of the footer here */ - height: 60px; - background-color: #f5f5f5; - .container { - padding: 15px; - } + position: absolute; + bottom: 0; + width: 100%; + /* Set the fixed height of the footer here */ + height: 60px; + background-color: #f5f5f5; + .container { + padding: 15px; + } } .nav-tabs { - margin-bottom: 15px; + margin-bottom: 15px; } .img-center { - margin: 0 auto; + margin: 0 auto; } /* centered columns styles */ @@ -71,4 +71,14 @@ p.comment-body { #account-already { font-size: 0.6em; -} \ No newline at end of file +} + +/* comments views pane: use padding-bottom before next comment box */ +.panel.panel-default .panel-body .box { + padding-bottom: 20px; +} + +/* comments views pane: use padding-bottom after each comment */ +.panel.panel-default .panel-body .box p { + padding-bottom: 20px; +} diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 86f4c418..4c72b3dc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -280,6 +280,6 @@ module ApplicationHelper end def unread_notifications(user) - Comment.accessible_by(current_ability).find_since_last_login(user).limit(5) + Comment.accessible_by(current_ability).find_since_last_login(user) end end diff --git a/app/views/admin/comments/_all_comments.html.haml b/app/views/admin/comments/_all_comments.html.haml index 6a5aebfd..c7a78cf8 100644 --- a/app/views/admin/comments/_all_comments.html.haml +++ b/app/views/admin/comments/_all_comments.html.haml @@ -1,16 +1,12 @@ - @comments.each do |conference, events| - .well - %p.h4= conference.title - - events.each do |event, comments| - %h3.title - = link_to event.title, admin_conference_event_path(event.conference.short_title, event) - %body - - comments.each do |comment| + .panel.panel-default + .panel-heading + %h4.title.panel-title= conference.title + .panel-body + - events.each do |event, comments| + .box + %h4.title= link_to event.title, admin_conference_event_path(event.conference.short_title, event) %hr - %ul.list-unstyled - %ul.list-inline - %li - %h5.strong Posted by: #{comment.user.name} - %li - %h5.strong Created at: #{comment.created_at} - %li= comment.body + - comments.each do |comment| + %h5.strong Posted by: #{comment.user.name} | Created at: #{comment.created_at} + %p= comment.body diff --git a/app/views/admin/comments/_posted_comments.html.haml b/app/views/admin/comments/_posted_comments.html.haml index a0459d4a..45f3fe2e 100644 --- a/app/views/admin/comments/_posted_comments.html.haml +++ b/app/views/admin/comments/_posted_comments.html.haml @@ -1,16 +1,12 @@ - @posted_comments.each do |conference, events| - .well - %p.h4= conference.title - - events.each do |event, comments| - %h3.title - = link_to event.title, admin_conference_event_path(event.conference.short_title, event) - %body - - comments.each do |comment| + .panel.panel-default + .panel-heading + %h4.title.panel-title= conference.title + .panel-body + - events.each do |event, comments| + .box + %h4.title= link_to event.title, admin_conference_event_path(event.conference.short_title, event) %hr - %ul.list-unstyled - %ul.list-inline - %li - %h5.strong Posted by: #{comment.user.name} - %li - %h5.strong Created at: #{comment.created_at} - %li= comment.body + - comments.each do |comment| + %h5.strong Created at: #{comment.created_at} + %p= comment.body diff --git a/app/views/admin/comments/_unread_comments.html.haml b/app/views/admin/comments/_unread_comments.html.haml index 24c5c9c5..60ad80dc 100644 --- a/app/views/admin/comments/_unread_comments.html.haml +++ b/app/views/admin/comments/_unread_comments.html.haml @@ -1,16 +1,12 @@ - @unread_comments.each do |conference, events| - .well - %p.h4= conference.title - - events.each do |event, comments| - %h3.title - = link_to event.title, admin_conference_event_path(event.conference.short_title, event) - %body - - comments.each do |comment| + .panel.panel-default + .panel-heading + %h4.title.panel-title= conference.title + .panel-body + - events.each do |event, comments| + .box + %h4.title= link_to event.title, admin_conference_event_path(event.conference.short_title, event) %hr - %ul.list-unstyled - %ul.list-inline - %li - %h5.strong Posted by: #{comment.user.name} - %li - %h5.strong Created at: #{comment.created_at} - %li= comment.body + - comments.each do |comment| + %h5.strong Posted by: #{comment.user.name} | Created at: #{comment.created_at} + %p= comment.body diff --git a/app/views/admin/comments/index.html.haml b/app/views/admin/comments/index.html.haml index 96d942f3..9a141c85 100644 --- a/app/views/admin/comments/index.html.haml +++ b/app/views/admin/comments/index.html.haml @@ -1,23 +1,24 @@ %h1 Comments +%br .row - .col-lg-12 + .col-md-12 %ul.nav.nav-tabs#commentsTable %li.active %a{:href=>"#unread_comments", "data-toggle"=>"tab"} %span.fa.fa-comment - Unread comments - %li - %a{:href=>"#all_comments", "data-toggle"=>"tab"} - %span.fa.fa-comments-o - Comments + Unread %li %a{:href=>"#posted_comments", "data-toggle"=>"tab"} %span.fa.fa-pencil - Posted Comments + Posted + %li + %a{:href=>"#all_comments", "data-toggle"=>"tab"} + %span.fa.fa-comments-o + All .tab-content .tab-pane.active#unread_comments = render partial: 'unread_comments' - .tab-pane#all_comments - = render partial: 'all_comments' .tab-pane#posted_comments = render partial: 'posted_comments' + .tab-pane#all_comments + = render partial: 'all_comments' diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index a9a45ecc..cf2b3b44 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -28,17 +28,19 @@ - if can? :index, Comment %ul.nav.navbar-nav.navbar-right %li.dropdown - %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#", id: "unread-comments-preview"} + %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#"} - if unread_notifications(current_user) Notifications (#{unread_notifications(current_user).length}) + %span.fa.fa-comment %b.caret %ul.dropdown-menu - - unread_notifications(current_user).limit(5).each do |unread_comment| - %li= link_to("New comment for: #{unread_comment.commentable.title}", admin_conference_event_path(unread_comment.commentable.conference.short_title, unread_comment.commentable_id)) - %li.divider - %li= link_to 'See comments', admin_comments_path - -else - No Notifications + - if unread_notifications(current_user).length > 0 + %li.dropdown-header Last 5 Comments for: + - unread_notifications(current_user).limit(5).group_by{ |comment| comment.commentable}.each do |event, comments| + %li= link_to("#{event.title}(#{comments.count})", admin_conference_event_path(event.conference.short_title, event.id)) + %li.divider + %li= link_to "See all unread Comments (#{unread_notifications(current_user).length})", admin_comments_path + %li= link_to 'See all Comments', admin_comments_path(anchor: 'all_comments') - else %ul.nav.navbar-nav.navbar-right - if CONFIG['authentication']['ichain']['enabled']