diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index a7a9a76f..5ac939c6 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -3,7 +3,7 @@ class Admin::PagesController < ApplicationController layout "admin" def index - @pages = Page.all( :conditions => { :parent_page_id => "root" } ) + @pages = Page.all( :conditions => { :parent_page_name => params[:parent] || "root" } ) end def show @@ -15,7 +15,7 @@ class Admin::PagesController < ApplicationController def new @page = Page.new @page.is_published = true - @page.parent_page_id = params[:parent_page_id] + @page.parent_page_name = params[:parent_page_name] end def edit @@ -27,7 +27,7 @@ class Admin::PagesController < ApplicationController if @page.save flash[:notice] = 'Page was successfully created.' - redirect_to admin_pages_url + redirect_to admin_pages_url( :parent_page_name => @page.parent_page_name ) else render :action => "new" end diff --git a/app/models/page.rb b/app/models/page.rb index 25b87a2a..5210eadb 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -2,19 +2,21 @@ class Page include MongoMapper::Document key :name, String - key :parent_page_id, String + key :parent_page_name, String + key_i18n :title, String key_i18n :content, String key :layout_id, String key :layout_name, String - key :use_engine, String key :external_link, String key :position, Integer key :is_published, Boolean + key :is_component, Boolean + key :component_name, String + belongs_to :layout - has_many :children, :class_name => 'Page', :foreign_key => 'parent_page_id' validates_presence_of :name validates_presence_of :position @@ -42,8 +44,8 @@ class Page self.position = (max_page)? max_page.position.to_i + 1 : 1 end - if self.parent_page_id.blank? - self.parent_page_id = "root" + if self.parent_page_name.blank? + self.parent_page_name = "root" end end diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index 4b52ec7e..d89e8dc6 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -3,6 +3,22 @@ <%= f.text_field :name, :class => 'text' %>

+

+<%= f.label :title, "Title en" %> +<%= f.text_field :title_en, :class => 'text' %> +

+ + +

+<%= f.label :title, "Title zh_tw" %> +<%= f.text_field :title_zh_tw, :class => 'text' %> +

+ +

+<%= f.label :parent_page_name, "Parent Page Name" %> +<%= f.text_field :parent_page_name, :class => 'text' %> +

+

<%= f.label :layout_name, "Layout Name" %> <%= f.text_field :layout_name, :class => 'text' %> @@ -22,18 +38,18 @@

<%= f.label :is_published, "Is Published" %> -<%= f.radio_button :is_published, 1 %>Yes <%= f.radio_button :is_published, 0 %> No +<%= f.radio_button :is_published, true %>Yes <%= f.radio_button :is_published, false %> No +

+ +

+ <%= f.label :is_component, "Is component" %> +<%= f.radio_button :is_component, true %>Yes <%= f.radio_button :is_component, false %> No

<%= f.label :external_link, "External Link" %> <%= f.text_field :external_link %>

- -

-<%= f.label :use_engine, "Use Engine" %> -<%= f.text_field :use_engine %> -

<% content_for :page_specific_javascript do %>