在管理员界面中,添加组织的编辑和删除功能。
This commit is contained in:
parent
95b071a8f7
commit
9baeb850a3
|
@ -37,6 +37,19 @@ class OrganizationsController < ApplicationController
|
|||
@organization = Organization.new
|
||||
render :layout => 'new_base'
|
||||
end
|
||||
|
||||
def edit
|
||||
@organization = Organization.find(params[:id])
|
||||
end
|
||||
|
||||
def destroy
|
||||
@organization = Organization.find(params[:id])
|
||||
@organization.destroy
|
||||
respond_to do |format|
|
||||
format.html{ redirect_to admin_organization_path }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@organization = Organization.new
|
||||
@organization.name = params[:organization][:name]
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
|
||||
<% @nav_dispaly_organization_label = 1
|
||||
@nav_dispaly_forum_label = 1 %>
|
||||
<%= error_messages_for 'organization' %>
|
||||
<div class="organization_r_h02">
|
||||
<h2 class="organization_h2">编辑组织</h2>
|
||||
</div>
|
||||
<div class="ml15 mr15" id="orgContent_1">
|
||||
<!--<div class="orgLogo mb10"><a href="javascript:void(0);"><img src="images/0" width="55" height="55" alt="组织logo" class="mr10 logoBorder fl ml10" /></a>-->
|
||||
<!--<a href="javascript:void(0);" class="logoEnter fl linkGrey4">上传图片</a>-->
|
||||
<%#= form_for( @organization,{:controller => 'organizations',:action => 'update',:id=>@organization,:html=>{:id=>'update_org_form',:method=>'put'}}) do %>
|
||||
<%= labelled_form_for @organization, :html => {:id => "edit_organization_#{@organization.id}"} do |f|%>
|
||||
<%= render :partial=>"new_org_avatar_form",:locals=> {source:@organization} %>
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--</div>-->
|
||||
<div class="orgRow mb10"><span class="c_red">* </span>组织名称:<input type="text" name="organization[name]" id="organization_name" maxlength="100" onblur="check_uniq(<%=@organization.id %>);" onfocus="$('#check_name_hint').hide()" class="orgNameInput" value="<%= @organization.name%>" />
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div style="margin-left: 80px " id="check_name_hint"></div>
|
||||
<div class="orgRow mb10"><span class="ml10">组织描述:</span><textarea type="text" name="organization[description]" class="orgDes" id="org_desc" placeholder="最多3000个汉字(或6000个英文字符)"><%= @organization.description%></textarea>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div style="margin-left: 80px " id="check_desc_hint"></div>
|
||||
<!--<div class="orgRow mb10"><span class="ml10">组织URL:</span>-->
|
||||
<!--<div class="w607 fr">https://-->
|
||||
<!--<input type="text" name="organization[domain]" value="<%= @organization.domain%>" class="orgUrlInput" />-->
|
||||
<!--.trustie.net<a href="javascript:void(0);" class="linkBlue ml15" style="text-decoration:underline;">申请</a>-->
|
||||
<!--<p id="apply_hint"></p></div>-->
|
||||
<!--<!–class="c_green f12" 您的申请已提交,系统会以消息的形式通知您结果 –>-->
|
||||
<!--</div>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<div class="orgRow mb10 mt5"><span style="margin-left:38px;" >公开 : </span>
|
||||
<input type="checkbox" name="organization[is_public]" <%= @organization.is_public ? 'checked': ''%> class="ml3" />
|
||||
</div>
|
||||
<a href="javascript:void(0);" class="saveBtn ml80 db fl" onclick="update_org(<%=@organization.id %>);">保存</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<% html_title(l(:label_organization_new)) -%>
|
||||
|
||||
<script>
|
||||
function update_org(id){
|
||||
check_uniq(id);
|
||||
if( $checkName){
|
||||
$("#edit_organization_"+id).submit();
|
||||
}
|
||||
}
|
||||
//新建组织
|
||||
//验证组织名称
|
||||
function regex_organization_name()
|
||||
{
|
||||
var name = $.trim($("#organization_name").val());
|
||||
if(name.length == 0)
|
||||
{
|
||||
$("#organization_name_notice").html('<span class="c_red">名字不能为空<span>').show();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#organization_name_notice").html('').hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
var $checkName = false;
|
||||
|
||||
function check_uniq(dom){
|
||||
if($("#organization_name").val().trim() == ""){
|
||||
$("#organization_name_notice").html('<span class="c_red">名字不能为空<span>').show();
|
||||
return;
|
||||
}
|
||||
$.get(
|
||||
'<%= check_uniq_organizations_path%>'+'?org_name='+$("#organization_name").val().trim()
|
||||
)
|
||||
}
|
||||
|
||||
//提交新建项目
|
||||
function submit_new_organization()
|
||||
{
|
||||
$.get(
|
||||
'<%= check_uniq_organizations_path%>'+'?org_name='+$("#organization_name").val().trim()
|
||||
)
|
||||
if(regex_organization_name() && $checkName)
|
||||
{
|
||||
$("#new_organization").submit();
|
||||
}
|
||||
}
|
||||
|
||||
$(function(){
|
||||
$('#organization_new_type').change(function(){
|
||||
var type = $('#organization_new_type').val();
|
||||
if(type == '1'){
|
||||
$(this).next().html("<%= l(:label_type_des_development)%>");
|
||||
}
|
||||
else if(type == '2'){
|
||||
$(this).next().html("<%= l(:label_type_des_research)%>");
|
||||
}
|
||||
else if(type == '3'){
|
||||
$(this).next().html("<%= l(:label_type_des_friend)%>");
|
||||
}
|
||||
// var p1=$(this).children('option:selected').val("研讨模式:面向小组研究,支持任务分工、论坛交流、资源分享等。");//这就是selected的值
|
||||
// var p2=$('#param2').val();//获取本页面其他标签的值
|
||||
})
|
||||
|
||||
})
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue