1.增加隐藏组织栏目功能;2.未登录情况,隐藏部分内容。

This commit is contained in:
ouyangxuhua 2015-12-31 13:26:28 +08:00
parent 2271befedd
commit 806e4caf5a
14 changed files with 153 additions and 89 deletions

View File

@ -281,4 +281,14 @@ class OrganizationsController < ApplicationController
format.js format.js
end end
end end
def hide_org_subfield
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield.update_attribute(:hide, 1)
end
def show_org_subfield
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield.update_attribute(:hide, 0)
end
end end

View File

@ -17,6 +17,15 @@ module OrganizationsHelper
s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" ) s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" )
end end
def get_default_name field
case field.name
when 'activity' then
return '动态'
when 'course' then
return '课程'
when 'project' then
return '项目'
end
end
end end

View File

@ -120,19 +120,21 @@
<!--</div>--> <!--</div>-->
<div class="cl"></div> <div class="cl"></div>
<div class="f12 fontGrey3"> <% if User.current.logged? %>
<%= link_to '文章', organization_org_document_comments_path(@organization) %>&nbsp; <div class="f12 fontGrey3">
<% if User.current.logged? %> <%= link_to '文章', organization_org_document_comments_path(@organization) %>&nbsp;
( <% if User.current.logged? %>
<%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %> (
) <%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %>
<% end %> )
&nbsp;|&nbsp; <% end %>
<%= link_to '成员', members_organization_path(@organization.id) %>&nbsp; &nbsp;|&nbsp;
<% if User.current.logged? %> <%= link_to '成员', members_organization_path(@organization.id) %>&nbsp;
<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %> <% if User.current.logged? %>
<% end %> <%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>
</div> <% end %>
</div>
<% end %>
</div> </div>
<div class="homepageLeftMenuContainer" id="sub_field_left_lists"> <div class="homepageLeftMenuContainer" id="sub_field_left_lists">
<%= render :partial => "organizations/org_left_subfield_list", :locals => {:organization => @organization} %> <%= render :partial => "organizations/org_left_subfield_list", :locals => {:organization => @organization} %>

View File

@ -1,31 +1,38 @@
<div class="homepageLeftMenuBlock"> <% org_activity_field = organization.org_subfields.where('field_type="default" and name="activity" and field_type="default"').first %>
<% org_course_field = organization.org_subfields.where('field_type="default" and name="course" and field_type="default"').first %>
<% org_project_field = organization.org_subfields.where('field_type="default" and name="project" and field_type="default"').first %>
<div class="homepageLeftMenuBlock" style="display:<%= org_activity_field.hide == 0?'block':'none' %>;" id="org_subfield_<%= org_activity_field.id %>">
<%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %> <%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %>
</div> </div>
<div class="homepageLeftMenuBlock"> <div style="display:<%= org_project_field.hide == 0?'block':'none' %>;" id="org_subfield_<%= org_project_field.id %>">
<a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuProjects').slideToggle();">项目</a>
<% if User.current.logged? and User.current.admin_of_org?(organization) %>
<%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%>
<% end %>
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuProjects" style="display:<%= organization.projects.count == 0?'none':'' %>">
<ul >
<%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
</ul>
</div>
<div class="homepageLeftMenuBlock">
<a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuCourses').slideToggle();">课程</a>
<% if User.current.logged? and User.current.admin_of_org?(organization) %>
<%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%>
<% end %>
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuCourses" style="display:<%= organization.courses.count == 0 ?'none':'' %>">
<ul >
<%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
</ul>
</div>
<% organization.org_subfields.each do |field| %>
<div class="homepageLeftMenuBlock"> <div class="homepageLeftMenuBlock">
<a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuProjects').slideToggle();">项目</a>
<% if User.current.logged? and User.current.admin_of_org?(organization) %>
<%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%>
<% end %>
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuProjects" style="display:<%= organization.projects.count == 0?'none':'' %>">
<ul >
<%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
</ul>
</div>
</div>
<div style="display:<%= org_course_field.hide == 0?'block':'none' %>;" id="org_subfield_<%= org_course_field.id %>">
<div class="homepageLeftMenuBlock">
<a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuCourses').slideToggle();">课程</a>
<% if User.current.logged? and User.current.admin_of_org?(organization) %>
<%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%>
<% end %>
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuCourses" style="display:<%= organization.courses.count == 0 ?'none':'' %>">
<ul >
<%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
</ul>
</div>
</div>
<% organization.org_subfields.where("field_type != 'default'").each do |field| %>
<div class="homepageLeftMenuBlock" style="display:<%= field.hide == 0?'block':'none' %>;" id="org_subfield_<%= field.id %>">
<% if field.field_type == "Post" %> <% if field.field_type == "Post" %>
<%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %> <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %>
<%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%> <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%>

View File

