1.解决一些bug;2.组织子目录功能实现

This commit is contained in:
ouyangxuhua 2016-01-13 15:17:13 +08:00
parent 7bcf995eaf
commit 6cfda615d6
19 changed files with 165 additions and 148 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the subfield_subdomain_dirs controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -1,4 +1,5 @@
class OrgSubfieldsController < ApplicationController class OrgSubfieldsController < ApplicationController
layout 'base_org'
def create def create
if OrgSubfield.where("organization_id=#{params[:organization_id]} and name=?",params[:name]).count == 0 if OrgSubfield.where("organization_id=#{params[:organization_id]} and name=?",params[:name]).count == 0
@res = true @res = true
@ -20,13 +21,12 @@ class OrgSubfieldsController < ApplicationController
def show def show
@organization = Organization.find(params[:id]) @organization = Organization.find(params[:id])
@subfield = @organization.org_subfields.first
if @subfield.field_type == 'Post'
redirect_to organization_path(@organization, :org_subfield_id => @subfield.id)
end
@org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+ @org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+
"subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+ "subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+
" org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name=#{params[:name]}").first " org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:name]}'").first
if @org_subfield.field_type == 'Post'
redirect_to organization_path(@organization, :org_subfield_id => @org_subfield.id)
end
if params[:sort] if params[:sort]
params[:sort].split(",").each do |sort_type| params[:sort].split(",").each do |sort_type|
order_by = sort_type.split(":") order_by = sort_type.split(":")
@ -74,17 +74,9 @@ class OrgSubfieldsController < ApplicationController
show_attachments @containers show_attachments @containers
@tag_list = attachment_tag_list @all_attachments @tag_list = attachment_tag_list @all_attachments
@page = params[:page] || 1 @page = params[:page] || 1
render :layout => 'base_org' #render :layout => 'base_org'
# @org_subfield = OrgSubfield.find(params[:id])
# @organization = @org_subfield.organization.id
# @messages = []
# @messages << @org_subfield.org_document_comments
# @messages << @org_subfield.messages
# @messages.sort{|a, b| b.updated_at <=> a.updated_at}
# respond_to do |format|
# format.html{render :layout => 'base_org'}
# end
end end
def destroy def destroy
@subfield = OrgSubfield.find(params[:id]) @subfield = OrgSubfield.find(params[:id])
@organization = Organization.find(@subfield.organization_id) @organization = Organization.find(@subfield.organization_id)
@ -97,4 +89,43 @@ class OrgSubfieldsController < ApplicationController
@subfield.update_attributes(:name => params[:name]) @subfield.update_attributes(:name => params[:name])
end end
def update_sub_dir
@org_subfield = OrgSubfield.find(params[:id])
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=#{@org_subfield.organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir_name]}'"
if SubfieldSubdomainDir.find_by_sql(sql).count == 0
if @org_subfield.subfield_subdomain_dir
@sub_dir = @org_subfield.subfield_subdomain_dir
@sub_dir.update_attribute(:name, params[:sub_dir_name])
else
@sub_dir = SubfieldSubdomainDir.create(:org_subfield_id => @org_subfield.id, :name => params[:sub_dir_name])
end
@exist = false
else
@exist = true
end
end
def show_attachments obj
@attachments = []
obj.each do |container|
@attachments += container.attachments
end
@all_attachments = User.current.admin? ? @attachments : visable_attachemnts(@attachments)
@limit = 10
@feedback_count = @all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
@obj_attachments = paginateHelper @all_attachments,10
end
#获取指定资源列表的TAG的集合以及每个TAG的数量降序排序
def attachment_tag_list attachments
tag_list = Hash.new
attachments.each do |attachment|
attachment.tag_list.map{|tag| tag_list.has_key?(tag) ? tag_list[tag] = tag_list[tag] + 1 : tag_list[tag] = 1}
end
tag_list.sort {|a,b| b[1]<=>a[1]}
end
end end

