Fix bugs.(Add filter_by_tags and Add criteria_title to index)

This commit is contained in:
BoHung Chiu 2020-06-11 18:57:15 +08:00
parent c028b62f05
commit e46db67df3
2 changed files with 4 additions and 2 deletions

View File

@ -7,6 +7,7 @@ class Admin::EPapersController < OrbitAdminController
@filter_fields.delete(:status) @filter_fields.delete(:status)
@papers = EPaperTopic.order_by(sort) @papers = EPaperTopic.order_by(sort)
.with_categories(filters("category")) .with_categories(filters("category"))
.with_tags(filters("tag"))
@papers = search_data(@papers,[:title]).page(params[:page]).per(10) @papers = search_data(@papers,[:title]).page(params[:page]).per(10)

View File

@ -1,10 +1,11 @@
class EPapersController < ApplicationController class EPapersController < ApplicationController
def index def index
topics = EPaperTopic.filter_by_categories.desc(:period) topics = EPaperTopic.filter_by_categories.filter_by_tags.desc(:period)
data = topics.collect do |topic| data = topics.collect do |topic|
{ {
"title" => topic.title, "title" => topic.title,
"criteria_title" => topic.criteria_title,
"link_to_show" => OrbitHelper.url_to_show(topic.to_param), "link_to_show" => OrbitHelper.url_to_show(topic.to_param),
"description" => topic.description, "description" => topic.description,
"img_url" => topic.image.url, "img_url" => topic.image.url,
@ -144,7 +145,7 @@ class EPapersController < ApplicationController
end end
def category_wise_articles def category_wise_articles
topics = EPaperTopic.filter_by_widget_categories.desc(:period) topics = EPaperTopic.filter_by_widget_categories.filter_by_tags(OrbitHelper.widget_tags).desc(:period)
data = Array(topics).compact.collect do |topic| data = Array(topics).compact.collect do |topic|
{ {
"title" => topic.title, "title" => topic.title,