From ee778b596816a3eeb035f44aea95e94fa3d35125 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 12 Aug 2015 17:45:17 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0issue=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8F=90=E9=86=92=EF=BC=88=E5=8F=91=E9=80=81=E7=BB=99?= =?UTF-8?q?=E6=8C=87=E6=B4=BE=E7=9A=84=E4=BA=BA=EF=BC=89=202=E3=80=81?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86=E5=BD=A2=E5=BC=8F=E5=8C=BA=E5=88=86?= =?UTF-8?q?=E6=B6=88=E6=81=AF=203=E3=80=81=E7=9B=B8=E5=85=B3=E5=85=B3?= =?UTF-8?q?=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/issue.rb | 11 +++++- app/models/project.rb | 2 ++ app/models/user.rb | 23 +++++++++--- app/views/layouts/_base_header.html.erb | 5 +++ app/views/layouts/_new_header.html.erb | 39 ++++++++++++++++++++ config/locales/projects/zh.yml | 7 ++++ public/javascripts/header.js | 48 +++++++++++++++++++++++++ 7 files changed, 129 insertions(+), 6 deletions(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index 147e26cef..f6faa3eb7 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -49,6 +49,8 @@ class Issue < ActiveRecord::Base has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy # end has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + # ForgeMessage虚拟关联(多态) + has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy acts_as_nested_set :scope => 'root_id', :dependent => :destroy @@ -80,7 +82,7 @@ class Issue < ActiveRecord::Base attr_reader :current_journal # fq - after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity + after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message after_update :be_user_score after_destroy :down_user_score # after_create :be_user_score @@ -138,6 +140,13 @@ class Issue < ActiveRecord::Base :project_id => self.project_id) end # end + + # 发布缺陷foege_messages中添加记录 + def act_as_forge_message + self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, + :project_id => self.project_id, + :viewed => false) + end # Returns a SQL conditions string used to find all issues visible by the specified user diff --git a/app/models/project.rb b/app/models/project.rb index 8ab377ccc..77711edff 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -91,6 +91,8 @@ class Project < ActiveRecord::Base has_many :tags, :through => :project_tags, :class_name => 'Tag' has_many :project_tags, :class_name => 'ProjectTags' + # 关联虚拟表 + has_many :forge_messages belongs_to :organization diff --git a/app/models/user.rb b/app/models/user.rb index 12ce8719f..e62976658 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -128,6 +128,8 @@ class User < Principal has_many :messages, :foreign_key => 'author_id' has_one :user_score, :dependent => :destroy has_many :documents # 项目中关联的文档再次与人关联 +# 关联虚拟表 + has_many :forge_messages # end # 邮件邀请状态 @@ -235,6 +237,22 @@ class User < Principal # ====================================================================== + # 查询用户未读过的记录 + # 用户留言记录 + def count_new_jour + count = self.new_jours.count + # count = self.journals_for_messages(:conditions => ["status=? and is_readed = ? " ,1, 0]).count + end + + # 查询指派给我的缺陷记录 + def count_new_issue_assign_to + # count = self.forge_messages.where("viewed=? and forge_message_type=?", 0,Issue).count + + self.forge_messages(:conditions => ["viewed=? and forge_message_type=?", 0,Issue]) + #issue_assign_count = issue_assign_messages.count + end + # end + def extensions self.user_extensions ||= UserExtensions.new end @@ -292,11 +310,6 @@ class User < Principal end ## end - # 查询用户未读过的记录 - def count_new_jour - count = self.journals_for_messages.where("status=? and is_readed = ? " ,1, 0).count - end - #added by nie def count_new_journal_reply count = self.journal_reply.count diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index 49c8b5499..73ae40a28 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -37,6 +37,11 @@ {:controller=> 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user}, {:class => 'my-message'} if User.current.logged?%> +
  • + <%=link_to l(:label_issue_message)+'('+User.current.count_new_issue_assign_to.to_s+')', + {:controller=> 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user}, + {:class => 'my-message'} if User.current.logged?%> +
  • <% end -%> diff --git a/app/views/layouts/_new_header.html.erb b/app/views/layouts/_new_header.html.erb index a756009f0..e650d43ca 100644 --- a/app/views/layouts/_new_header.html.erb +++ b/app/views/layouts/_new_header.html.erb @@ -53,6 +53,45 @@ + + +
  • + <%= link_to "#{l(:label_forge_message)}".html_safe %> + +
  • + <% end -%> <%= header_render_menu :account_menu -%> diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index e47cd476c..bd3815375 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -67,6 +67,13 @@ zh: label_project_mail_upload: 上传了资源 label_invite: 邀请 + + # 项目消息通知 + label_forge_message: 消息 + label_issue_message: 问题 + label_course_message: 课程消息 + label_project_message: 项目消息 + label_issue_tracking: 问题跟踪 label_release_issue: 发布问题 diff --git a/public/javascripts/header.js b/public/javascripts/header.js index 06748d726..d33b80e3d 100644 --- a/public/javascripts/header.js +++ b/public/javascripts/header.js @@ -46,6 +46,54 @@ $(document).ready(function () { addCourseSlipMenu(); }); +//消息提醒 +function MessageAddSlipMenu () { + var loggedas = $('#current_message_li a:first'); + var sub_menu = $('#message_sub_menu'); + loggedas.mouseenter(function() { + sub_menu.show(); + $('#my_projects_message_ul').hide(); + $('#my_courses_message_ul').hide(); + }); + sub_menu.mouseleave(function() { + sub_menu.hide(); + $('#my_projects_message_ul').hide(); + $('#my_courses_message_ul').hide(); + }); +} + +function MessageAddProjectSlipMenu () { + var loggedas = $('#my_projects_message_li'); + var project_sub_menu = $('#my_projects_message_ul'); + var course_sub_menu = $('#my_courses_message_ul'); + loggedas.mouseenter(function() { + course_sub_menu.hide(); + project_sub_menu.show(); + }); + loggedas.mouseleave(function() { + project_sub_menu.hide(); + course_sub_menu.hide(); + }); +} +function MessageAddCourseSlipMenu () { + var loggedas = $('#my_courses_message_li'); + var project_sub_menu = $('#my_projects_message_ul'); + var course_sub_menu = $('#my_courses_message_ul'); + loggedas.mouseenter(function() { + project_sub_menu.hide(); + course_sub_menu.show(); + }); + loggedas.mouseleave(function() { + course_sub_menu.hide(); + project_sub_menu.hide(); + }); +} + +$(document).ready(function () { + MessageAddSlipMenu(); + MessageAddProjectSlipMenu (); + MessageAddCourseSlipMenu(); +}); //将右侧的最小高度设置成左侧高度,美化界面 $(document).ready(function () { $("#RSide").css("min-height",$("#LSide").height()-30);