Merge branch 'master' into 'master'

add honor types filter

let honor index page return honors by types

See merge request !1
This commit is contained in:
EricTYL 2019-11-04 11:07:48 +08:00
commit f76098aad6
3 changed files with 64 additions and 47 deletions

View File

@ -1,7 +1,16 @@
class PersonalHonorsController < ApplicationController
def index
params = OrbitHelper.params
filter_value = params[:honors_filter_value]
honors = nil
if filter_value.nil? || filter_value == t("personal_honor.honor_types_all") || filter_value.empty?
honors = Honor.where(:award_name.ne => nil).or(:award_name.ne => "").sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
else
honor_type_id = HonorType.or({ 'title.en' => filter_value }, { 'title.zh_tw' => filter_value }).first.id
honors = Honor.where(honor_type_id: honor_type_id).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
end
fields_to_show = Page.where(:page_id => params[:page_id]).first.custom_array_field rescue []
if fields_to_show.blank?
@ -45,9 +54,15 @@ class PersonalHonorsController < ApplicationController
}
end
current_locale = I18n.locale
honor_types = HonorType.all.pluck(:title).map { |title| { 'honor_type' => title[current_locale] } }
honor_types.unshift({ 'honor_type' => t("personal_honor.honor_types_all") })
{
"honors" => honor_list,
"extras" => {"widget-title" => t("module_name.personal_honor")},
"honor_types" => honor_types,
"extras" => { "widget-title" => t("module_name.personal_honor"),
"url" => '/' + current_locale.to_s + params[:url] },
"headers" => headers,
"total_pages" => honors.total_pages
}

View File

@ -9,6 +9,7 @@ en:
awarding_unit : "Awarding Unit"
honor_category : "Honor Category"
honor_type: "Honor Category"
honor_types_all: "All Honor Types"
extracted_chapters : "Extracted Chapters"
publishers : "Publishers"
honoree: "Honoree"

View File

@ -9,6 +9,7 @@ zh_tw:
awarding_unit : "頒獎單位"
honor_category : "類別"
honor_type: "類別"
honor_types_all: "所有榮譽項目"
honoree: "受獎人"
authors : "作者"
tags : "領域"