mirror of
https://github.com/zhigang1992/tsemple.git
synced 2026-01-12 17:52:57 +08:00
Notifcation index page
This commit is contained in:
@@ -12,6 +12,7 @@ $nav-link-hover-bg: transparent;
|
||||
@import "topics";
|
||||
@import "posts";
|
||||
@import "post_votes";
|
||||
@import "notifications";
|
||||
|
||||
body {
|
||||
background: #eee;
|
||||
|
||||
@@ -7,11 +7,14 @@
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #555;
|
||||
li {
|
||||
a {
|
||||
color: #555;
|
||||
|
||||
&:hover {
|
||||
color: #333;
|
||||
&:hover {
|
||||
color: #333;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
app/assets/stylesheets/notifications.css.scss
Normal file
25
app/assets/stylesheets/notifications.css.scss
Normal file
@@ -0,0 +1,25 @@
|
||||
.notifications {
|
||||
position: relative;
|
||||
|
||||
.badge {
|
||||
background: $brand-primary;
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.list-group-notification {
|
||||
margin: 0 -16px;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.list-group-item-notification {
|
||||
padding: 16px;
|
||||
border-bottom: 1px solid #eee;
|
||||
|
||||
&:first-child {
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
}
|
||||
7
app/controllers/notifications_controller.rb
Normal file
7
app/controllers/notifications_controller.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class NotificationsController < ApplicationController
|
||||
before_filter :require_logined
|
||||
|
||||
def index
|
||||
@notifications = current_user.notifications.page(params[:page])
|
||||
end
|
||||
end
|
||||
2
app/helpers/notifications_helper.rb
Normal file
2
app/helpers/notifications_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module NotificationsHelper
|
||||
end
|
||||
@@ -27,6 +27,10 @@ html
|
||||
#navbar.collapse.navbar-collapse
|
||||
ul.nav.navbar-nav.navbar-right
|
||||
- if logined?
|
||||
li
|
||||
a.notifications href=notifications_path
|
||||
i.fa.fa-bell-o
|
||||
.badge 1
|
||||
li.dropdown
|
||||
a.dropdown-toggle data-toggle="dropdown" href='#'
|
||||
= current_user.name
|
||||
|
||||
15
app/views/notifications/index.html.slim
Normal file
15
app/views/notifications/index.html.slim
Normal file
@@ -0,0 +1,15 @@
|
||||
.row
|
||||
.col-md-9
|
||||
.panel.panel-campo
|
||||
.panel-heading.clearfix
|
||||
.pull-right
|
||||
= paginate @notifications, theme: 'campo', left: 1, right: 1, window: 2
|
||||
h3.panel-title Notifications
|
||||
.panel-body
|
||||
ul.list-group-notification
|
||||
- @notifications.each do |notification|
|
||||
- begin
|
||||
= render "notification/#{notification.name}"
|
||||
- rescue
|
||||
.list-group-item-notification
|
||||
= "##{notification.id} Missing template for #{notification.name} notification."
|
||||
@@ -26,6 +26,8 @@ Rails.application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
resources :notifications, only: [:index]
|
||||
|
||||
if Rails.env.development?
|
||||
get 'qunit', to: 'qunit#index'
|
||||
end
|
||||
|
||||
10
test/controllers/notifications_controller_test.rb
Normal file
10
test/controllers/notifications_controller_test.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NotificationsControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
assert_require_logined do
|
||||
get :index
|
||||
end
|
||||
assert_response :success, @response.body
|
||||
end
|
||||
end
|
||||
@@ -3,7 +3,6 @@
|
||||
FactoryGirl.define do
|
||||
factory :notification do
|
||||
user
|
||||
subject
|
||||
name "name_type"
|
||||
end
|
||||
end
|
||||
|
||||
4
test/helpers/notifications_helper_test.rb
Normal file
4
test/helpers/notifications_helper_test.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NotificationsHelperTest < ActionView::TestCase
|
||||
end
|
||||
Reference in New Issue
Block a user