View File

@ -512,6 +512,14 @@ class ProjectsController < ApplicationController
def edit def edit
end end
def set_public_or_private
@project = Project.find(params[:id])
if @project.is_public?
@project.update_attribute(:is_public, 0)
else
@project.update_attribute(:is_public, 1)
end
end
# by young # by young
# include CoursesHelper # include CoursesHelper
def member def member

View File

@ -0,0 +1,10 @@
class SubfieldSubdomainDirsController < ApplicationController
def update
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
if @org_subfield.subfield_subdomain_dir
@org_subfield.subfield_subdomain_dir.update_attribute(:name, :params[:sub_dir_name])
else
SubfieldSubdomainDir.create(:org_subfield_id => @org_subfield.id, :name => params[:sub_dir_name])
end
end
end

View File

@ -0,0 +1,2 @@
module SubfieldSubdomainDirsHelper
end

View File

@ -1,6 +1,6 @@
class OrgSubfield < ActiveRecord::Base class OrgSubfield < ActiveRecord::Base
belongs_to :organization, :foreign_key => :organization_id belongs_to :organization, :foreign_key => :organization_id
has_one :subfield_subdomain_dir has_one :subfield_subdomain_dir,:dependent => :destroy
has_many :org_document_comments, :dependent => :destroy has_many :org_document_comments, :dependent => :destroy
has_many :files has_many :files
has_many :org_subfield_messages, :dependent => :destroy has_many :org_subfield_messages, :dependent => :destroy

View File

@ -1,3 +1,4 @@
<% if params[:user_page].nil? %>
$("#project_info_<%=@course.id %>").html('<%=escape_javascript(render :partial=>'layouts/project_info') %>'); $("#project_info_<%=@course.id %>").html('<%=escape_javascript(render :partial=>'layouts/project_info') %>');
if(document.getElementById("course_is_public")) { if(document.getElementById("course_is_public")) {
<% if @course.is_public == 0%> <% if @course.is_public == 0%>
@ -6,3 +7,6 @@ if(document.getElementById("course_is_public")) {
$("#course_is_public").attr("checked",true); $("#course_is_public").attr("checked",true);
<% end %> <% end %>
} }
<% else %>
location.reload();
<% end %>

View File

@ -11,58 +11,11 @@
} }
}); });
} }
function show_upload(obj)
{
switch(obj)
{
// case 1:
// $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'upload_subfield_file',:locals => {:org_subfield => @org_subfield,:org_subfield_attachment_type => 1}) %>');
// break;
case 2:
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_subfield_file',:locals => {:org_subfield => @org_subfield,:org_subfield_attachment_type => 2}) %>');
break;
case 3:
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_subfield_file',:locals => {:org_subfield => @org_subfield,:org_subfield_attachment_type => 3}) %>');
break;
case 4:
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_subfield_file',:locals => {:org_subfield => @org_subfield,:org_subfield_attachment_type => 4}) %>');
break;
// case 6:
// $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'upload_subfield_file',:locals => {:org_subfield => @org_subfield,:org_subfield_attachment_type => 6}) %>');
// break;
default:
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_subfield_file',:locals => {:org_subfield => @org_subfield,:org_subfield_attachment_type => 5}) %>');
}
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal()' style='margin-left: 480px;'><img src='/images/bid/close.png' width='26px' height='26px' /></a>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls");
}
function closeModal() function closeModal()
{ {
hideModal($("#popbox_upload")); hideModal($("#popbox_upload"));
} }
//
// function presscss(id)
// {
// if(id == "inorg_subfield")
// {
// $('#inorg_subfield').attr("class", "re_schbtn b_dblue");
// $('#insite').attr("class", "re_schbtn b_lblue");
// }
// else
// {
// $('#inorg_subfield').attr("class", "re_schbtn b_lblue");
// $('#insite').attr("class", "re_schbtn b_dblue");
// }
// }
// function buttoncss()
// {
// $('#inorg_subfield').attr("class", "re_schbtn b_lblue");
// $('#insite').attr("class", "re_schbtn b_lblue");
// }
</script> </script>
<div class="homepageRight mt0 ml0"> <div class="homepageRight mt0 ml0">
@ -97,7 +50,7 @@
<div> <div>
<div class="re_con_top"> <div class="re_con_top">
<div class="files_tag" id="files_tag"> <div class="files_tag" id="files_tag">
<%= render :partial => "files/subfield_tags", :locals => {:tag_list => @tag_list,:org_subfield => @org_subfield,:tag_name => @tag_name}%> <%#= render :partial => "files/subfield_tags", :locals => {:tag_list => @tag_list,:org_subfield => @org_subfield,:tag_name => @tag_name}%>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span><%= @all_attachments.count %></span>&nbsp;个资源</p> <p class="f_l fontBlue f_b f_14">共有&nbsp;<span><%= @all_attachments.count %></span>&nbsp;个资源</p>
@ -117,7 +70,7 @@
</div> </div>
</div> </div>
<div id="org_subfield_list"> <div id="org_subfield_list">
<%= render :partial => 'org_subfield_list',:locals => {org_subfield: @org_subfield,all_attachments: @all_attachments,sort:@sort,order:@order,org_subfield_attachments:@obj_attachments} %> <%= render :partial => 'files/org_subfield_list',:locals => {org_subfield: @org_subfield,all_attachments: @all_attachments,sort:@sort,order:@order,org_subfield_attachments:@obj_attachments} %>
</div><!---re_con end--> </div><!---re_con end-->
</div> </div>