@ -1,16 +1,16 @@
<div class="resources mt10" id="organization_document_<%= document.id %>"> <div class="resources <%= User.current.logged? ? 'mt10' :'' %>" id="organization_document_<%= document.id %>">
<div class="homepagePostBrief"> <div class="homepagePostBrief">
<div class="homepagePostDes" style="width:690px;"> <div class="homepagePostDes" style="width:690px;">
<% if User.current.logged? %>
<div class="homepagePostTitle postGrey"><%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %></div> <div class="homepagePostTitle postGrey"><%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %></div>
<% end %>
<% unless document.content.blank? %> <% unless document.content.blank? %>
<div class="homepagePostIntro" > <div class="homepagePostIntro" >
<%= document.content.html_safe %> <%= document.content.html_safe %>
</div> </div>
<% end %> <% end %>
<% if params[:show_homepage].nil? %> <% if params[:show_homepage].nil? and User.current.logged? %>
<div class="homepagePostDate" style="float:right;"> <div class="homepagePostDate" style="float:right;">
发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %> 发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %>
</div> </div>

View File

@ -1,47 +1,47 @@
<ul class="orgListRow">
<li class="orgListUser fb">已有栏目</li>
<li class="orgListStatus fb">状态</li>
<li class="orgListStatus fb">类型</li>
<div class="cl"></div>
</ul>
<ul class="orgListRow"> <% default_fields.each do |field| %>
<li class="orgListUser fb">已有栏目</li> <% name = get_default_name(field) %>
<li class="orgListUser fb">状态</li>
<li class="orgListStatus fb">类型</li>
<div class="cl"></div>
</ul>
<ul class="orgListRow">
<li class="orgListUser">动态</li>
<li class="orgListUser">默认</li>
<li class="orgListStatus">默认</li>
<div class="cl"></div>
</ul>
<ul class="orgListRow">
<li class="orgListUser">项目</li>
<li class="orgListUser">默认</li>
<li class="orgListStatus">默认</li>
<div class="cl"></div>
</ul>
<ul class="orgListRow">
<li class="orgListUser">课程</li>
<li class="orgListUser">默认</li>
<li class="orgListStatus">默认</li>
<div class="cl"></div>
</ul>
<% subfields.each do |field| %>
<ul class="orgListRow"> <ul class="orgListRow">
<li class="orgListUser"><div id="subfield_show_<%= field.id %>"><%= field.name %></div><div id="subfield_edit_<%= field.id %>" style="display:none;"> <li class="orgListUser"><%= name %></li>
<input type="text" name="name" onblur="update_subfield('#subfield_show_<%= field.id %>','#subfield_edit_<%= field.id %>','<%= field.id %>',$(this).val());" value="<%= field.name %>" style="width:70px;" /></div></li> <li class="orgListStatus">默认</li>
<li class="orgListUser">新增</li> <li class="orgListStatus">默认</li>
<li class="orgListStatus"><%= field.field_type == "Post" ? "帖子":"资源" %></li> <a href="javascript:void(0);" class="linkBlue fr mr10" onclick="hide($(this),'<%= field.id %>');" id="hide_<%= field.id %>"><%= field.hide==0?"设为隐藏":"设为显示" %></a>
<%= link_to "删除",org_subfield_path(field), :method => 'delete',:remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr5" %> <div class="cl"></div>
<a href="javascript:void(0);" class="linkBlue fr mr10" onclick="edit('#subfield_show_<%= field.id %>','#subfield_edit_<%= field.id %>');">编辑</a>
<div class="cl"></div>
</ul> </ul>
<% end %> <% end %>
<script> <% subfields.each do |field| %>
function edit(show_id, edit_id){ <ul class="orgListRow">
<li class="orgListUser">
<div id="subfield_show_<%= field.id %>"><%= field.name %></div>
<div id="subfield_edit_<%= field.id %>" style="display:none;">
<input type="text" name="name" onblur="update_subfield('#subfield_show_<%= field.id %>','#subfield_edit_<%= field.id %>','<%= field.id %>',$(this).val());" value="<%= field.name %>" style="width:70px;"/>
</div>
</li>
<li class="orgListStatus">新增</li>
<li class="orgListStatus"><%= field.field_type == "Post" ? "帖子" : "资源" %></li>
<%#= link_to "隐藏", hide_org_subfield_organizations_path(field), :method => 'post', :remote => true, :id => "hide_#{field.id}", :class => "linkBlue fr mr5" %>
<a href="javascript:void(0);" class="linkBlue fr mr10" onclick="hide($(this),'<%= field.id %>');" id="hide_<%= field.id %>"><%= field.hide==0?"设为隐藏":"设为显示" %></a>
<%= link_to "删除", org_subfield_path(field), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr10" %>
<a href="javascript:void(0);" class="linkBlue fr mr10" onclick="edit('#subfield_show_<%= field.id %>','#subfield_edit_<%= field.id %>');">编辑</a>
<div class="cl"></div>
</ul>
<% end %>
<script>
function edit(show_id, edit_id) {
$(show_id).toggle(); $(show_id).toggle();
$(edit_id).toggle(); $(edit_id).toggle();
$(edit_id).find('input').focus(); $(edit_id).find('input').focus();
$(edit_id).find('input').on('keypress',function(e){ $(edit_id).find('input').on('keypress', function (e) {
if(e.keyCode == 13){ if (e.keyCode == 13) {
this.blur(); this.blur();
} }
}) })
@ -50,12 +50,25 @@
if ($(show_id).html().trim() != input_value.trim()) { if ($(show_id).html().trim() != input_value.trim()) {
if (confirm('确定修改为' + input_value + "?")) if (confirm('确定修改为' + input_value + "?"))
$.ajax({ $.ajax({
url :"/org_subfields/" + field_id + "?name=" + input_value, url: "/org_subfields/" + field_id + "?name=" + input_value,
type :'put' type: 'put'
}); });
} }
$(show_id).show(); $(show_id).show();
$(edit_id).hide(); $(edit_id).hide();
// $(edit_id).focus(); // $(edit_id).focus();
} }
</script>
function hide(content, id){
if (content.text() == '设为隐藏')
$.ajax({
url: "/organizations/hide_org_subfield?org_subfield_id=" + id,
type: "post"
});
else
$.ajax({
url: "/organizations/show_org_subfield?org_subfield_id=" + id,
type: "post"
});
}
</script>

