Skip to content

Commit

Permalink
board nav
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Dec 10, 2023
1 parent e22b791 commit 7dd4ec4
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/work-design/rails_auth.git
revision: 10051332d5d804616ef04995a9ac422806f44957
revision: 5fa9fe86c83a4f8cc734a2a87fa4731c233052b3
specs:
rails_auth (1.2.0)
bcrypt (~> 3.1)
Expand All @@ -9,7 +9,7 @@ GIT

GIT
remote: https://github.com/work-design/rails_com.git
revision: b719f7e862907c1717ab3643fe20706f86cd652d
revision: b72419c23e5244276c5837303b432f2172122be8
specs:
rails_com (1.3.0)
acme-client
Expand All @@ -27,14 +27,14 @@ GIT

GIT
remote: https://github.com/work-design/rails_design.git
revision: d564b9906a7d1942300ebf91e1329643c46c72a4
revision: 441cd8c2fe5ae91a63b43ffdafc4ded37da7ca6b
specs:
rails_design (0.0.1)
rails

GIT
remote: https://github.com/work-design/rails_extend.git
revision: e2c0b14dc046c5173c7e4f2c63abafa116bb5614
revision: d7f6c61e28fbc3a9a8b9e536e5c5bc0e6b58c791
specs:
rails_extend (1.0.1)
rails (>= 5.0)
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/notice/board/base_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Notice
class Board::BaseController < BoardController
end
end
5 changes: 5 additions & 0 deletions app/controllers/notice/board/notifications_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Notice
class Board::NotificationsController < My::NotificationsController
include Controller::Board
end
end
10 changes: 10 additions & 0 deletions app/controllers/notice/controller/board.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Notice
module Controller::Board
extend ActiveSupport::Concern

included do
layout 'board'
end

end
end
4 changes: 2 additions & 2 deletions app/models/notice/ext/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Ext::User

included do
has_many :notifications, class_name: 'Notice::Notification', dependent: :delete_all
has_many :announcements, class_name: 'Notice::UserAnnouncement', through: :user_taggeds
has_many :announcement_user_tags, class_name: 'Notice::AnnouncementUserTag', through: :user_taggeds
end

def apply_pending_annunciations
Expand Down Expand Up @@ -36,7 +36,7 @@ def apply_pending_annunciations
end

def pending_annunciation_ids
all_annunciation_ids = user_annunciates.default_where('created_at-gte': self.created_at).order(annunciation_id: :desc).pluck(:annunciation_id).compact
all_annunciation_ids = announcement_user_tags.default_where('created_at-gte': self.created_at).order(announcement_id: :desc).pluck(:announcement_id).compact
made_annunciation_ids = notifications.where(notifiable_type: 'Notice::UserAnnunciation').pluck(:notifiable_id)

all_annunciation_ids - made_annunciation_ids
Expand Down
6 changes: 6 additions & 0 deletions app/views/board/_notice_navbar.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% if defined?(current_user) && current_user %>
<%= link_to({ controller: 'notice/board/notifications' }, id: 'notice_show', class: 'navbar-item') do %>
<i class="fa-regular fa-bell"></i>
<span class="pl-1" id="notice_count"><%= current_user.unread_count %></span>
<% end %>
<% end %>
2 changes: 0 additions & 2 deletions app/views/notice/my/notifications/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<%= render 'tabs' %>

<div class="box">
<%= render partial: 'notification', collection: @notifications, as: :notification %>
</div>
Expand Down
6 changes: 6 additions & 0 deletions app/views/panel/_notice_navbar.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% if defined?(current_user) && current_user %>
<%= link_to({ controller: 'notice/board/notifications' }, id: 'notice_show', class: 'navbar-item') do %>
<i class="fa-regular fa-bell"></i>
<span class="pl-1" id="notice_count"><%= current_user.unread_count %></span>
<% end %>
<% end %>
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
namespace :my, defaults: { namespace: 'my' } do
concerns :notice
end

namespace :board, defaults: { namespace: 'board' } do
concerns :notice
end
end
end
end

0 comments on commit 7dd4ec4

Please sign in to comment.