From 9e54e1794ce3b43024c0c4bdde2084e6e1312f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Wed, 1 Mar 2023 09:56:23 +0800 Subject: [PATCH] Fix bug. --- app/controllers/personal_journals_controller.rb | 11 +++++++---- lib/personal_journal/engine.rb | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/controllers/personal_journals_controller.rb b/app/controllers/personal_journals_controller.rb index be5d340..0f41aa5 100644 --- a/app/controllers/personal_journals_controller.rb +++ b/app/controllers/personal_journals_controller.rb @@ -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] diff --git a/lib/personal_journal/engine.rb b/lib/personal_journal/engine.rb index 86c4a47..423f8f7 100644 --- a/lib/personal_journal/engine.rb +++ b/lib/personal_journal/engine.rb @@ -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| %><% 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| %><% end %>'}) rescue => e puts ['there_was_no_page_custom_option',e] end