From 9ba0d50f26589c4233e009c1eb6ecf33992eb2e6 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 26 Apr 2016 10:16:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=89=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/organizations_helper.rb | 221 ++++++++------- app/views/organizations/_org_content.html.erb | 259 ++++++++++++++++++ .../organizations/_subfield_list.html.erb | 4 +- 3 files changed, 382 insertions(+), 102 deletions(-) create mode 100644 app/views/organizations/_org_content.html.erb diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 03a61a65f..e42bae220 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -1,100 +1,121 @@ -# encoding: utf-8 -module OrganizationsHelper - include ApplicationHelper - include FilesHelper - - - def find_user_not_in_current_org_by_name org - if params[:q] && params[:q].lstrip.rstrip != "" - scope = Principal.active.sorted.not_member_of_org(org).like(params[:q]) - else - scope = [] - end - principals = paginateHelper scope,10 - s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals') - links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options| - link_to text, org_member_autocomplete_org_member_index_path( parameters.merge(:q => params[:q],:flag => true,:org=>org, :format => 'js')), :remote => true - } - s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" ) - end - - def get_default_name field - case field.name - when 'activity' then - return '动态' - when 'course' then - return '课程' - when 'project' then - return '项目' - end - end - - def get_message_org(org_id, field_id) - OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and org_subfield_id = #{field_id} and parent_id is null order by updated_at desc limit 8;") - end - - def get_message_reply_org(org_id, ids) - # OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id is not null order by updated_at desc limit 1;") - OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id in (#{ids}) order by updated_at desc limit 1;") - end - - def get_attach_org(field_id) - Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;") - end - - def get_attach_org2(field) - org_attachments = field.attachments - attachments = User.current.admin? ? org_attachments : visable_attachemnts(org_attachments) - return attachments.sort_by{|x| x.created_on}.reverse.first(6) - # Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;") - end - - # 从内容中获取路径 - def get_image_path_from_content content - r = Regexp.new(/src="\/files\/uploads\/image(.+?)"/) - if r.match(content).nil? - image_path = nil - else - image_path = r.match(content)[1] - end - end - - #排列下拉框 - def subfield_status_option - type = [] - option1 = [] - option1 << "左上" - option1 << "1" - type << option1 - option2 = [] - option2 << "左中一" - option2 << "2" - type << option2 - option3 = [] - option3 << "左中二" - option3 << "3" - type << option3 - option4 = [] - option4 << "左中下" - option4 << "4" - type << option4 - option5 = [] - option5 << "左下" - option5 << "5" - type << option5 - option6 = [] - option6 << "右上" - option6 << "6" - type << option6 - option7 = [] - option7 << "右中" - option7 << "7" - type << option7 - option8 = [] - option8 << "右下" - option8 << "8" - type << option8 - type - end - -end +# encoding: utf-8 +module OrganizationsHelper + include ApplicationHelper + include FilesHelper + + + def find_user_not_in_current_org_by_name org + if params[:q] && params[:q].lstrip.rstrip != "" + scope = Principal.active.sorted.not_member_of_org(org).like(params[:q]) + else + scope = [] + end + principals = paginateHelper scope,10 + s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals') + links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options| + link_to text, org_member_autocomplete_org_member_index_path( parameters.merge(:q => params[:q],:flag => true,:org=>org, :format => 'js')), :remote => true + } + s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" ) + end + + def get_default_name field + case field.name + when 'activity' then + return '动态' + when 'course' then + return '课程' + when 'project' then + return '项目' + end + end + + def get_message_org(org_id, field_id) + OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and org_subfield_id = #{field_id} and parent_id is null order by updated_at desc limit 8;") + end + + def get_message_reply_org(org_id, ids) + # OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id is not null order by updated_at desc limit 1;") + OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id in (#{ids}) order by updated_at desc limit 1;") + end + + def get_attach_org(field_id) + Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;") + end + + def get_attach_org2(field) + org_attachments = field.attachments + attachments = User.current.admin? ? org_attachments : visable_attachemnts(org_attachments) + return attachments.sort_by{|x| x.created_on}.reverse.first(6) + # Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;") + end + + # 从内容中获取路径 + def get_image_path_from_content content + r = Regexp.new(/src="\/files\/uploads\/image(.+?)"/) + if r.match(content).nil? + image_path = nil + else + image_path = r.match(content)[1] + end + end + + #排列下拉框 + def subfield_status_option + type = [] + option1 = [] + option1 << "左上" + option1 << "1" + type << option1 + option2 = [] + option2 << "中一" + option2 << "2" + type << option2 + option3 = [] + option3 << "中二" + option3 << "3" + type << option3 + option4 = [] + option4 << "中下" + option4 << "4" + type << option4 + option5 = [] + option5 << "左下" + option5 << "5" + type << option5 + option6 = [] + option6 << "右上" + option6 << "6" + type << option6 + option7 = [] + option7 << "右中" + option7 << "7" + type << option7 + option8 = [] + option8 << "右下" + option8 << "8" + type << option8 + type + end + + def subfield_list_type subfield + case subfield.to_i + when 1 + resulet = "左上" + when 2 + resulet = "中一" + when 3 + resulet = "中二" + when 4 + resulet = "中下" + when 5 + resulet = "左下" + when 6 + resulet = "右上" + when 7 + resulet = "右中" + when 8 + resulet = "右下" + end + end + +end diff --git a/app/views/organizations/_org_content.html.erb b/app/views/organizations/_org_content.html.erb new file mode 100644 index 000000000..c7d53356c --- /dev/null +++ b/app/views/organizations/_org_content.html.erb @@ -0,0 +1,259 @@ + +<% if is_default_field?(field) %> + <% case field.name %> + <% when 'course' %> + <% if field.status.to_i == 1 %> + + <% elsif field.status.to_i == 2 %> + + <% elsif field.status.to_i == 3 %> + + <% elsif field.status.to_i == 4 %> + + <% elsif field.status.to_i == 5 %> + + <% elsif field.status.to_i == 6 %> + + <% end %> +
+ <% if field.status == 0 %> +
+

