1.在栏目表中增加field_type(类型)字段;

2.在组织配置-》栏目,增加栏目类型。
This commit is contained in:
ouyangxuhua 2015-12-09 17:24:59 +08:00
parent 78fb8b6254
commit 2f7260cba2
5 changed files with 30 additions and 3 deletions

View File

@ -3,7 +3,7 @@ class OrgSubfieldsController < ApplicationController
@subfield = OrgSubfield.create(:name => params[:name])
@organization = Organization.find(params[:organization_id])
@organization.org_subfields << @subfield
@subfield.update_attributes(:priority => @subfield.id)
@subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type])
end
def destroy

View File

@ -1,4 +1,5 @@
$("#org_subfield_list").html("");
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',:locals => {:subfields => @organization.org_subfields }) %>");
$("#sub_field_left_lists").html("");
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");
$("#subfield_name").val("");

View File

@ -114,7 +114,18 @@
<p class="fontBlue fb mb5">新增栏目</p>
<%= form_tag url_for(:controller => 'org_subfields', :action => 'create', :organization_id => @organization.id), :id=> 'add_subfield_form',:remote => true do %>
<input type="text" id="subfield_name" name="name" placeholder="栏目名称" class="orgAddSearch mb20" />
<div class="cl"></div>
<ul class="orgAddRole">
<li class="fontGrey3 fb mb10">栏目类型</li>
<li>
<input type="radio" id="orgMng" value="Post" name="field_type" checked="checked"/>
<label for="orgMng">帖子</label>
</li>
<li>
<input type="radio" id="orgMeb" value="Resource" name="field_type" />
<label for="orgMeb">资源</label>
</li>
</ul>
<div class="cl"></div>
<a href="javascript:void(0);" class="saveBtn db fl mt10" onclick="add_org_subfield();">确定</a>
<% end %>
</div>

View File

@ -0,0 +1,5 @@
class AddTypeToOrgSubfields < ActiveRecord::Migration
def change
add_column :org_subfields, :field_type, :string
end
end

View File

@ -0,0 +1,10 @@
class SetTypeForOrgSubfields < ActiveRecord::Migration
def up
OrgSubfield.all.each do |field|
field.update_attribute(:field_type, "Post")
end
end
def down
end
end