add index

This commit is contained in:
邱博亞 2023-03-01 08:38:01 +08:00
parent a73145f038
commit a62400bb07
3 changed files with 35 additions and 1 deletions

View File

@ -12,7 +12,10 @@ class PersonalJournalsController < ApplicationController
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)
page = Page.where(page_id: params[:page_id]).first rescue nil
if params[:layout_type]
return index_by_author(journal_papers)
end
page = OrbitHelper.page
if page.custom_string_field == 'table'
fields_to_show = page.custom_array_field rescue []
if fields_to_show.blank?
@ -136,6 +139,19 @@ class PersonalJournalsController < ApplicationController
}
end
def index_by_author(journal_papers)
journal_papers_total_pages = journal_papers.total_pages
journal_papers_list = journal_papers.group_by{|jp| jp.member_profile.name rescue jp.authors}.collect do |name, jps|
{'name' => name, 'jps' => jps.collect{|jp| {'title' => jp.paper_title}}}
end
{
'journal_papers' => journal_papers_list,
'extras' => { 'widget-title' => t('module_name.journal_paper')},
'total_pages' => journal_papers_total_pages
}
end
def show
params = OrbitHelper.params
plugin = JournalPaper.where(is_hidden: false).find_by(uid: params[:uid].to_s)

View File

@ -0,0 +1,10 @@
<h3 class="page-module-title">{{page-title}}</h3>
<article>
<div data-level="0" data-list="journal_papers">
<h4>{{name}}</h4>
<ul data-level="1" data-list="jps">
<li>{{title}}</li>
</ul>
</div>
</article>
{{pagination_goes_here}}

View File

@ -15,6 +15,14 @@
"en" : "2. List which includes search"
},
"thumbnail" : "thumb.png"
},
{
"filename" : "index_by_author",
"name" : {
"zh_tw" : "3. 作者論文",
"en" : "3. List by Author"
},
"thumbnail" : "thumb.png"
}
]
}