add year and journal type setting for index page

This commit is contained in:
Peter Chiu 2023-02-26 20:57:50 +08:00
parent 1e9a0cb143
commit a0e5539620
9 changed files with 92 additions and 31 deletions

View File

@ -222,6 +222,7 @@ class Admin::JournalPapersController < OrbitMemberController
@journal_levels = JournalLevel.all @journal_levels = JournalLevel.all
@author_types = JournalPaperAuthorType.all @author_types = JournalPaperAuthorType.all
@paper_types = JournalPaperType.all @paper_types = JournalPaperType.all
@journal_types = JournalType.all
end end
def set_plugin def set_plugin

View File

@ -3,7 +3,15 @@ class PersonalJournalsController < ApplicationController
def index def index
params = OrbitHelper.params params = OrbitHelper.params
page_data_count = OrbitHelper.page_data_count page_data_count = OrbitHelper.page_data_count
journal_papers = JournalPaper.sort_for_frontend.page(OrbitHelper.params[:page_no]).per(page_data_count) page = OrbitHelper.page
journal_paper_query = JournalPaper.sort_for_frontend
if (!page.year.blank? rescue false)
journal_paper_query = journal_paper_query.where(:year.in => page.year.to_a )
end
if (!page.journal_type.blank? rescue false)
journal_paper_query = journal_paper_query.where(:journal_type_id.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 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 []
@ -25,7 +33,7 @@ class PersonalJournalsController < ApplicationController
] ]
end end
if !params[:selectbox].nil? if !params[:selectbox].nil?
journal_papers_temp = JournalPaper.where(is_hidden: false).sort_by { |tp| [-tp[:year].to_i, -tp[:publication_date].to_i] } journal_papers_temp = journal_paper_query.sort_by { |tp| [-tp[:year].to_i, -tp[:publication_date].to_i] }
case params[:selectbox] case params[:selectbox]
when 'paper_title', 'default' when 'paper_title', 'default'
if page.custom_string_field == 'table' if page.custom_string_field == 'table'

View File

@ -33,6 +33,8 @@ class JournalPaper
#relations #relations
belongs_to :member_profile belongs_to :member_profile
belongs_to :journal_paper_type belongs_to :journal_paper_type
belongs_to :journal_type
has_and_belongs_to_many :journal_levels has_and_belongs_to_many :journal_levels
has_many :journal_paper_files, autosave: true, dependent: :destroy has_many :journal_paper_files, autosave: true, dependent: :destroy

View File

@ -197,6 +197,14 @@
</div> </div>
</div> </div>
<!-- journal_type -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_journal.journal_type") %></label>
<div class="controls">
<%= f.select :journal_type_id, @journal_types.collect {|t| [ t.title, t.id ]}, {include_blank: ''}, :class => "span3" %>
</div>
</div>
<!-- paper_type --> <!-- paper_type -->
<div class="control-group"> <div class="control-group">
<label class="control-label muted"><%= t("personal_journal.paper_type") %></label> <label class="control-label muted"><%= t("personal_journal.paper_type") %></label>

View File

@ -98,6 +98,33 @@
</div> </div>
</div> </div>
</div> </div>
<div class="element span4">
<div class="detail w-a h-a">
<p class="totle">
<a class="btn btn-small btn-primary pull-right" href="<%= new_admin_journal_type_path %>#journal_type_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
<span><%= t("personal_journal.journal_type") %></span>
</p>
<div class="detal-list my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<table id="journal_types" class="table table-striped">
<tbody>
<%= render :partial => 'list_journal_type', :collection => @journal_types %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div> </div>
<div id="paper_type_qe"> <div id="paper_type_qe">
@ -114,3 +141,9 @@
<div style="display:none;" class="modal" id="author_type_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div style="display:none;" class="modal" id="author_type_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
</div> </div>
</div> </div>
<div id="journal_type_qe">
<div style="display:none;" class="modal" id="journal_type_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
</div>
</div>

View File

@ -44,6 +44,7 @@ en:
graph_by : "Graph By" graph_by : "Graph By"
frontend: frontend:
writing_journals: "Journal Paper Frontend" writing_journals: "Journal Paper Frontend"
journal_type: Journal Name
strict_compare_mode: Strict Compare mode strict_compare_mode: Strict Compare mode
create_success : "Successfully Create" create_success : "Successfully Create"
update_success : "Successfully Update" update_success : "Successfully Update"

View File

@ -43,6 +43,7 @@ zh_tw:
graph_by : "Graph By" graph_by : "Graph By"
frontend: frontend:
writing_journals: "期刊論文前台" writing_journals: "期刊論文前台"
journal_type: 期刊類別
strict_compare_mode: "嚴格比較模式" strict_compare_mode: "嚴格比較模式"
create_success : "新增完成!!" create_success : "新增完成!!"
update_success : "更新完成!!" update_success : "更新完成!!"

View File

@ -33,6 +33,7 @@ Rails.application.routes.draw do
resources :journal_levels resources :journal_levels
resources :journal_paper_author_types resources :journal_paper_author_types
resources :journal_paper_types resources :journal_paper_types
resources :journal_types
resources :journal_paper_intros resources :journal_paper_intros
end end
get "/xhr/personal_journal/get_fields_for_index" => "personal_journals#get_fields_for_index" get "/xhr/personal_journal/get_fields_for_index" => "personal_journals#get_fields_for_index"

View File

@ -6,6 +6,12 @@ module PersonalJournal
base_url File.expand_path File.dirname(__FILE__) base_url File.expand_path File.dirname(__FILE__)
personal_plugin :enable => true, :sort_number => '5', :app_name=>"JournalPaper", :intro_app_name=>"JournalPaperlIntro",:path=>"/plugin/personal_journal/profile",:front_path=>"/profile",:admin_path=>"/admin/journal_papers/",:i18n=>'module_name.journal_paper', :module_app_name=>'PersonalJournal', :one_line_title => true, :field_modifiable => true, :analysis => true, :analysis_path => "/admin/journal_papers/analysis" personal_plugin :enable => true, :sort_number => '5', :app_name=>"JournalPaper", :intro_app_name=>"JournalPaperlIntro",:path=>"/plugin/personal_journal/profile",:front_path=>"/profile",:admin_path=>"/admin/journal_papers/",:i18n=>'module_name.journal_paper', :module_app_name=>'PersonalJournal', :one_line_title => true, :field_modifiable => true, :analysis => true, :analysis_path => "/admin/journal_papers/analysis"
begin
page_custom_option({year: '<%= f.select :year, (1930...(DateTime.now.year+5)).to_a.reverse, {:include_blank => ""}, {multiple: true} %>'})
page_custom_option({journal_type: '<% JournalType.all.each do |journal_type| %><label><%= f.check_box :journal_type, {multiple: true}, journal_type.id.to_s, nil %><%= journal_type.title %></label><% end %>'})
rescue => e
puts ['there_was_no_page_custom_option',e]
end
version "0.1" version "0.1"
desktop_enabled true desktop_enabled true
organization "Rulingcom" organization "Rulingcom"