View File

@ -1,7 +1,7 @@
<% courses.each do |course|%> <% courses.each do |course|%>
<li class="homepageLeftMenuCoursesLine pr"> <li class="homepageLeftMenuCoursesLine pr">
<%= link_to course.name, course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey hidden #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}", <%= link_to course.name, course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey hidden #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}",
:title => (course.is_public ? "公有课程:":"私有课程:")+course.name+""+course.time.to_s+course.term+""%> :title => (course.is_public? ? "公开课程:":"私有课程:")+course.name+""+course.time.to_s+course.term+""%>
<% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %>
<ul class="<%= count > 0 ? 'shild shildP':'subNavArrow'%>"> <ul class="<%= count > 0 ? 'shild shildP':'subNavArrow'%>">
<li> <li>
@ -13,12 +13,12 @@
</li> </li>
<li class="subNavRow"> <li class="subNavRow">
<%= link_to "通知", course_news_index_path(course), :class => 'fl',:target => '_blank' %> <%= link_to "通知", course_news_index_path(course), :class => 'fl',:target => '_blank' %>
<%= link_to "+", course_news_index_path(course), :class => 'fr fb', :title => '发布通知',:target => '_blank' %> <%= link_to "+", new_course_news_path(course,:is_new=>1), :class => 'fr fb', :title => '发布通知',:target => '_blank' %>
<div class="cl"></div> <div class="cl"></div>
</li> </li>
<li class="subNavRow"> <li class="subNavRow">
<%= link_to "资源",course_files_path(course), :remote => true, :class => 'fl' %> <%= link_to "资源",course_files_path(course), :class => 'fl',:target => '_blank' %>
<%= link_to "+",upload_files_menu_path(:course_id => course.id), :class => 'fr fb', :title => '上传资源' %> <%= link_to "+",upload_files_menu_path(:course_id => course.id), :class => 'fr fb',:remote => true, :title => '上传资源' %>
<div class="cl"></div> <div class="cl"></div>
</li> </li>
<li class="subNavRow"> <li class="subNavRow">
@ -31,13 +31,13 @@
<% if count == 0 %> <% if count == 0 %>
<%= link_to "屏蔽动态", shield_activities_path(:user_id => user.id, :course_id => course.id), :method => 'post',:remote => true %> <%= link_to "屏蔽动态", shield_activities_path(:user_id => user.id, :course_id => course.id), :method => 'post',:remote => true %>
<% else %> <% else %>
<%= link_to "显示动态", show_acts_shield_activities_path(:user_id => user.id, :course_id => course.id),:remote => true %> <%= link_to "显示动态", show_acts_shield_activities_path(:user_id => user.id, :course_id => course.id),:remote => true,:method => 'delete' %>
<% end %> <% end %>
</li> </li>
<% end %> <% end %>
<% if User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %> <% if User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %>
<li class="subNavRow"> <li class="subNavRow">
<%= link_to course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => course}, <%= link_to course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => course,:user_page => true},
:remote=>true,:confirm=>"您确定要设置为"+(course.is_public == 0 ? "公开" : "私有")+"吗"%> :remote=>true,:confirm=>"您确定要设置为"+(course.is_public == 0 ? "公开" : "私有")+"吗"%>
<div class="cl"></div> <div class="cl"></div>
</li> </li>