View File

@ -0,0 +1,2 @@
$("#hide_<%= @org_subfield.id %>").text("设为显示");
$("#org_subfield_<%= @org_subfield.id %>").css("display", "none");

View File

@ -107,7 +107,8 @@
</div> </div>
<div class="undis ml15 mr15" id="orgContent_3"> <div class="undis ml15 mr15" id="orgContent_3">
<div class="orgMemberList" id="org_subfield_list"> <div class="orgMemberList" id="org_subfield_list">
<%= render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields } %> <%= render :partial => 'organizations/subfield_list', :locals => {:default_fields => @organization.org_subfields.where("field_type='default'"),
:subfields => @organization.org_subfields.where("field_type != 'default'") } %>
</div> </div>
<div class="fr orgMemContainer"> <div class="fr orgMemContainer">
<div class="orgMemberAdd"> <div class="orgMemberAdd">

View File

@ -16,7 +16,7 @@
.homepagePostReplyInputContainer .ke-inline-block {display: none;} .homepagePostReplyInputContainer .ke-inline-block {display: none;}
.homepagePostReplyInputContainer .ke-container {float: left;} .homepagePostReplyInputContainer .ke-container {float: left;}
</style> </style>
<% if params[:show_homepage].nil? %> <% if params[:show_homepage].nil? and User.current.logged? %>
<div class="homepageRightBanner"> <div class="homepageRightBanner">
<div class="NewsBannerName"><%= @org_subfield.nil? ? "最新动态":"#{@org_subfield.name}" %></div> <div class="NewsBannerName"><%= @org_subfield.nil? ? "最新动态":"#{@org_subfield.name}" %></div>
<% if params[:org_subfield_id].nil? %> <% if params[:org_subfield_id].nil? %>

View File

@ -0,0 +1,2 @@
$("#hide_<%= @org_subfield.id %>").text("设为隐藏");
$("#org_subfield_<%= @org_subfield.id %>").css("display", "block");

View File

@ -51,6 +51,8 @@ RedmineApp::Application.routes.draw do
collection do collection do
get 'check_uniq' get 'check_uniq'
get 'autocomplete_search' get 'autocomplete_search'
post 'hide_org_subfield'
post 'show_org_subfield'
end end
resources :org_document_comments do resources :org_document_comments do
member do member do

View File

@ -0,0 +1,5 @@
class AddHideToOrgSubfields < ActiveRecord::Migration
def change
add_column :org_subfields, :hide, :integer, :default => 0
end
end

View File

@ -0,0 +1,9 @@
class AddRecordsToOrgSubfields < ActiveRecord::Migration
def change
Organization.all.each do |org|
OrgSubfield.create(:organization_id => org.id, :name => 'activity', :field_type => 'default')
OrgSubfield.create(:organization_id => org.id, :name => 'course', :field_type => 'default')
OrgSubfield.create(:organization_id => org.id, :name => 'project', :field_type => 'default')
end
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20151229022049) do ActiveRecord::Schema.define(:version => 20151231023610) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -198,6 +198,7 @@ ActiveRecord::Schema.define(:version => 20151229022049) do
t.integer "last_message_id" t.integer "last_message_id"
t.integer "parent_id" t.integer "parent_id"
t.integer "course_id" t.integer "course_id"
t.integer "org_subfield_id"
end end
add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id"
@ -1209,9 +1210,10 @@ ActiveRecord::Schema.define(:version => 20151229022049) do
t.integer "organization_id" t.integer "organization_id"
t.integer "priority" t.integer "priority"
t.string "name" t.string "name"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.string "field_type" t.string "field_type"
t.integer "hide", :default => 0
end end
create_table "organizations", :force => true do |t| create_table "organizations", :force => true do |t|