Merge branch 'hjq_beidou' of https://git.trustie.net/jacknudt/trustieforge into hjq_beidou
This commit is contained in:
commit
c8da24b6bc
|
@ -1,6 +1,6 @@
|
|||
class SubDomainsController < ApplicationController
|
||||
layout 'base_org'
|
||||
before_filter :find_org_subfield_and_subdomain, :only => [:show, :index]
|
||||
before_filter :find_org_subfield_and_subdomain, :only => [:show, :index, :domain_update_priority, :destroy, :update, :hide_sub_domain, :show_sub_domain]
|
||||
|
||||
def new
|
||||
@subdomain = SubDomain.new
|
||||
|
@ -13,13 +13,25 @@ class SubDomainsController < ApplicationController
|
|||
@res = true
|
||||
@subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
@organization = @subfield.organization
|
||||
@subdomain = SubDomain.create(:name => params[:name], :org_subfield_id => params[:org_subfield_id],:priority => @subfield.sub_domains.blank? ? 1.1 : @subfield.sub_domains.order("priority").last.priority + 0.1)
|
||||
@subdomain = SubDomain.create(:name => params[:name], :org_subfield_id => params[:org_subfield_id], :priority => @subfield.sub_domains.blank? ? 1 : @subfield.sub_domains.order("priority").last.priority + 1)
|
||||
@subdomain.update_column(:field_type, params[:field_type])
|
||||
else
|
||||
@res = false
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@subdomain.update_column(:name, params[:name])
|
||||
end
|
||||
|
||||
def domain_update_priority
|
||||
@subdomain.update_attribute(:priority, params[:priority].to_i)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@subdomain.destroy
|
||||
end
|
||||
|
||||
def show
|
||||
render_404
|
||||
# @subfield_content = @organization.org_subfields.order("priority")
|
||||
|
@ -30,6 +42,15 @@ class SubDomainsController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
def hide_sub_domain
|
||||
@subdomain.update_attribute(:hide, 1)
|
||||
end
|
||||
|
||||
def show_sub_domain
|
||||
@subdomain.update_attribute(:hide, 0)
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def find_org_subfield_and_subdomain
|
||||
@subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
<ul class="orgSubList">
|
||||
<li class="orgSubTree"></li>
|
||||
<li class="orgSubNum ml5 mr5">
|
||||
<div id="show_priority_<%= subdomain.id %>" ondblclick="edit_priority('#show_priority_<%= subdomain.id %>','#edit_priority_<%= subdomain.id %>');" class="subNumBlock" title="双击可编辑">
|
||||
<div id="show_domain_priority_<%= subdomain.id %>" ondblclick="edit_priority('#show_domain_priority_<%= subdomain.id %>','#edit_domain_priority_<%= subdomain.id %>');" class="subNumBlock" title="双击可编辑">
|
||||
<%= subdomain.priority %>
|
||||
</div>
|
||||
<div id="edit_priority_<%= subdomain.id %>" style="display:none; width:30px;">
|
||||
<input type="text" onblur="update_priority('#show_priority_<%= subdomain.id %>','#edit_priority_<%= subdomain.id %>','<%= subdomain.id %>',$(this).val());" style="width:20px;" value="<%= subdomain.priority %>"/>
|
||||
<div id="edit_domain_priority_<%= subdomain.id %>" style="display:none; width:30px;">
|
||||
<input type="text" onblur="domain_update_priority('#show_domain_priority_<%= subdomain.id %>','#edit_domain_priority_<%= subdomain.id %>','<%= subdomain.org_subfield.id %>','<%= subdomain.id %>',$(this).val());" style="width:20px;" value="<%= subdomain.priority %>"/>
|
||||
</div>
|
||||
</li>
|
||||
<li class="orgSubColumn">
|
||||
<div id="subsubdomain_show_<%= subdomain.id %>" class="subColumnControl"><%= subdomain.name %></div>
|
||||
<div id="subsubdomain_edit_<%= subdomain.id %>" style="display:none;">
|
||||
<input type="text" name="name" onblur="update_subsubdomain('#subsubdomain_show_<%= subdomain.id %>','#subsubdomain_edit_<%= subdomain.id %>','<%= subdomain.id %>',$(this).val());" value="<%= subdomain.name %>" style="width:70px;"/>
|
||||
<input type="text" name="name" onblur="update_subfield_subdomain('#subsubdomain_show_<%= subdomain.id %>','#subsubdomain_edit_<%= subdomain.id %>','<%= subdomain.org_subfield.id %>','<%= subdomain.id %>',$(this).val());" value="<%= subdomain.name %>" style="width:70px;"/>
|
||||
</div>
|
||||
</li>
|
||||
<li class="orgSubStatus">新增</li>
|
||||
|
@ -25,9 +25,9 @@
|
|||
<li class="orgListCatalog hidden"> -- </li>
|
||||
<%#= link_to "隐藏", hide_org_subsubdomain_organizations_path(subdomain), :method => 'post', :remote => true, :id => "hide_#{subdomain.id}", :class => "linkBlue fr mr5" %>
|
||||
<li class="orgSubOperation">
|
||||
<a href="javascript:void(0);" class="linkGrey fr ml5 mr10" onclick="hide($(this),'<%= subdomain.id %>');" id="hide_<%= subdomain.id %>"><%= subdomain.hide==0?"隐藏":"可见" %></a>
|
||||
<a href="javascript:void(0);" class="linkGrey fr ml5 mr10" onclick="hide_domain($(this),'<%= subdomain.org_subfield.id %>','<%= subdomain.id %>');" id="hide_<%= subdomain.id %>"><%= subdomain.hide==0?"隐藏":"可见" %></a>
|
||||
<span class="fr">|</span>
|
||||
<%= link_to "删除", org_subfield_sub_domain_path(subdomain), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkGrey fr ml5 mr5" %>
|
||||
<%= link_to "删除", org_subfield_sub_domain_path(subdomain, :org_subfield_id => subdomain.org_subfield.id), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkGrey fr ml5 mr5" %>
|
||||
<span class="fr">|</span>
|
||||
<a href="javascript:void(0);" class="linkGrey fr ml5 mr5" onclick="edit('#subsubdomain_show_<%= subdomain.id %>','#subsubdomain_edit_<%= subdomain.id %>');">编辑</a>
|
||||
</li>
|
||||
|
@ -35,3 +35,50 @@
|
|||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<script>
|
||||
function update_subfield_subdomain(show_id, edit_id, field_id, domain_id, input_value) {
|
||||
if ($(show_id).html().trim() != input_value.trim()) {
|
||||
if (confirm('确定修改为' + input_value + "?"))
|
||||
$.ajax({
|
||||
url: "/org_subfields/" + field_id + "/sub_domains/" + domain_id + "?name=" + input_value,
|
||||
type: 'put'
|
||||
});
|
||||
else{
|
||||
$(edit_id).children("input").val($(show_id).html().trim());
|
||||
}
|
||||
}
|
||||
$(show_id).show();
|
||||
$(edit_id).hide();
|
||||
// $(edit_id).focus();
|
||||
}
|
||||
|
||||
|
||||
function domain_update_priority(show_id, edit_id, field_id, domain_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() != ''){
|
||||
$.ajax({
|
||||
url: "/org_subfields/" + field_id + "/sub_domains/" + domain_id + "/domain_update_priority?priority=" + input_value,
|
||||
type: 'put'
|
||||
});
|
||||
}
|
||||
else{
|
||||
$(edit_id).children("input").val($(show_id).html().trim());
|
||||
}
|
||||
$(show_id).show();
|
||||
$(edit_id).hide();
|
||||
}
|
||||
|
||||
function hide_domain(content, field_id, domain_id){
|
||||
if (content.text() == '隐藏')
|
||||
$.ajax({
|
||||
url: "/org_subfields/" + field_id + "/sub_domains/" + domain_id + "/hide_sub_domain",
|
||||
type: "post"
|
||||
});
|
||||
else
|
||||
$.ajax({
|
||||
url: "/org_subfields/" + field_id + "/sub_domains/" + domain_id + "/show_sub_domain",
|
||||
type: "post"
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
<input type="radio" id="orgMng" value="Post" name="field_type" checked="checked"/>
|
||||
<label for="orgMng">帖子</label>
|
||||
</li>
|
||||
<li class="fl mr15">
|
||||
<input type="radio" id="orgMeb" value="Resource" name="field_type" />
|
||||
<label for="orgMeb">资源</label>
|
||||
</li>
|
||||
<!--<li class="fl mr15">-->
|
||||
<!--<input type="radio" id="orgMeb" value="Resource" name="field_type" />-->
|
||||
<!--<label for="orgMeb">资源</label>-->
|
||||
<!--</li>-->
|
||||
<li class="cl"></li>
|
||||
</ul>
|
||||
<div class="courseSendSubmit mr15"><a href="javascript:void(0);" class="sendSourceText" onclick="add_org_subfield_subdomain();hideModal()">确定</a></div>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
$("#org_subfield_list").html("");
|
||||
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', :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}) %>");
|
|
@ -0,0 +1,2 @@
|
|||
$("#hide_<%= @subfield.id %>").text("可见");
|
||||
$("#org_subfield_<%= @subfield.id %>").css("display", "none");
|
|
@ -0,0 +1,2 @@
|
|||
$("#hide_<%= @subfield.id %>").text("可见");
|
||||
$("#org_subfield_<%= @subfield.id %>").css("display", "none");
|
|
@ -0,0 +1,3 @@
|
|||
$("#subsubdomain_show_<%= @subdomain.id %>").html("<%= @subdomain.name %>");
|
||||
$("#sub_field_left_lists").html("");
|
||||
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");
|
|
@ -118,7 +118,7 @@ RedmineApp::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :sub_domains, :only => [:index, :new, :create, :show] do
|
||||
resources :sub_domains, :only => [:index, :new, :create, :show, :update, :destroy] do
|
||||
resources :sub_document_comments, :only => [:index, :new, :create, :show] do
|
||||
member do
|
||||
post 'add_reply'
|
||||
|
@ -135,6 +135,11 @@ RedmineApp::Application.routes.draw do
|
|||
collection do
|
||||
end
|
||||
member do
|
||||
match 'domain_update_sub_dir', :via => [:put]
|
||||
match 'domain_update_priority', :via => [:put]
|
||||
match 'domain_update_status', :via => [:post]
|
||||
post 'hide_sub_domain'
|
||||
post 'show_sub_domain'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue