diff --git a/app/controllers/personal_diplomas_controller.rb b/app/controllers/personal_diplomas_controller.rb index 146ec1d..1329810 100644 --- a/app/controllers/personal_diplomas_controller.rb +++ b/app/controllers/personal_diplomas_controller.rb @@ -40,4 +40,35 @@ class PersonalDiplomasController < ApplicationController {"plugin_datas"=>plugin.get_plugin_data(fields_to_show)} end + + def get_fields_for_index + @page = Page.find(params[:page_id]) rescue nil + @fields_to_show = [ + "name", + "school_name", + "duration", + "country", + "department", + "degree", + "url" + ] + @fields_to_show = @fields_to_show.map{|fs| [t("personal_diploma.#{fs}"), fs]} + @default_fields_to_show = [ + "paper_title", + "journal_title", + "authors", + "year", + "issue_no", + "vol_no", + "level_type" + ] + render :layout => false + end + + def save_index_fields + page = Page.find(params[:page_id]) rescue nil + page.custom_array_field = params[:keys] + page.save + render :json => {"success" => true}.to_json + end end \ No newline at end of file diff --git a/app/views/personal_diplomas/get_fields_for_index.html.erb b/app/views/personal_diplomas/get_fields_for_index.html.erb new file mode 100644 index 0000000..1a7e4df --- /dev/null +++ b/app/views/personal_diplomas/get_fields_for_index.html.erb @@ -0,0 +1,48 @@ +<% if !@page.nil? %> +
+
+ +
+ +
+ +
+ +
+ <%= select_tag "fields_to_show_for_pp", options_for_select(@fields_to_show), prompt: "---Select something---" %> +
+
+ Add Field + + +
+
+ +<% else %> +

Page not found.

+<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 6fdafb3..ea3a492 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,5 +26,7 @@ Rails.application.routes.draw do end end + get "/xhr/personal_diploma/get_fields_for_index" => "personal_diplomas#get_fields_for_index" + post "/xhr/personal_diploma/save_index_fields" => "personal_diplomas#save_index_fields" end end diff --git a/lib/personal_diploma/engine.rb b/lib/personal_diploma/engine.rb index ad9325f..4f1ecaf 100644 --- a/lib/personal_diploma/engine.rb +++ b/lib/personal_diploma/engine.rb @@ -4,7 +4,7 @@ module PersonalDiploma OrbitApp.registration "PersonalDiploma",:type=> 'ModuleApp' do module_label 'module_name.personal_journal' base_url File.expand_path File.dirname(__FILE__) - personal_plugin :enable => true, :sort_number => '40', :app_name=>"Diploma", :intro_app_name=>"PersonalDiplomaIntro",:path=>"/plugin/personal_diploma/profile",:front_path=>"/profile",:admin_path=>"/admin/diplomas",:i18n=>'module_name.personal_diploma', :module_app_name=>'PersonalDiploma' + personal_plugin :enable => true, :sort_number => '40', :app_name=>"Diploma", :intro_app_name=>"PersonalDiplomaIntro",:path=>"/plugin/personal_diploma/profile",:front_path=>"/profile",:admin_path=>"/admin/diplomas",:i18n=>'module_name.personal_diploma', :field_modifiable => true, :module_app_name=>'PersonalDiploma' version "0.1" desktop_enabled true