View File

@ -1,28 +1,28 @@
<% projects.each do |project|%> <% projects.each do |project|%>
<li class="homepageLeftMenuCoursesLine pr"> <li class="homepageLeftMenuCoursesLine pr">
<% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count %> <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count %>
<%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => project.name%> <%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%>
<ul class="<%= count > 0 ? 'shild shildP':'subNavArrow'%>"> <ul class="<%= count > 0 ? 'shild shildP':'subNavArrow'%>">
<li> <li>
<ul class="subNavMenu boxShadow"> <ul class="subNavMenu boxShadow">
<li class="subNavRow"> <li class="subNavRow">
<%=link_to "问题跟踪", new_project_issue_path(project), :class => 'fl fontGrey2', :target => '_blank',:style => "width:48px;" %> <%=link_to "问题跟踪", project_issues_path(project), :class => 'fl fontGrey2', :target => '_blank',:style => "width:48px;" %>
<%=link_to "+", new_project_issue_path(project), :class => 'fr fb', :target => '_blank',:style => "width:48px;", :title => '发布问题',:style =>'width:10px;' %> <%=link_to "+", new_project_issue_path(project), :class => 'fr fb', :target => '_blank',:style => "width:48px;", :title => '发布问题',:style =>'width:10px;' %>
<div class="cl"></div> <div class="cl"></div>
</li> </li>
<li class="subNavRow"> <li class="subNavRow">
<%=link_to "资源", upload_files_menu_path(:project_id => project.id),:remote => true,:class => 'fl fontGrey2' %> <%=link_to "资源", project_files_path(project),:remote => true,:class => 'fl fontGrey2' %>
<%=link_to "+", upload_files_menu_path(:project_id => project.id),:remote => true,:class => 'fr fb',:title => '上传资源'%> <%=link_to "+", upload_files_menu_path(:project_id => project.id),:remote => true,:class => 'fr fb',:title => '上传资源'%>
<div class="cl"></div> <div class="cl"></div>
</li> </li>
<li class="subNavRow"> <li class="subNavRow">
<%=link_to "论坛", project_boards_path(project, :flag => true),:remote => true,:class => 'fl fontGrey2', :target => '_blank'%> <%=link_to "论坛", project_boards_path(project),:class => 'fl fontGrey2', :target => '_blank'%>
<%=link_to "+", project_boards_path(project, :flag => true),:remote => true,:class => 'fr fb', :target => '_blank',:title => '发布帖子'%> <%=link_to "+", project_boards_path(project, :flag => true),:class => 'fr fb', :target => '_blank',:title => '发布帖子'%>
<div class="cl"></div> <div class="cl"></div>
</li> </li>
<% if (User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, project)) && rep_is_gitlab?(project) %> <% if (User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, project)) && rep_is_gitlab?(project) %>
<li class="subNavRow"> <li class="subNavRow">
<%= link_to '版本库', url_for(:controller => 'projects', :action => 'settings', :id => project.id, :tab=>'repositories') , :target => '_blank',:class => "fl",:title => '新建版本库' %> <%= link_to '版本库', url_for(:controller => 'projects', :action => 'settings', :id => project.id, :tab=>'repositories') , :target => '_blank',:class => "fl",:title => '版本库' %>
<div class="cl"></div> <div class="cl"></div>
</li> </li>
<% end %> <% end %>
@ -36,6 +36,13 @@
<div class="cl"></div> <div class="cl"></div>
</li> </li>
<% end %> <% end %>
<% if User.current.logged? && (User.current.admin? || is_project_manager?(User.current,project)) %>
<li class="subNavRow">
<%= link_to project.is_public? ? "设为私有" : "设为公开", {:controller => 'projects', :action => 'set_public_or_private', :id => project.id,:user_page => true},
:method => 'post',:remote=>true,:confirm=>"您确定要设置为"+(project.is_public? ? "私有" : "公开")+"吗"%>
<div class="cl"></div>
</li>
<% end %>
</ul> </ul>
</li> </li>
</ul> </ul>