课程动态

+ <% if @course_acts.blank? %> + +
+ <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% else %> +
+
    + <% unless @course_acts.nil? %> + <%= render :partial => 'organizations/org_new_course_pic', :locals => {:activities => @course_acts.first(3)} %> + <% end %> +
    + <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
    +
+
+ <% end %> +
+ <% else %> +
+

课程动态

+ <% if @course_acts.blank? %> + +
+ <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% else %> +
+ <%= render :partial => 'organizations/org_new_course_act_list', :locals =>{:activities => @course_acts, :field => field, :organization => @organization} %> + +
+
+ <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% end %> + + +
+ <% end %> +
+ <% when 'project' %> +
+ <% if field.status == 0 %> +
+

项目动态

+ <% if @project_acts.blank? %> + +
+ <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% else %> +
+
    + <% unless @project_acts.nil? %> + <%= render :partial => 'organizations/org_new_project_pic', :locals => {:activities => @project_acts.first(3)} %> + <% end %> +
    + <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
    +
+
+ <% end %> + +
+ <% else %> +
+

项目动态

+ <% if @project_acts.blank? %> + +
+ <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% else %> +
+ <%= render :partial => 'organizations/org_new_project_act_list', :locals =>{:activities => @project_acts, :field => field, :organization => @organization} %> + +
+
+ <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% end %> + +
+ <% end %> +
+ <% end %> +<% else %> + <% if field.field_type == "Post" %> <%# 讨论类型 %> + <% org_subfield = OrgSubfield.find(field.id) %> + <% org_subfield_ids = org_subfield.org_document_comments.map(&:id) << 0 %> + <% org_acts = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{org_subfield.id})").order('updated_at desc') %> + <%# message_ats = get_message_org(@organization.id, field.id) %> + <%# ids = field.org_document_comments.map{|o| o.id}.join(",") %> +
+ <% if field.status == 0 %> +
+

<%= field.name %>

+ <% if org_acts.blank? %> + +
+ <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + + <%#= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% else %> +
+
    + + <% org_acts.first(3).each do |act| %> + <%= render :partial => 'organizations/org_new_forum_pic', :locals => {:activity => act, :field => field, :organization => @organization} %> + <% end %> +
    +
+ <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + <%#= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> +
+
+ <% end %> + +
+ <% else %> +
+

<%= field.name %>

+ <% if org_acts.blank? %> + +
+ <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> +
+ <% else %> +
+ <% org_acts.each do |act| %> + <%= render :partial => 'organizations/org_new_forum_list', :locals => {:activity => act, :field => field, :organization => @organization} %> + <% end %> + +
+
+ <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> +
+ <% end %> + +
+
+ <% end %> +
+ <% elsif field.field_type == "Resource" %> + <% org_attachs = get_attach_org2(field) %> +
+
+

<%= field.name %>

+ <% if org_attachs.blank? %> + +
+ <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30", :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30", :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", org_subfield_files_path(field), :class => "more-btn-center mt30", :target => "_blank" %> + <% end %> + <%#= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% else %> +
+ <%= render :partial => 'organizations/org_new_resource', :locals => {:org_attachs => org_attachs} %> + +
+ +
+ <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30", :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30", :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", org_subfield_files_path(field), :class => "more-btn-center mt30", :target => "_blank" %> + <% end %> + <%#= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% end %> + +
+
+
+ + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index 2c679eb3d..7db41cba5 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -27,7 +27,7 @@ 默认 <% else %> <%= form_tag({:controller => 'org_subfields', :action => 'update_status', :id => field.id,},:remote=>'true', :method => 'post', :id=>"update_status_form_#{field.id}", :class => 'query_form') do %> -
+
<%= select( :name,:group_id, subfield_status_option, @@ -63,7 +63,7 @@ 列表 <% else %> <%= form_tag({:controller => 'org_subfields', :action => 'update_status', :id => field.id,},:remote=>'true', :method => 'post', :id=>"update_status_form_#{field.id}", :class => 'query_form') do %> -
+
<%= select( :name,:group_id, subfield_status_option,