From 38acb4230e45062cb53973f4872dfc380d113daf Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Sat, 14 Nov 2015 14:31:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=8A=A8=E6=80=81=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 45 +++++- app/helpers/organizations_helper.rb | 2 + .../_org_project_activities.html.erb | 30 ++++ .../organizations/_org_project_issue.html.erb | 136 ++++++++++++++++++ app/views/organizations/show.html.erb | 20 ++- app/views/organizations/show.js.erb | 7 + 6 files changed, 231 insertions(+), 9 deletions(-) create mode 100644 app/views/organizations/_org_project_activities.html.erb create mode 100644 app/views/organizations/_org_project_issue.html.erb create mode 100644 app/views/organizations/show.js.erb diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index fdd12030f..daf443d07 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -1,5 +1,33 @@ # encoding: utf-8 class OrganizationsController < ApplicationController + + + helper :sort + include SortHelper + helper :custom_fields + include CustomFieldsHelper + include AvatarHelper + include WordsHelper + include GitlabHelper + include UserScoreHelper + + include PollHelper + helper :user_score + helper :journals + + # added by liuping 关注 + + helper :watchers + helper :activities + + ### added by william + include ActsAsTaggableOn::TagsHelper + + # fq + helper :words + helper :project_score + helper :issues + include UsersHelper before_filter :find_organization, :only => [:show, :members] layout 'base_org' def index @@ -27,13 +55,22 @@ class OrganizationsController < ApplicationController def show if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @organization = Organization.find(params[:id]) - @activities = OrgActivity.where('container_id =? and container_type =? ', - @organization.id, 'Organization ').order('updated_at desc') - - @activities = paginateHelper @activities, 10 + @org_activities = OrgActivity.where('container_id =? and container_type =? ', + @organization.id, 'Organization ').order('updated_at desc').page(params[:page]).per(10) + @org_activities_count = OrgActivity.where('container_id =? and container_type =? ', + @organization.id, 'Organization ').order('updated_at desc').count + project_ids = @organization.projects.map(&:id) + @org_project_activties = ForgeActivity.where('project_id in (?)',project_ids.join(',')).page(params[:page]).per(10) + @org_project_activties_count = ForgeActivity.where('project_id in (?)',project_ids.join(',')).count + #@org_activities = paginateHelper @org_activities, 10 + @page = params[:page] else render_403 end + respond_to do |format| + format.html + format.js + end end def update diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 55a7a5d42..607d2af5c 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -17,4 +17,6 @@ module OrganizationsHelper s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" ) end + + end diff --git a/app/views/organizations/_org_project_activities.html.erb b/app/views/organizations/_org_project_activities.html.erb new file mode 100644 index 000000000..0a6a8fae4 --- /dev/null +++ b/app/views/organizations/_org_project_activities.html.erb @@ -0,0 +1,30 @@ +<% org_project_activties.each do |act|%> +<% if act %> + + <% unless act.forge_act_type == "ProjectCreateInfo" %> + <% if act %> + <% case act.forge_act_type.to_s %> + <% when 'Issue' %> + <%= render :partial => 'organizations/org_project_issue', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> + <% when 'Message' %> + <%= render :partial => 'users/project_message', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> + <% when 'ProjectCreateInfo'%> + <%= render :partial => 'users/project_create', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> + <% end %> + <% end %><% end %> +<% end %> +<% end %> +<% if org_act_count == 10 || pro_act_count == 10 %> +
展开更多<%=link_to "", organization_path(org,:page => page.to_i + 1),:id => "more_org_activities_link",:remote => "true",:class => "none" %>
+ <%#= link_to "点击展开更多",user_activities_path(@user.id,:type => type,:page => page),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> +<% end%> + + + diff --git a/app/views/organizations/_org_project_issue.html.erb b/app/views/organizations/_org_project_issue.html.erb new file mode 100644 index 000000000..ed80ba7b1 --- /dev/null +++ b/app/views/organizations/_org_project_issue.html.erb @@ -0,0 +1,136 @@ +
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> +
+
+
+ <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% end %> TO + <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%> +
+
+ <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %> + + <%#= get_issue_priority(activity.priority_id)[1] %> + +
+
+
指派给   + <% unless activity.assigned_to_id.nil? %> + <% if activity.try(:assigned_to).try(:realname) == ' ' %> + <%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> + <% end %> + <% end %> +
+
+ 时间: + <%=format_time(activity.created_on) %> +
+
+
+
+ <% if activity.description? %> + <%= textAreailizable activity, :description, :attachments => activity.attachments %> + <% end %> +
+
+
+ + +
+
+ <% if activity.attachments.any? %> + <% activity.attachments.each do |attachment| %> +
+ + + <%= link_to_short_attachment attachment,:length=> 58, :class => 'link_file_a fl newsBlue', :download => true -%> + + <% if attachment.is_text? %> + <%= link_to image_tag('magnifier.png'), + :controller => 'attachments', + :action => 'show', + :id => attachment, + :class => 'fl', + :filename => attachment.filename %> + <% end %> + + ( + <%= number_to_human_size attachment.filesize %>) + + + <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author),:class => "c_orange" %>, + <%= format_time(attachment.created_on) %> + +
+ <% end %> + <% end %> +
+
+
+
+ <% count = activity.journals.count %> +
+
+
+
回复(<%= count %>)
+
<%#= format_date(activity.updated_on) %>
+ <% if count > 3 %> + + <% end %> +
+ + <% replies_all_i = 0 %> + <% if count > 0 %> +
+
    + <% activity.journals.reorder("created_on desc").each do |reply| %> + + <% replies_all_i=replies_all_i + 1 %> +
  • +
    + <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_path(reply.user_id), :alt => "用户头像" %> +
    +
    +
    + <% if reply.try(:user).try(:realname) == ' ' %> + <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> +
    +
    + <% if reply.details.any? %> + <% details_to_strings(reply.details).each do |string| %> +

    <%= string %>

    + <% end %> + <% end %> +

    <%= reply.notes %>

    +
    +
    +
    +
  • + <% end %> +
+
+ <% end %> + + + +
+
diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index deaec4437..0b624d479 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -34,8 +34,8 @@ <%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id} %> <% end %> - <% unless @activities.nil? %> - <% @activities.each do |act| %> + <% unless @org_activities.nil? %> + <% @org_activities.each do |act| %> <% if act.org_act_type == 'CreateOrganization' %>
@@ -60,10 +60,20 @@ <%= render :partial => 'show_org_document', :locals => {:document => act.org_act} %> <% end %> <% end %> -
    - <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> -
+ + <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> + <% end %> + <%# @org_project_activties.each do |org_act|%> + <%= render :partial => 'organizations/org_project_activities', + :locals => {:org_project_activties =>@org_project_activties, + :page=>@page, + :org => @organization, + :org_act_count=>@org_activities.count, + :pro_act_count=>@org_project_activties.count}%> + <%# end %> + + diff --git a/app/views/organizations/show.js.erb b/app/views/organizations/show.js.erb new file mode 100644 index 000000000..b0a447910 --- /dev/null +++ b/app/views/organizations/show.js.erb @@ -0,0 +1,7 @@ +$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'organizations/org_project_activities', + :locals => {:org_project_activties =>@org_project_activties, + :page=>@page, + :org => @organization, + :org_act_count=>@org_activities.count, + :pro_act_count=>@org_project_activties.count} )%>"); +