diff --git a/app/controllers/admin/page_contents_controller.rb b/app/controllers/admin/page_contents_controller.rb
index 2c61904..ca05003 100644
--- a/app/controllers/admin/page_contents_controller.rb
+++ b/app/controllers/admin/page_contents_controller.rb
@@ -1,9 +1,10 @@
class Admin::PageContentsController < OrbitAdminController
+ before_action ->(module_app = @app_title) { set_variables module_app }
def index
- @table_fields = [:page_id, :name,:version,:update_at,:last_modified]
+ @table_fields = [:page_id, :name,:version,:update_at,:last_modified, :category]
@filter_fields = {}
@pages = Page.where(:module=>"page_content").order_by(sort)
-
+ @categories = @module_app.categories.collect{|c| [c.title, c.id]}
@pages = search_data(@pages,[:name, :page_id]).page(params[:page]).per(10)
render :partial => "index" if request.xhr?
@@ -35,6 +36,17 @@ class Admin::PageContentsController < OrbitAdminController
@page_contexts = @page.page_contexts.desc(:version)
end
+ def save_category
+ page_id = params[:page_id]
+ category_id = params[:category_id]
+ page = Page.find(page_id) rescue nil
+ if !page.nil?
+ page.category_id = category_id
+ page.save
+ end
+ render :json => {"success" => true}.to_json
+ end
+
private
def update_params
diff --git a/app/views/admin/page_contents/_index.html.erb b/app/views/admin/page_contents/_index.html.erb
index cf2c727..351a397 100644
--- a/app/views/admin/page_contents/_index.html.erb
+++ b/app/views/admin/page_contents/_index.html.erb
@@ -23,6 +23,10 @@
<%= page.page_contexts.last.version rescue nil %> |
<%= format_value page.page_contexts.last.updated_at rescue nil %> |
<%= User.find(page.page_contexts.last.update_user_id).user_name rescue nil %> |
+
+ <%= select_tag("category_id",options_for_select(@categories, (page.category_id.to_s rescue "")), prompt: "Select a category", class: "category_select") %>
+
+ |
<% end %>
@@ -32,4 +36,38 @@
content_tag :div, class: "bottomnav clearfix" do
content_tag :div, paginate(@pages), class: "pagination pagination-centered"
end
-%>
\ No newline at end of file
+%>
+
+
\ No newline at end of file
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 34fee99..b234b55 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -3,6 +3,7 @@ en:
page_content:
page: Page content
save: Save
+ all: All
create_page_content_success: Page content was successfully created
editing_page_content: Editing page content
frontend:
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index b803089..a51ee4e 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -4,6 +4,7 @@ zh_tw:
context: 內文
create_page_content_success: 建立頁面內容成功
editing_page_content: 編輯頁面內容
+ all: All
frontend:
page: 頁面前台
update_page_content_success: 更新頁面內容成功
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 28c8a59..9c581fe 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -9,6 +9,7 @@ Rails.application.routes.draw do
get "view" => "page_contents#view"
end
end
+ post "/page_contents/save_category" => "page_contents#save_category"
end
end
diff --git a/lib/page_content/engine.rb b/lib/page_content/engine.rb
index ee111c3..baaa5e6 100644
--- a/lib/page_content/engine.rb
+++ b/lib/page_content/engine.rb
@@ -6,12 +6,27 @@ module PageContent
base_url File.expand_path File.dirname(__FILE__)
frontend_enabled
authorizable
+ categorizable
side_bar do
head_label_i18n 'page_content.page', icon_class: "icons-newspaper"
available_for "users"
active_for_controllers (['admin/page_contents'])
head_link_path "admin_page_contents_path"
+
+ context_link 'page_content.all',
+ :link_path=>"admin_page_contents_path" ,
+ :priority=>1,
+ :active_for_action=>{'admin/page_contents'=>"index"},
+ :available_for => 'users'
+
+ context_link 'categories',
+ :link_path=>"admin_module_app_categories_path" ,
+ :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'page_content').id}",
+ :priority=>3,
+ :active_for_action=>{'admin/page_contents'=>'categories'},
+ :active_for_category => 'PageContent',
+ :available_for => 'managers'
end
end
end