This commit is contained in:
邱博亞 2023-03-01 09:56:23 +08:00
parent a62400bb07
commit 9e54e1794c
2 changed files with 9 additions and 6 deletions

View File

@ -4,12 +4,15 @@ class PersonalJournalsController < ApplicationController
params = OrbitHelper.params
page_data_count = OrbitHelper.page_data_count
page = OrbitHelper.page
custom_data_field = page.custom_data_field || {}
journal_paper_query = JournalPaper.sort_for_frontend
if (!page.year.blank? rescue false)
journal_paper_query = journal_paper_query.where(:year.in => page.year.to_a )
page_year = custom_data_field[:year]
page_journal_type = custom_data_field[:journal_type]
if (page_year.present?)
journal_paper_query = journal_paper_query.where(:year.in => page_year.to_a )
end
if (!page.journal_type.blank? rescue false)
journal_paper_query = journal_paper_query.where(:journal_type_ids.in => page.journal_type.to_a )
if (page_journal_type.present?)
journal_paper_query = journal_paper_query.where(:journal_type_ids.in => page_journal_type.to_a )
end
journal_papers = journal_paper_query.page(OrbitHelper.params[:page_no]).per(page_data_count)
if params[:layout_type]

View File

@ -7,8 +7,8 @@ module PersonalJournal
personal_plugin :enable => true, :sort_number => '5', :app_name=>"JournalPaper", :intro_app_name=>"JournalPaperlIntro",:path=>"/plugin/personal_journal/profile",:front_path=>"/profile",:admin_path=>"/admin/journal_papers/",:i18n=>'module_name.journal_paper', :module_app_name=>'PersonalJournal', :one_line_title => true, :field_modifiable => true, :analysis => true, :analysis_path => "/admin/journal_papers/analysis"
begin
page_custom_option({year: '<%= f.select :year, (1930...(DateTime.now.year+5)).to_a.reverse, {:include_blank => ""}, {multiple: true} %>'})
page_custom_option({journal_type: '<% JournalType.all.each do |journal_type| %><label><%= f.check_box :journal_type, {multiple: true}, journal_type.id.to_s, nil %><%= journal_type.title %></label><% end %>'})
page_custom_option({year: '<%= select_tag "#{f.object_name}[custom_data_field][year][]", options_for_select((1930...(DateTime.now.year+5)).to_a.reverse, (f.object.custom_data_field[:year].to_a rescue [])), {multiple: true} %>'})
page_custom_option({journal_type: '<% JournalType.all.each do |journal_type| %><label><%= check_box_tag "#{f.object_name}[custom_data_field][journal_type][]", journal_type.id.to_s, (f.object.custom_data_field[:journal_type].include?(journal_type.id.to_s) rescue false) %><%= journal_type.title %></label><% end %>'})
rescue => e
puts ['there_was_no_page_custom_option',e]
end