From a62400bb075a68c35a4f7eb3af9a59cd97611580 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 08:38:01 +0800 Subject: [PATCH] add index --- .../personal_journals_controller.rb | 18 +++++++++++++++++- .../personal_journal/index_by_author.html.erb | 10 ++++++++++ modules/personal_journal/info.json | 8 ++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 modules/personal_journal/index_by_author.html.erb diff --git a/app/controllers/personal_journals_controller.rb b/app/controllers/personal_journals_controller.rb index a112c4d..be5d340 100644 --- a/app/controllers/personal_journals_controller.rb +++ b/app/controllers/personal_journals_controller.rb @@ -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) diff --git a/modules/personal_journal/index_by_author.html.erb b/modules/personal_journal/index_by_author.html.erb new file mode 100644 index 0000000..806bd68 --- /dev/null +++ b/modules/personal_journal/index_by_author.html.erb @@ -0,0 +1,10 @@ +

{{page-title}}

+
+
+

{{name}}

+
    +
  • {{title}}
  • +
+
+
+{{pagination_goes_here}} \ No newline at end of file diff --git a/modules/personal_journal/info.json b/modules/personal_journal/info.json index bdb0c2c..b3b2ea3 100644 --- a/modules/personal_journal/info.json +++ b/modules/personal_journal/info.json @@ -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" } ] } \ No newline at end of file