View File

@ -55,7 +55,6 @@
} }
} }
function attachment_contenttypes_searchex(value) { function attachment_contenttypes_searchex(value) {
<% if @project%> <% if @project%>
$.ajax({ $.ajax({
@ -70,8 +69,6 @@
<%end%> <%end%>
} }
function attachtype_edit(value) { function attachtype_edit(value) {
<% if @project%> <% if @project%>
$.ajax({ $.ajax({
@ -87,62 +84,6 @@
<%end%> <%end%>
} }
function attachmenttypes_searchex(value) {
<% if @project%>
$.ajax({
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
type: "POST",
data: {
type: encodeURIComponent(value),
contentType: $('#attach_sufix_browse').val()
}
}).complete(eval_ajax);
<%end%>
}
function course_attachmenttypes_searchex(value) {
<% if @course%>
$.ajax({
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
type: "POST",
data: {
type: encodeURIComponent(value),
contentType: $('#attach_sufix_browse').val()
}
}).complete(eval_ajax);
<%end%>
}
function course_attachment_contenttypes_searchex(value) {
<% if @course%>
$.ajax({
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
type: "POST",
data: {
type: $('#attachment_browse').val(),
contentType: encodeURIComponent(value)
}
}).complete(eval_ajax);
<%end%>
}
function course_attachtype_edit(value) {
<% if @course%>
$.ajax({
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
type: "POST",
data: {
type: $('#attachment_browse').val(),
contentType: encodeURIComponent(value)
}
}).complete(eval_ajax);
<%end%>
}
function attachmenttypes_change(id, type) { function attachmenttypes_change(id, type) {
<% if @project%> <% if @project%>
$.ajax({ $.ajax({

View File

@ -0,0 +1,10 @@
<%# if @exist == false %>
$('#sub_dir_show_<%= @org_subfield.id %>').html('<%= @sub_dir.name %>');
$('#sub_dir_edit_<%= @org_subfield.id %>').find('input').val('<%= @sub_dir.name %>');
$('#sub_dir_show_<%= @org_subfield.id %>').show();
$('#sub_dir_edit_<%= @org_subfield.id %>').hide();
<%# else %>
// alert("该目录已存在,请重新输入");
// $('#sub_dir_edit_<%#= @org_subfield.id %>').find('input').val('<%#= @org_subfield.subfield_subdomain_dir.nil? ? "未设置":@org_subfield.subfield_subdomain_dir.name %>');
// $('#sub_dir_edit_<%= @org_subfield.id %>').focus();
<%# end %>

View File

@ -75,7 +75,11 @@
<%=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 => "发布帖子"%>
<% end %> <% end %>
<% else %> <% else %>
<%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :name => field.name), :class => "homepageMenuText" %> <% if !field.subfield_subdomain_dir.nil? %>
<%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
<% else %>
<%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %>
<% end %>
<% if User.current.member_of_org?organization %> <% 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 => "上传资源" %> <%= 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>--> <!--<a class="homepageMenuSetting fr" title="上传资源" href="javascript:void(0);" onclick="org_subfield_files_upload(<%#= field.id %>);"> </a>-->

View File

@ -27,7 +27,12 @@
</li> </li>
<li class="orgListStatus">新增</li> <li class="orgListStatus">新增</li>
<li class="orgListStatus"><%= field.field_type == "Post" ? "帖子" : "资源" %></li> <li class="orgListStatus"><%= field.field_type == "Post" ? "帖子" : "资源" %></li>
<li class="orgListUser hidden"><%= field.subfield_subdomain_dir.nil? ? '未设置': field.subfield_subdomain_dir.name %></li> <li class="orgListUser hidden">
<div id="sub_dir_show_<%= field.id %>" ondblclick="edit_dir('#sub_dir_show_<%= field.id %>','#sub_dir_edit_<%= field.id %>');"><%= field.subfield_subdomain_dir.nil? ? '未设置': field.subfield_subdomain_dir.name %></div>
<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" %> <%#= 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> <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" %> <%= link_to "删除", org_subfield_path(field), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr10" %>
@ -61,6 +66,28 @@
// $(edit_id).focus(); // $(edit_id).focus();
} }
function edit_dir(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_sub_dir(show_id, edit_id, field_id, input_value) {
if ($(show_id).html().trim() != input_value.trim()) {
if (confirm('确定修改为' + input_value + "?"))
$.ajax({
url: "/org_subfields/" + field_id + "/update_sub_dir?sub_dir_name=" + input_value,
type: 'put'
});
}
$(show_id).show();
$(edit_id).hide();
}
function hide(content, id){ function hide(content, id){
if (content.text() == '设为隐藏') if (content.text() == '设为隐藏')
$.ajax({ $.ajax({

View File

@ -0,0 +1 @@
location.reload();

View File

@ -0,0 +1 @@
$("#sub_dir_show_<%= @org_subfield.id %>").html("<%= @org_subfield.subfield_subdomain_dir.name %>");

View File

@ -74,7 +74,10 @@ RedmineApp::Application.routes.draw do
end end
Organization.where("domain is not null").each do |org| Organization.where("domain is not null").each do |org|
get '/', to: 'organizations#show', defaults: { id: org.id }, constraints: {subdomain: org.domain} org_domains = []
org_domains << org.domain
#get '/', to: 'organizations#show', defaults: { id: org.id }, constraints: {subdomain: org.domain}
get '/', to: 'organizations#show', defaults: { id: org.id }, constraints: lambda{ |request| org_domains.include?(request.remote_ip) }
end end
get '/', to: 'organizations#show', defaults: { id: 5 }, constraints: {subdomain: 'micros'} get '/', to: 'organizations#show', defaults: { id: 5 }, constraints: {subdomain: 'micros'}
get '/', to: 'organizations#show', defaults: { id: 23 }, constraints: {subdomain: 'nubot'} get '/', to: 'organizations#show', defaults: { id: 23 }, constraints: {subdomain: 'nubot'}
@ -102,6 +105,9 @@ RedmineApp::Application.routes.draw do
match "quote_resource_show_org_subfield", :via => [:get] match "quote_resource_show_org_subfield", :via => [:get]
end end
end end
member do
match 'update_sub_dir', :via => [:put]
end
resource :boards resource :boards
end end
@ -631,6 +637,7 @@ RedmineApp::Application.routes.draw do
post 'reopen' post 'reopen'
get 'search_public_orgs_not_in_project' get 'search_public_orgs_not_in_project'
match 'copy', :via => [:get, :post] match 'copy', :via => [:get, :post]
match 'set_public_or_private', :via => [:post]
end end
collection do collection do

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe SubfieldSubdomainDirsController, :type => :controller do
end