diff --git a/app/controllers/personal_conferences_controller.rb b/app/controllers/personal_conferences_controller.rb index c705932..e75c9ec 100644 --- a/app/controllers/personal_conferences_controller.rb +++ b/app/controllers/personal_conferences_controller.rb @@ -4,6 +4,7 @@ class PersonalConferencesController < ApplicationController writing_conferences = WritingConference.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) page = Page.where(:page_id => params[:page_id]).first rescue nil if page.custom_string_field == "table" + fields_to_show = page.custom_array_field rescue [] fields_to_show = [ "authors", "paper_title", @@ -11,7 +12,7 @@ class PersonalConferencesController < ApplicationController "location", "paper_types", "paper_levels" - ] + ] if fields_to_show.blank? else fields_to_show = [ "year", @@ -34,6 +35,8 @@ class PersonalConferencesController < ApplicationController t << {"value" => ( !writing_conference.conference_paper_levels.blank? ? "(#{writing_conference.conference_paper_levels.collect{|x| x.title}.join(', ')})" : nil)} when "paper_types" t << {"value" => ( !writing_conference.conference_paper_levels.blank? ? "(#{writing_conference.conference_paper_levels.collect{|x| x.title}.join(', ')})" : nil)} + when "publication_date" + t << {"value" => (writing_conference.send(fs).strftime("%Y/%m/%d") rescue "")} else t << {"value" => writing_conference.send(fs)} end @@ -87,4 +90,45 @@ class PersonalConferencesController < 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 = [ + "year", + "authors", + "paper_title", + "conference_title", + "location", + "period_start_date", + "period_end_date", + "paper_type", + "paper_level", + "sponsor", + "author_type", + "number_of_authors", + "abstract", + "url", + "publication_date", + "isbn", + "isi_number" , + "language" + ] + @fields_to_show = @fields_to_show.map{|fs| [t("personal_conference.#{fs}"), fs]} + @default_fields_to_show = [ + "authors", + "paper_title", + "conference_title", + "location", + "paper_types", + "paper_levels" + ] + 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/models/writing_conference.rb b/app/models/writing_conference.rb index 587518e..0e42d39 100644 --- a/app/models/writing_conference.rb +++ b/app/models/writing_conference.rb @@ -69,14 +69,18 @@ class WritingConference def self.get_plugin_datas_to_member(datas) page = Page.where(:module => "personal_conference").first rescue nil if !page.nil? && page.custom_string_field == "table" - fields_to_show = [ - "authors", - "paper_title", - "conference_title", - "location", - "paper_types", - "paper_levels" - ] + if !page.custom_array_field.blank? + fields_to_show = page.custom_array_field + else + fields_to_show = [ + "authors", + "paper_title", + "conference_title", + "location", + "paper_types", + "paper_levels" + ] + end else fields_to_show = [ "year", diff --git a/app/views/personal_conferences/get_fields_for_index.html.erb b/app/views/personal_conferences/get_fields_for_index.html.erb new file mode 100644 index 0000000..b370d20 --- /dev/null +++ b/app/views/personal_conferences/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 afec906..0175077 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,5 +30,7 @@ Rails.application.routes.draw do resources :conference_author_types resources :tags end + get "/xhr/personal_conference/get_fields_for_index" => "personal_conferences#get_fields_for_index" + post "/xhr/personal_conference/save_index_fields" => "personal_conferences#save_index_fields" end end diff --git a/lib/personal_conference/engine.rb b/lib/personal_conference/engine.rb index 8825934..5e1393b 100644 --- a/lib/personal_conference/engine.rb +++ b/lib/personal_conference/engine.rb @@ -4,7 +4,7 @@ module PersonalConference OrbitApp.registration "PersonalConference",:type=> 'ModuleApp' do module_label 'module_name.personal_conference' base_url File.expand_path File.dirname(__FILE__) - personal_plugin :enable => true, :sort_number => '6', :app_name=>"WritingConference", :intro_app_name=>"PersonalConferenceIntro",:path=>"/plugin/personal_conference/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_conferences",:i18n=>'module_name.personal_conference', :module_app_name=>'PersonalConference', :one_line_title => true + personal_plugin :enable => true, :sort_number => '6', :app_name=>"WritingConference", :intro_app_name=>"PersonalConferenceIntro",:path=>"/plugin/personal_conference/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_conferences",:i18n=>'module_name.personal_conference', :module_app_name=>'PersonalConference', :one_line_title => true, :field_modifiable => true version "0.1" desktop_enabled true