Let page edit from can select layout
This commit is contained in:
		
							parent
							
								
									12de9d2514
								
							
						
					
					
						commit
						8da5323fd0
					
				| 
						 | 
					@ -4,5 +4,8 @@ class Component < Item
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  key :engine_name, String
 | 
					  key :engine_name, String
 | 
				
			||||||
  key :layout_name, String, :required => true
 | 
					  key :layout_name, String, :required => true
 | 
				
			||||||
     
 | 
					  key :layout_id, String, :required => true
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  belongs_to :layout
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					@ -44,6 +44,11 @@ class Item
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      self.parent_id = Item.find_by_name( self.parent_name ).id
 | 
					      self.parent_id = Item.find_by_name( self.parent_name ).id
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if self.layout_name
 | 
				
			||||||
 | 
					      self.layout_id = Layout.find_by_name( self.layout_name ).id
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					@ -3,6 +3,9 @@ class Layout
 | 
				
			||||||
   include MongoMapper::Document
 | 
					   include MongoMapper::Document
 | 
				
			||||||
   
 | 
					   
 | 
				
			||||||
   key :name, String, :required => true, :index => true
 | 
					   key :name, String, :required => true, :index => true
 | 
				
			||||||
 | 
					   key :description, String
 | 
				
			||||||
   key_i18n :content, String
 | 
					   key_i18n :content, String
 | 
				
			||||||
   
 | 
					   
 | 
				
			||||||
 | 
					   validates_format_of :name, :with => /^[a-zA-Z-_]+$/
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					@ -4,5 +4,8 @@ class Page < Item
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  key_i18n :content, String
 | 
					  key_i18n :content, String
 | 
				
			||||||
  key :layout_name, String, :required => true
 | 
					  key :layout_name, String, :required => true
 | 
				
			||||||
    
 | 
					  key :layout_id, String, :required => true
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  belongs_to :layout
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<p>
 | 
					<p>
 | 
				
			||||||
<%= f.label :layout_name, "Layout Name" %>
 | 
					<%= f.label :layout_name, "Layout Name" %>
 | 
				
			||||||
<%= f.text_field :layout_name, :class => 'text' %>
 | 
					<%= f.select :layout_name, Layout.all.map{ |l| [l.description, l.name] } %>
 | 
				
			||||||
</p>
 | 
					</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<p>
 | 
					<p>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,6 +3,11 @@
 | 
				
			||||||
<%= f.text_field :name, :class => 'text' %>
 | 
					<%= f.text_field :name, :class => 'text' %>
 | 
				
			||||||
</p>
 | 
					</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<p>
 | 
				
			||||||
 | 
					<%= f.label :description, "Description" %>
 | 
				
			||||||
 | 
					<%= f.text_field :description, :class => 'text' %>
 | 
				
			||||||
 | 
					</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<p id="content_zh_tw_block">
 | 
					<p id="content_zh_tw_block">
 | 
				
			||||||
<%= f.label "content_zh_tw", "Content (zh_tw)" %>
 | 
					<%= f.label "content_zh_tw", "Content (zh_tw)" %>
 | 
				
			||||||
<%= f.text_area "content_zh_tw", :size => '100x30' %>
 | 
					<%= f.text_area "content_zh_tw", :size => '100x30' %>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@
 | 
				
			||||||
<% @layouts.each do |layout| %>
 | 
					<% @layouts.each do |layout| %>
 | 
				
			||||||
  <tr>
 | 
					  <tr>
 | 
				
			||||||
    <td><%= layout.name %></td>
 | 
					    <td><%= layout.name %></td>
 | 
				
			||||||
 | 
					    <td><%= layout.description %></td>
 | 
				
			||||||
    <td><%= link_to t(:edit), edit_admin_layout_path(layout) %></td>
 | 
					    <td><%= link_to t(:edit), edit_admin_layout_path(layout) %></td>
 | 
				
			||||||
    <td><%= link_to t(:delete), admin_layout_path(layout), :confirm => 'Are you sure?', :method => :delete %></td>
 | 
					    <td><%= link_to t(:delete), admin_layout_path(layout), :confirm => 'Are you sure?', :method => :delete %></td>
 | 
				
			||||||
  </tr>
 | 
					  </tr>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<p>
 | 
					<p>
 | 
				
			||||||
<%= f.label :layout_name, "Layout Name" %>
 | 
					<%= f.label :layout_name, "Layout Name" %>
 | 
				
			||||||
<%= f.text_field :layout_name, :class => 'text' %>
 | 
					<%= f.select :layout_name, Layout.all.map{ |l| [l.description, l.name] } %>
 | 
				
			||||||
</p>
 | 
					</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<p id="content_zh_tw_block">
 | 
					<p id="content_zh_tw_block">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue