diff --git a/app/views/layouts/notification.haml b/app/views/layouts/notification.haml new file mode 100644 index 00000000..30ffd22d --- /dev/null +++ b/app/views/layouts/notification.haml @@ -0,0 +1,10 @@ += render 'notifications/notification_nav' +.container.j2-page + .row + .col-md-3.col-xs-12.col-sm-4 + = render 'tabs/notifications' + .col-md-9.col-xs-12.col-sm-8 + = yield + +- Notification.for(current_user).update_all(new: false) +- provide(:title, generate_title("Notifications")) \ No newline at end of file diff --git a/app/views/notifications/_notification_tabs.html.haml b/app/views/notifications/_notification_tabs.html.haml deleted file mode 100644 index 7d4389c0..00000000 --- a/app/views/notifications/_notification_tabs.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -.col-md-3.col-xs-12.col-sm-4 - .card.hidden-xs - .list-group - = list_group_item "New Notifications", notifications_path, badge: Notification.for(current_user).where(new: true).count - = list_group_item "All Notifications", notifications_path('all') - - .card.hidden-xs - .card-header - Filter by Type - .list-group - = list_group_item t('views.notifications.tabs.answer'), notifications_path('answer'), badge: Notification.for(current_user).where(target_type: "Answer", new: true).count - = list_group_item t('views.notifications.tabs.smile'), notifications_path('smile'), badge: Notification.for(current_user).where(target_type: "Smile", new: true).count - = list_group_item t('views.notifications.tabs.comment'), notifications_path('comment'), badge: Notification.for(current_user).where(target_type: "Comment", new: true).count - = list_group_item t('views.notifications.tabs.commentsmile'), notifications_path('commentsmile'), badge: Notification.for(current_user).where(target_type: "CommentSmile", new: true).count - = list_group_item t('views.notifications.tabs.relationship'), notifications_path('relationship'), badge: Notification.for(current_user).where(target_type: "Relationship", new: true).count diff --git a/app/views/notifications/index.haml b/app/views/notifications/index.haml new file mode 100644 index 00000000..249a825c --- /dev/null +++ b/app/views/notifications/index.haml @@ -0,0 +1,22 @@ +.card + %ul#notifications.list-group + - if @notifications.count == 0 + %li.list-group-item.text-center + .notifications--none + %i.fa.fa-bell-o.no-notifications + %p + - if params[:type] != "all" + No new notifications. + - else + No notifications. + - else + - @notifications.each do |notification| + = render 'notifications/notification', notification: notification + + = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @notifications_last_id, permitted_params: %i[type] + + - if @more_data_available + %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @notifications_last_id }} + Load more + +- parent_layout "notification" \ No newline at end of file diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml deleted file mode 100644 index 054362c0..00000000 --- a/app/views/notifications/index.html.haml +++ /dev/null @@ -1,27 +0,0 @@ -- provide(:title, generate_title("Notifications")) -= render 'notifications/notification_nav' -.container.j2-page - .row - = render 'notification_tabs' - .col-md-9.col-xs-12.col-sm-8 - .card - %ul#notifications.list-group - - if @notifications.count == 0 - %li.list-group-item.text-center - .notifications--none - %i.fa.fa-bell-o.no-notifications - %p - - if params[:type] != "all" - No new notifications. - - else - No notifications. - - else - - @notifications.each do |notification| - = render 'notifications/notification', notification: notification - - = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @notifications_last_id, permitted_params: %i[type] - - - if @more_data_available - %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @notifications_last_id }} - Load more -- Notification.for(current_user).update_all(new: false) diff --git a/app/views/tabs/_notifications.haml b/app/views/tabs/_notifications.haml new file mode 100644 index 00000000..fd06ace9 --- /dev/null +++ b/app/views/tabs/_notifications.haml @@ -0,0 +1,14 @@ +.card.hidden-xs + .list-group + = list_group_item "New Notifications", notifications_path, badge: Notification.for(current_user).where(new: true).count + = list_group_item "All Notifications", notifications_path('all') + +.card.hidden-xs + .card-header + Filter by Type + .list-group + = list_group_item t('views.notifications.tabs.answer'), notifications_path('answer'), badge: Notification.for(current_user).where(target_type: "Answer", new: true).count + = list_group_item t('views.notifications.tabs.smile'), notifications_path('smile'), badge: Notification.for(current_user).where(target_type: "Smile", new: true).count + = list_group_item t('views.notifications.tabs.comment'), notifications_path('comment'), badge: Notification.for(current_user).where(target_type: "Comment", new: true).count + = list_group_item t('views.notifications.tabs.commentsmile'), notifications_path('commentsmile'), badge: Notification.for(current_user).where(target_type: "CommentSmile", new: true).count + = list_group_item t('views.notifications.tabs.relationship'), notifications_path('relationship'), badge: Notification.for(current_user).where(target_type: "Relationship", new: true).count \ No newline at end of file