组织中,增加调整栏目显示顺序的功能
This commit is contained in:
parent
713c28c0b5
commit
a51ca428be
|
@ -5,9 +5,8 @@ class OrgSubfieldsController < ApplicationController
|
|||
def create
|
||||
if OrgSubfield.where("organization_id=#{params[:organization_id]} and name=?",params[:name]).count == 0
|
||||
@res = true
|
||||
@subfield = OrgSubfield.create(:name => params[:name])
|
||||
@organization = Organization.find(params[:organization_id])
|
||||
@organization.org_subfields << @subfield
|
||||
@subfield = OrgSubfield.create(:name => params[:name], :organization_id => params[:organization_id],:priority => @organization.org_subfields.order("priority").last.priority + 1)
|
||||
if !params[:sub_dir].blank?
|
||||
sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+
|
||||
"and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'"
|
||||
|
@ -15,7 +14,7 @@ class OrgSubfieldsController < ApplicationController
|
|||
SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir])
|
||||
end
|
||||
end
|
||||
@subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type])
|
||||
@subfield.update_attributes(:field_type => params[:field_type])
|
||||
else
|
||||
@res = false
|
||||
end
|
||||
|
@ -125,6 +124,12 @@ class OrgSubfieldsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def update_priority
|
||||
@org_subfield = OrgSubfield.find(params[:id])
|
||||
@org_subfield.update_attribute(:priority, params[:priority].to_i)
|
||||
@organization = @org_subfield.organization
|
||||
end
|
||||
|
||||
def show_attachments obj
|
||||
@attachments = []
|
||||
obj.each do |container|
|
||||
|
|
|
@ -28,4 +28,8 @@ module OrganizationsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def is_default_field? field
|
||||
(field.name == 'activity' || field.name == 'course' || field.name == 'project') && field.field_type == 'default'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -9,6 +9,7 @@ class OrgSubfield < ActiveRecord::Base
|
|||
has_many :news, :dependent => :destroy
|
||||
acts_as_attachable
|
||||
after_create :create_board_sync
|
||||
after_destroy :update_priority
|
||||
# 创建资源栏目讨论区
|
||||
def create_board_sync
|
||||
@board = self.boards.build
|
||||
|
@ -25,4 +26,11 @@ class OrgSubfield < ActiveRecord::Base
|
|||
|
||||
def project
|
||||
end
|
||||
|
||||
def update_priority
|
||||
OrgSubfield.where("organization_id=? and priority>?", self.organization_id, self.priority).each do |field|
|
||||
field.decrement(:priority)
|
||||
field.save
|
||||
end
|
||||
end
|
||||
end
|
|
@ -16,8 +16,8 @@ class Organization < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def add_default_subfields
|
||||
OrgSubfield.create(:organization_id => self.id, :name => 'activity', :field_type => 'default')
|
||||
OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default')
|
||||
OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default')
|
||||
OrgSubfield.create(:organization_id => self.id, :name => 'activity', :field_type => 'default', :priority => 1)
|
||||
OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default', :priority => 2)
|
||||
OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default', :priority => 3)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<% if @res %>
|
||||
$("#org_subfield_list").html("");
|
||||
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',
|
||||
:locals => {:default_fields => @organization.org_subfields.where("field_type='default'"),
|
||||
:subfields => @organization.org_subfields.where("field_type != 'default'") }) %>");
|
||||
:locals => {:subfields => @organization.org_subfields.order("priority") }) %>");
|
||||
$("#sub_field_left_lists").html("");
|
||||
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");
|
||||
$("#subfield_name").val("");
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
$("#org_subfield_list").html("");
|
||||
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',
|
||||
:locals => {:default_fields => @organization.org_subfields.where("field_type='default'"),
|
||||
:subfields => @organization.org_subfields.where("field_type != 'default'") }) %>");
|
||||
:locals => {:subfields => @organization.org_subfields.order("priority") }) %>");
|
||||
$("#sub_field_left_lists").html("");
|
||||
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");
|
|
@ -0,0 +1,2 @@
|
|||
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',:locals => {:subfields => @organization.org_subfields.order("priority")}) %>");
|
||||
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>")
|
|
@ -34,71 +34,76 @@
|
|||
})
|
||||
})
|
||||
</script>
|
||||
<% 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:<%= is_hide_org_left(org_activity_field) ? 'block':'none' %>;" id="org_subfield_<%= org_activity_field.id %>">
|
||||
<%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %>
|
||||
</div>
|
||||
<div style="display:<%= is_hide_org_left(org_project_field) ? 'block':'none' %>;" id="org_subfield_<%= org_project_field.id %>">
|
||||
<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:<%= is_hide_org_left(org_course_field) ? '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.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 "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
|
||||
<% organization.org_subfields.order("priority").each do |field| %>
|
||||
<% if is_default_field?(field) %>
|
||||
<% case field.name %>
|
||||
<% when 'activity' %>
|
||||
<div class="homepageLeftMenuBlock" style="display:<%= field.hide == 0 ? 'block':'none' %>;" id="org_subfield_<%= field.id %>">
|
||||
<%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %>
|
||||
</div>
|
||||
<% when 'course' %>
|
||||
<div style="display:<%= field.hide == 0 ? 'block':'none' %>;" id="org_subfield_<%= 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>
|
||||
<% when 'project' %>
|
||||
<div style="display:<%= field.hide == 0 ? 'block':'none' %>;" id="org_subfield_<%= field.id %>">
|
||||
<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>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="homepageLeftMenuBlock" style="display:<%= field.hide == 0?'block':'none' %>;" id="org_subfield_<%= field.id %>">
|
||||
<% if field.field_type == "Post" %>
|
||||
<% 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 "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
|
||||
<%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %>
|
||||
<% end %>
|
||||
<% if User.current.member_of_org?organization %>
|
||||
<%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %>
|
||||
<% 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 "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %>
|
||||
<% end %>
|
||||
<% if User.current.member_of_org?organization %>
|
||||
<%= link_to "", subfield_upload_file_org_subfield_files_path(field.id, :in_org => 1),:method => "post", :remote => true, :class => "homepageMenuSetting fr", :title => "上传资源" %>
|
||||
<!--<a class="homepageMenuSetting fr" title="上传资源" href="javascript:void(0);" onclick="org_subfield_files_upload(<%#= field.id %>);"> </a>-->
|
||||
<% end %>
|
||||
<!--<a href="javascript:void(0);" class="homepageMenuText"><%#= field.name %></a>-->
|
||||
<% end %>
|
||||
<% if User.current.member_of_org?organization %>
|
||||
<%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% 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 "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %>
|
||||
<% end %>
|
||||
<% if User.current.member_of_org?organization %>
|
||||
<%= link_to "", subfield_upload_file_org_subfield_files_path(field.id, :in_org => 1),:method => "post", :remote => true, :class => "homepageMenuSetting fr", :title => "上传资源" %>
|
||||
<!--<a class="homepageMenuSetting fr" title="上传资源" href="javascript:void(0);" onclick="org_subfield_files_upload(<%#= field.id %>);"> </a>-->
|
||||
<% end %>
|
||||
<!--<a href="javascript:void(0);" class="homepageMenuText"><%#= field.name %></a>-->
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="homepageLeftMenuCourses" id="homepageLeftMenuField_<%= field.id %>" style="display:none;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="homepageLeftMenuCourses" id="homepageLeftMenuField_<%= field.id %>" style="display:none;">
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -1,4 +1,5 @@
|
|||
<ul class="orgListRow">
|
||||
<li class="orgOrder fb">顺序</li>
|
||||
<li class="orgListUser fb">已有栏目</li>
|
||||
<li class="orgListStatus fb">状态</li>
|
||||
<li class="orgListStatus fb">类型</li>
|
||||
|
@ -6,48 +7,64 @@
|
|||
<div class="cl"></div>
|
||||
</ul>
|
||||
|
||||
<% default_fields.each do |field| %>
|
||||
<% name = get_default_name(field) %>
|
||||
<ul class="orgListRow">
|
||||
<li class="orgListUser"><%= name %></li>
|
||||
<li class="orgListStatus">默认</li>
|
||||
<li class="orgListStatus">默认</li>
|
||||
<a href="javascript:void(0);" class="linkBlue fr mr10" onclick="hide($(this),'<%= field.id %>');" id="hide_<%= field.id %>"><%= field.hide==0?"设为隐藏":"设为可见" %></a>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% subfields.each do |field| %>
|
||||
<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>
|
||||
<li class="orgListUser hidden">
|
||||
<% if Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 %>
|
||||
<div id="sub_dir_show_<%= field.id %>" ondblclick="edit_dir('#sub_dir_show_<%= field.id %>','#sub_dir_edit_<%= field.id %>');" style="cursor:pointer;background-color:#fffce6;color: #0d90c3;" title="双击可编辑">
|
||||
<%= field.subfield_subdomain_dir.nil? ? '未设置': field.subfield_subdomain_dir.name %>
|
||||
<% if is_default_field?(field) %>
|
||||
<% name = get_default_name(field) %>
|
||||
<ul class="orgListRow">
|
||||
<li class="orgOrder">
|
||||
<div id="show_priority_<%= field.id %>" ondblclick="edit_priority('#show_priority_<%= field.id %>','#edit_priority_<%= field.id %>');" style="cursor:pointer;background-color:#fffce6;color: #0d90c3;" title="双击可编辑">
|
||||
<%= field.priority %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div id="sub_dir_show_<%= field.id %>" >
|
||||
<%= field.subfield_subdomain_dir.nil? ? '未设置': field.subfield_subdomain_dir.name %>
|
||||
<div id="edit_priority_<%= field.id %>" style="display:none;width:30px;">
|
||||
<input type="text" onblur="update_priority('#show_priority_<%= field.id %>','#edit_priority_<%= field.id %>','<%= field.id %>',$(this).val());" style="width:20px;" value="<%= field.priority %>"/>
|
||||
</div>
|
||||
<% end %>
|
||||
<div id="sub_dir_edit_<%= field.id %>" style="display:none;">
|
||||
<input type="text" name="name" onblur="update_sub_dir('#sub_dir_show_<%= field.id %>','#sub_dir_edit_<%= field.id %>','<%= field.id %>',$(this).val());" value="<%= field.subfield_subdomain_dir.nil? ? '': field.subfield_subdomain_dir.name %>" style="width:70px;"/>
|
||||
</div>
|
||||
</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>
|
||||
</li>
|
||||
<li class="orgListUser"><%= name %></li>
|
||||
<li class="orgListStatus">默认</li>
|
||||
<li class="orgListStatus">默认</li>
|
||||
<a href="javascript:void(0);" class="linkBlue fr mr10" onclick="hide($(this),'<%= field.id %>');" id="hide_<%= field.id %>"><%= field.hide==0?"设为隐藏":"设为可见" %></a>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<% else %>
|
||||
<ul class="orgListRow">
|
||||
<li class="orgOrder">
|
||||
<div id="show_priority_<%= field.id %>" ondblclick="edit_priority('#show_priority_<%= field.id %>','#edit_priority_<%= field.id %>');" style="cursor:pointer;background-color:#fffce6;color: #0d90c3;" title="双击可编辑">
|
||||
<%= field.priority %>
|
||||
</div>
|
||||
<div id="edit_priority_<%= field.id %>" style="display:none;width:30px;">
|
||||
<input type="text" onblur="update_priority('#show_priority_<%= field.id %>','#edit_priority_<%= field.id %>','<%= field.id %>',$(this).val());" style="width:20px;" value="<%= field.priority %>"/>
|
||||
</div>
|
||||
</li>
|
||||
<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>
|
||||
<li class="orgListUser hidden">
|
||||
<% if Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 %>
|
||||
<div id="sub_dir_show_<%= field.id %>" ondblclick="edit_dir('#sub_dir_show_<%= field.id %>','#sub_dir_edit_<%= field.id %>');" style="cursor:pointer;background-color:#fffce6;color: #0d90c3;" title="双击可编辑">
|
||||
<%= field.subfield_subdomain_dir.nil? ? '未设置': field.subfield_subdomain_dir.name %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div id="sub_dir_show_<%= field.id %>" >
|
||||
<%= field.subfield_subdomain_dir.nil? ? '未设置': field.subfield_subdomain_dir.name %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div id="sub_dir_edit_<%= field.id %>" style="display:none;">
|
||||
<input type="text" name="name" onblur="update_sub_dir('#sub_dir_show_<%= field.id %>','#sub_dir_edit_<%= field.id %>','<%= field.id %>',$(this).val());" value="<%= field.subfield_subdomain_dir.nil? ? '': field.subfield_subdomain_dir.name %>" style="width:70px;"/>
|
||||
</div>
|
||||
</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>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<script>
|
||||
|
@ -96,6 +113,31 @@
|
|||
$(show_id).show();
|
||||
$(edit_id).hide();
|
||||
}
|
||||
|
||||
function edit_priority(show_id, edit_id){
|
||||
$(show_id).toggle();
|
||||
$(edit_id).toggle();
|
||||
$(edit_id).find("input").focus();
|
||||
$(edit_id).find("input").on('keypress',function(e){
|
||||
if (e.keyCode == 13){
|
||||
this.blur();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function update_priority(show_id, edit_id, field_id, input_value){
|
||||
var re = /^[0-9]*[1-9]*[0-9]$/
|
||||
if(re.test(input_value) && $(show_id).html().trim() != input_value.trim() && input_value.trim() != ''){
|
||||
if(confirm("确定修改为" + input_value + "?")){
|
||||
$.ajax({
|
||||
url: "/org_subfields/" + field_id + "/update_priority?priority=" + input_value,
|
||||
type: 'put'
|
||||
});
|
||||
}
|
||||
}
|
||||
$(show_id).show();
|
||||
$(edit_id).hide();
|
||||
}
|
||||
function hide(content, id){
|
||||
if (content.text() == '设为隐藏')
|
||||
$.ajax({
|
||||
|
|
|
@ -119,8 +119,7 @@
|
|||
</div>
|
||||
<div class="undis ml15 mr15" id="orgContent_3">
|
||||
<div class="orgMemberList" id="org_subfield_list">
|
||||
<%= render :partial => 'organizations/subfield_list', :locals => {:default_fields => @organization.org_subfields.where("field_type='default'"),
|
||||
:subfields => @organization.org_subfields.where("field_type != 'default'") } %>
|
||||
<%= render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields.order("priority")} %>
|
||||
</div>
|
||||
<div class="fr orgMemContainer">
|
||||
<div class="fr">
|
||||
|
|
|
@ -111,6 +111,7 @@ RedmineApp::Application.routes.draw do
|
|||
end
|
||||
member do
|
||||
match 'update_sub_dir', :via => [:put]
|
||||
match 'update_priority', :via => [:put]
|
||||
end
|
||||
resource :boards
|
||||
end
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
class SetPriorityForOrgSubfields < ActiveRecord::Migration
|
||||
def up
|
||||
Organization.all.each do |org|
|
||||
org.transaction do
|
||||
org.org_subfields.where("field_type='default'").each do|field|
|
||||
case field.field_type
|
||||
when 'activity'
|
||||
field.update_attribute(:priority, 1)
|
||||
when 'course'
|
||||
field.update_attribute(:priority, 2)
|
||||
when 'project'
|
||||
field.update_attribute(:priority, 3)
|
||||
end
|
||||
end
|
||||
org.org_subfields.where("field_type!='default'").each_with_index do |field, index|
|
||||
field.update_attribute(:priority, index + 4)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -22,6 +22,7 @@ a.saveBtn:hover {background-color:#297fb8;}
|
|||
.orgListRow {border-bottom:1px solid #e4e4e4; padding-bottom:5px;}
|
||||
.orgListUser {width:85px; float:left;}
|
||||
.orgListRole {width:180px; float:left;}
|
||||
.orgOrder {width:30px; float:left;margin-right:10px;text-align:center;}
|
||||
.orgMemContainer {width:228px;}
|
||||
.orgMemberAdd {float:right;}
|
||||
.orgAddSearch {border:1px solid #dddddd; outline:none; width:180px; height:22px; color:#9b9b9b;}
|
||||
|
|
Loading…
Reference in New Issue