forked from saurabh/personal-journal
Update personal_journals_controller.rb
fix paper_type error
This commit is contained in:
parent
b63aebc633
commit
2b2b1704f6
|
@ -1,12 +1,8 @@
|
||||||
class PersonalJournalsController < ApplicationController
|
class PersonalJournalsController < ApplicationController
|
||||||
def search_all_words(target,word)
|
|
||||||
target=target.upcase
|
|
||||||
words=word.upcase.split(' ')
|
|
||||||
return words.select{|value| target.include? value}==words
|
|
||||||
end
|
|
||||||
def index
|
def index
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
journal_papers = JournalPaper.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
page_data_count = OrbitHelper.page_data_count
|
||||||
|
journal_papers = JournalPaper.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(page_data_count)
|
||||||
page = Page.where(:page_id => params[:page_id]).first rescue nil
|
page = Page.where(:page_id => params[:page_id]).first rescue nil
|
||||||
if page.custom_string_field == "table"
|
if page.custom_string_field == "table"
|
||||||
fields_to_show = page.custom_array_field rescue []
|
fields_to_show = page.custom_array_field rescue []
|
||||||
|
@ -40,6 +36,8 @@ class PersonalJournalsController < ApplicationController
|
||||||
journal_papers_show = journal_papers_temp.select {|value| search_all_words((value.send("publication_date").strftime("%Y/%m/%d") rescue ""), params[:keywords])}
|
journal_papers_show = journal_papers_temp.select {|value| search_all_words((value.send("publication_date").strftime("%Y/%m/%d") rescue ""), params[:keywords])}
|
||||||
when "author_type"
|
when "author_type"
|
||||||
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.journal_paper_author_types.collect{|jat| jat.title}.join(", "), params[:keywords])}
|
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.journal_paper_author_types.collect{|jat| jat.title}.join(", "), params[:keywords])}
|
||||||
|
when "paper_types"
|
||||||
|
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.journal_paper_type.collect{|x| x.title}.join(", "), params[:keywords])}
|
||||||
when "language"
|
when "language"
|
||||||
journal_papers_show = journal_papers_temp.select {|value| search_all_words((!value.language.nil? ? t("#{value.language}") : ""), params[:keywords])}
|
journal_papers_show = journal_papers_temp.select {|value| search_all_words((!value.language.nil? ? t("#{value.language}") : ""), params[:keywords])}
|
||||||
else
|
else
|
||||||
|
@ -50,8 +48,8 @@ class PersonalJournalsController < ApplicationController
|
||||||
else
|
else
|
||||||
page_to_show = params[:page_no].to_i
|
page_to_show = params[:page_no].to_i
|
||||||
end
|
end
|
||||||
journal_papers = journal_papers_show[(page_to_show-1)*OrbitHelper.page_data_count...page_to_show*OrbitHelper.page_data_count]
|
journal_papers = journal_papers_show[(page_to_show-1)*page_data_count...page_to_show*page_data_count]
|
||||||
journal_papers_total_pages = (journal_papers_show.length/OrbitHelper.page_data_count.to_f).ceil
|
journal_papers_total_pages = (journal_papers_show.length/page_data_count.to_f).ceil
|
||||||
else
|
else
|
||||||
journal_papers_total_pages = journal_papers.total_pages
|
journal_papers_total_pages = journal_papers.total_pages
|
||||||
end
|
end
|
||||||
|
@ -73,7 +71,7 @@ class PersonalJournalsController < ApplicationController
|
||||||
when "author_type"
|
when "author_type"
|
||||||
t << {"value" => (journal_paper.journal_paper_author_types.collect{|jat| jat.title}.join(", ") rescue "")}
|
t << {"value" => (journal_paper.journal_paper_author_types.collect{|jat| jat.title}.join(", ") rescue "")}
|
||||||
when "paper_types"
|
when "paper_types"
|
||||||
t << {"value" => ( !journal_paper.paper_types.blank? ? "(#{journal_paper.paper_types.collect{|x| x.title}.join(', ')})" : nil)}
|
t << {"value" => ( !journal_paper.journal_paper_type.blank? ? "(#{journal_paper.journal_paper_type.collect{|x| x.title}.join(', ')})" : nil)}
|
||||||
when "language"
|
when "language"
|
||||||
t << {"value" => (!journal_paper.language.nil? ? t("#{journal_paper.language}") : "")}
|
t << {"value" => (!journal_paper.language.nil? ? t("#{journal_paper.language}") : "")}
|
||||||
else
|
else
|
||||||
|
@ -185,4 +183,10 @@ class PersonalJournalsController < ApplicationController
|
||||||
page.save
|
page.save
|
||||||
render :json => {"success" => true}.to_json
|
render :json => {"success" => true}.to_json
|
||||||
end
|
end
|
||||||
|
private
|
||||||
|
def search_all_words(target,word)
|
||||||
|
target=target.upcase
|
||||||
|
words=word.upcase.split(' ')
|
||||||
|
return words.select{|value| target.include? value}==words
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue