Add some fields.

Fix bug.
This commit is contained in:
BoHung Chiu 2022-08-23 18:40:36 +08:00
parent 364341d246
commit 2ddc292255
5 changed files with 138 additions and 56 deletions

View File

@ -135,11 +135,14 @@ class PersonalConferencesController < ApplicationController
paper_title paper_title
conference_title conference_title
location location
period_start_date
period_end_date
period period
vol_no
issue_no
form_to_start
form_to_end
paper_type paper_type
paper_level paper_level
total_pages
sponsor sponsor
author_type author_type
number_of_authors number_of_authors
@ -163,8 +166,6 @@ class PersonalConferencesController < ApplicationController
paper_title paper_title
conference_title conference_title
location location
period_start_date
period_end_date
period period
paper_type paper_type
paper_level paper_level

View File

@ -25,6 +25,11 @@ class WritingConference
field :create_user_id, :type => BSON::ObjectId field :create_user_id, :type => BSON::ObjectId
field :update_user_id, :type => BSON::ObjectId field :update_user_id, :type => BSON::ObjectId
field :isbn field :isbn
field :vol_no, type: String
field :issue_no, type: String
field :form_to_start, type: String
field :form_to_end, type: String
field :total_pages, type: String
field :isi_number field :isi_number
field :number_of_authors field :number_of_authors
field :rss2_id field :rss2_id
@ -52,29 +57,62 @@ class WritingConference
title << self.paper_title if self.paper_title.present? title << self.paper_title if self.paper_title.present?
title << self.conference_title if self.conference_title.present? title << self.conference_title if self.conference_title.present?
title << self.location if self.location.present?
paper_types = ( !self.conference_paper_types.blank? ? self.conference_paper_types.collect{|x| x.title}.join(', ') : "") paper_types = ( !self.conference_paper_types.blank? ? self.conference_paper_types.collect{|x| x.title}.join(', ') : "")
paper_levels = ( !self.conference_paper_levels.blank? ? "(#{self.conference_paper_levels.collect{|x| x.title}.join(', ')})" : "") paper_levels = ( !self.conference_paper_levels.blank? ? "(#{self.conference_paper_levels.collect{|x| x.title}.join(', ')})" : "")
title << paper_types + paper_levels title << paper_types + paper_levels
title << "#{period_start_date}-#{period_end_date}" if (self.period_start_date.present? && self.period_end_date.present?) title << "vol. " + self.vol_no.strip if (self.vol_no.present? && self.vol_no != "0")
title << self.issue_no if (self.issue_no.present? && self.issue_no != "0")
# if !self.publication_date.nil? title << "pp." + self.form_to_start.to_s+"-"+self.form_to_end.to_s if (self.form_to_start.present? && self.form_to_start != "0")
# pd = self.publication_date.strftime("%Y-%m-%d").split('-') if self.period_start_date.present? && self.period_end_date.present?
# title << pd[0] title << self.duration
# end elsif !self.publication_date.nil?
# title << self.year title << (self.publication_date.strftime("%b. %Y") rescue nil)
elsif self.year.present?
title << self.year
end
if self.location.present?
title << self.location
end
title = title.join(', ') title = title.join(', ')
title.rstrip.chomp(",") title.sub(/^\\s*,/,'').gsub(/,(\s*,)+/,',').strip
end end
def form_to
def duration if (self.form_to_start.present? && self.form_to_start != "0")
if !self.send('period_start_date').nil? or !self.send('period_end_date').nil? self.form_to_start.to_s+"-"+self.form_to_end.to_s
date = (self.send('period_start_date').strftime('%Y.%m.%d') rescue "")+' ~ '+(self.send('period_end_date').strftime('%Y.%m.%d') rescue I18n.t('personal_project.up_to_today'))
else else
date = "" ""
end end
end end
def duration(date_format="%b. %d, %Y")
period_start_date_present = self.period_start_date.present?
period_end_date_present = self.period_end_date.present?
date = ""
if period_start_date_present && period_end_date_present
if self.period_start_date == self.period_end_date
date = self.period_start_date.strftime(date_format)
else
period_start_ym = [self.period_start_date.year, self.period_start_date.month]
period_end_ym = [self.period_end_date.year, self.period_end_date.month]
same_year = period_start_ym[0] == period_end_ym[0]
same_month = period_start_ym[1] == period_end_ym[1]
month_date_format = date_format.sub('%Y','').gsub(',','').strip.sub(/^[\/\-\.]/,'').sub(/[\/\-\.]$/,'')
if same_year && same_month
date = self.period_start_date.strftime("#{month_date_format}-#{self.period_end_date.day}, %Y")
elsif same_year
date = self.period_start_date.strftime("#{month_date_format}-#{self.period_end_date.strftime(month_date_format)}, %Y")
else
date = self.period_start_date.strftime(date_format) + ' ~ ' + self.period_end_date.strftime(date_format)
end
end
elsif period_start_date_present || period_end_date_present
if self.period_start_date
date = self.period_start_date.strftime('%b. %d, %Y') + ' ~ ' + I18n.t('personal_conference.up_to_today')
else
date = self.period_end_date.strftime('%b. %d, %Y')
end
end
date
end
def self.get_plugin_datas_to_member(datas) def self.get_plugin_datas_to_member(datas)
@ -105,11 +143,16 @@ class WritingConference
if (self.fields[t].type.to_s == "String" rescue false) if (self.fields[t].type.to_s == "String" rescue false)
fields_to_remove << t if (datas.where(t.to_sym.ne => nil).or(t.to_sym.ne => "").count == 0 rescue false) fields_to_remove << t if (datas.where(t.to_sym.ne => nil).or(t.to_sym.ne => "").count == 0 rescue false)
else else
t = "conference_author_types" if t == "author_type" t2 = t
t = "period_start_date" if t == "period" case t
fields_to_remove << t if (datas.where(t.to_sym.ne => nil).count == 0 rescue false) when "form_to"
t = "author_type" if t == "conference_author_types" t2 = "form_to_start"
t = "period" if t == "period_start_date" when "author_type"
t2 = "conference_author_types"
when "period"
t2 = "period_start_date"
end
fields_to_remove << t if (datas.where(t2.to_sym.ne => nil).count == 0 rescue false)
end end
pd_title << { pd_title << {
"plugin_data_title" => I18n.t("personal_conference.#{t}") "plugin_data_title" => I18n.t("personal_conference.#{t}")
@ -117,7 +160,7 @@ class WritingConference
end end
fields_to_show = fields_to_show - fields_to_remove fields_to_show = fields_to_show - fields_to_remove
date_format = (I18n.locale == :zh_tw ? '%Y-%m-%d' : '%b. %d, %Y')
plugin_datas = datas.sort_for_frontend.collect do |p| plugin_datas = datas.sort_for_frontend.collect do |p|
pd_data = [] pd_data = []
@ -135,7 +178,7 @@ class WritingConference
when "author_type" when "author_type"
pd_data << {"data_title" => (p.conference_author_types.collect{|cat| cat.title}.join(", ") rescue "")} pd_data << {"data_title" => (p.conference_author_types.collect{|cat| cat.title}.join(", ") rescue "")}
when "period" when "period"
pd_data << {"data_title" => p.duration} pd_data << {"data_title" => p.duration(date_format)}
when "url" when "url"
pd_data << { "data_title" => "<a href='#{p.url}' title=\"#{p.url}\" target='_blank'>#{p.url}</a>" } pd_data << { "data_title" => "<a href='#{p.url}' title=\"#{p.url}\" target='_blank'>#{p.url}</a>" }
when "publication_date" when "publication_date"
@ -190,6 +233,8 @@ class WritingConference
end end
end end
value = value.join(" / ") value = value.join(" / ")
when "period"
value = self.duration((I18n.locale == :zh_tw ? '%Y-%m-%d' : '%b. %d, %Y'))
when "publication_date" when "publication_date"
get_setting get_setting
value = self.publication_date.strftime(@setting.publication_date_format) rescue "" value = self.publication_date.strftime(@setting.publication_date_format) rescue ""

View File

@ -170,6 +170,38 @@
</div> </div>
</div> </div>
<!-- vol_no -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_journal.vol_no") %></label>
<div class="controls">
<%= f.text_field :vol_no %>
</div>
</div>
<!-- issue_no -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_journal.issue_no") %></label>
<div class="controls">
<%= f.text_field :issue_no %>
</div>
</div>
<!-- form_to -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_journal.form_to") %></label>
<div class="controls">
<%= f.text_field :form_to_start, :class=>'span1' %> ~ <%= f.text_field :form_to_end, :class=>'span1' %>
</div>
</div>
<!-- total_pages -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_journal.total_pages") %></label>
<div class="controls">
<%= f.text_field :total_pages %>
</div>
</div>
<!-- period_start_date --> <!-- period_start_date -->
<div class="control-group"> <div class="control-group">
<label class="control-label muted"><%= t("personal_conference.period_start_date") %></label> <label class="control-label muted"><%= t("personal_conference.period_start_date") %></label>

View File

@ -35,11 +35,13 @@ en:
keywords : "Keywords" keywords : "Keywords"
isbn: "ISSN (ISBN)" isbn: "ISSN (ISBN)"
isi_number: "ISI Number" isi_number: "ISI Number"
# total_pages : "Total Pages" vol_no : "Vol.No"
# form_to_start : "From" issue_no : "Issue.No"
# form_to_end : "To" form_to: "Page(s)"
# from : "From" form_to_start : "From"
# to : "To" form_to_end : "To"
up_to_today : "Up to today"
total_pages : "Total Pages"
abstract : "Abstract" abstract : "Abstract"
publication_date : "Date of Publication" publication_date : "Date of Publication"
url : "Reference URL" url : "Reference URL"

View File

@ -34,11 +34,13 @@ zh_tw:
keywords : "關鍵字" keywords : "關鍵字"
isbn: "ISSN (ISBN)" isbn: "ISSN (ISBN)"
isi_number: "ISI Number" isi_number: "ISI Number"
# total_pages : "總頁數" vol_no : "卷數"
# form_to_start : "From" issue_no : "期數"
# form_to_end : "To" form_to: "頁碼"
# from : "起" form_to_start : "起"
# to : "迄" form_to_end : "迄"
up_to_today : "迄今"
total_pages : "總頁數"
abstract : "摘要" abstract : "摘要"
publication_date : "發表日期" publication_date : "發表日期"
url : "參考連結" url : "參考連結"