1、增加issue消息提醒(发送给指派的人)

2、下拉框形式区分消息
3、相关关联
This commit is contained in:
huang 2015-08-12 17:45:17 +08:00
parent 998fe24e49
commit ee778b5968
7 changed files with 129 additions and 6 deletions

View File

@ -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
@ -139,6 +141,13 @@ class Issue < ActiveRecord::Base
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
def self.visible_condition(user, options={})

View File

@ -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

View File

@ -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

View File

@ -37,6 +37,11 @@
{:controller=> 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user},
{:class => 'my-message'} if User.current.logged?%>
</li>
<li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;">
<%=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?%>
</li>
</ul>
</div>
<% end -%>

View File

@ -53,6 +53,45 @@
</li>
</ul>
</li>
<!--消息提醒-->
<li id="current_message_li">
<%= link_to "#{l(:label_forge_message)}<span class='pic_triangle'></span>".html_safe %>
<ul id="message_sub_menu" style="right: 0px;display: none;left: 10px;">
<% if @show_course == 1 %>
<% user_course = get_user_course User.current%>
<% unless user_course.empty? %>
<li id="my_courses_message_li">
<%=link_to l(:label_course_message), {:controller => 'users', :action => 'user_courses', id: User.current.id},target:"_blank", :class => "parent" %>
<ul id="my_courses_message_ul">
<% user_course.reverse.each do |course| %>
<li title="<%=course.name%>">
<%= link_to course.name, {:controller => 'courses',:action => 'show',:id => course.id},target:"_blank" %>
</li>
<% end %>
</ul>
</li>
<% end %>
<% end %>
<% unless User.current.projects.empty? %>
<li id="my_projects_message_li">
<%= "#{l(:label_project_message)}"+"("+User.current.count_new_issue_assign_to.count.to_s+")" %>
<ul id="my_projects_message_ul" >
<% User.current.count_new_issue_assign_to.reverse.each do |issue_assign| %>
<li title="<%=issue_assign.forge_message %>">
<%= link_to issue_assign.forge_message, {:controller => 'issues', :action => 'show',id: issue_assign.forge_message_id, host: Setting.host_name }, target:"_blank" %>
</li>
<% end %>
</ul>
</li>
<% end %>
<li>
<%=link_to "...", {:controller => 'my', :action=> 'account', host: Setting.host_user}%>
</li>
</ul>
</li>
<% end -%>
<%= header_render_menu :account_menu -%>
</ul>

View File

@ -68,6 +68,13 @@ zh:
label_invite: 邀请
# 项目消息通知
label_forge_message: 消息
label_issue_message: 问题
label_course_message: 课程消息
label_project_message: 项目消息
label_issue_tracking: 问题跟踪
label_release_issue: 发布问题

View File

@ -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);