Fix bug.
Add transform display year when language is chinese.
This commit is contained in:
parent
b62776f833
commit
ab332a2c3d
|
@ -32,7 +32,7 @@ class AcademicAdvisingsController < ApplicationController
|
||||||
when "award_name"
|
when "award_name"
|
||||||
t << {"value" => "<a href='#{OrbitHelper.url_to_show(academic_advising.to_param)}'>" + (academic_advising.send(fs) rescue "") + "</a>"}
|
t << {"value" => "<a href='#{OrbitHelper.url_to_show(academic_advising.to_param)}'>" + (academic_advising.send(fs) rescue "") + "</a>"}
|
||||||
when "academic_advising_type"
|
when "academic_advising_type"
|
||||||
t << {"value" => (academic_advising.send("academic_advising_type").title rescue "")}
|
t << {"value" => academic_advising.display_advising_type}
|
||||||
when "authors"
|
when "authors"
|
||||||
member_profile = academic_advising.send(:member_profile)
|
member_profile = academic_advising.send(:member_profile)
|
||||||
role_status_id = member_profile.role_status_ids.first.to_s
|
role_status_id = member_profile.role_status_ids.first.to_s
|
||||||
|
@ -42,6 +42,8 @@ class AcademicAdvisingsController < ApplicationController
|
||||||
t << {"value" => (academic_advising.send(fs).strftime("%Y/%m") rescue "")}
|
t << {"value" => (academic_advising.send(fs).strftime("%Y/%m") rescue "")}
|
||||||
when "advising_students"
|
when "advising_students"
|
||||||
t << {"value" => academic_advising.advising_students_front_data}
|
t << {"value" => academic_advising.advising_students_front_data}
|
||||||
|
when "year"
|
||||||
|
t << {"value" => academic_advising.display_year}
|
||||||
else
|
else
|
||||||
t << {"value" => (academic_advising.send(fs) rescue "")}
|
t << {"value" => (academic_advising.send(fs) rescue "")}
|
||||||
end
|
end
|
||||||
|
|
|
@ -181,7 +181,7 @@ class Admin::AcademicAdvisingsController < OrbitMemberController
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_plugin
|
def set_plugin
|
||||||
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'AcademicAdvising'}.first
|
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Advising'}.first
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -25,7 +25,12 @@ class Advising
|
||||||
before_validation :add_http
|
before_validation :add_http
|
||||||
|
|
||||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc",:award_date => "desc") }
|
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc",:award_date => "desc") }
|
||||||
|
def display_year
|
||||||
|
(I18n.locale.to_s == "zh_tw" ? (self.year > 1911 ? (self.year - 1911) : self.year ) : self.year)
|
||||||
|
end
|
||||||
|
def display_advising_type
|
||||||
|
(self.advising_type ? self.advising_type.title : "")
|
||||||
|
end
|
||||||
def slug_title
|
def slug_title
|
||||||
self.award_name+' '+self.awarding_unit rescue ""
|
self.award_name+' '+self.awarding_unit rescue ""
|
||||||
end
|
end
|
||||||
|
@ -51,8 +56,8 @@ class Advising
|
||||||
fields_to_show = page.custom_array_field
|
fields_to_show = page.custom_array_field
|
||||||
else
|
else
|
||||||
fields_to_show = [
|
fields_to_show = [
|
||||||
"academic_advising_type",
|
|
||||||
"year",
|
"year",
|
||||||
|
"academic_advising_type",
|
||||||
"award_name",
|
"award_name",
|
||||||
"awarding_unit",
|
"awarding_unit",
|
||||||
"advising_students"
|
"advising_students"
|
||||||
|
@ -62,12 +67,13 @@ class Advising
|
||||||
fields_to_remove = []
|
fields_to_remove = []
|
||||||
|
|
||||||
pd_title = []
|
pd_title = []
|
||||||
puts fields_to_show
|
|
||||||
fields_to_show.each do |t|
|
fields_to_show.each do |t|
|
||||||
if (self.fields[t].type.to_s == "String" || self.fields[t].type.to_s == "Object" rescue false)
|
if (self.fields[t].type.to_s == "String" || self.fields[t].type.to_s == "Object" rescue false)
|
||||||
fields_to_remove << t if (datas.where(t.to_sym.ne => nil, t.to_sym.ne => "").count == 0 rescue false)
|
fields_to_remove << t if (datas.where(t.to_sym.ne => nil, t.to_sym.ne => "").count == 0 rescue false)
|
||||||
elsif t=='advising_students'
|
elsif t=='advising_students'
|
||||||
fields_to_remove << t if (datas.where(:advising_student_ids.ne => []).count == 0 rescue false)
|
fields_to_remove << t if (datas.where(:advising_student_ids.ne => []).count == 0 rescue false)
|
||||||
|
elsif t == "academic_advising_type"
|
||||||
|
fields_to_remove << t if (datas.where(:advising_type.ne => nil).count == 0 rescue false)
|
||||||
else
|
else
|
||||||
fields_to_remove << t if (datas.where(t.to_sym.ne => nil).count == 0 rescue false)
|
fields_to_remove << t if (datas.where(t.to_sym.ne => nil).count == 0 rescue false)
|
||||||
end
|
end
|
||||||
|
@ -75,7 +81,7 @@ class Advising
|
||||||
"plugin_data_title" => I18n.t("academic_advising.#{t}")
|
"plugin_data_title" => I18n.t("academic_advising.#{t}")
|
||||||
} if !fields_to_remove.include?(t)
|
} if !fields_to_remove.include?(t)
|
||||||
end
|
end
|
||||||
|
puts fields_to_remove
|
||||||
fields_to_show = fields_to_show - fields_to_remove
|
fields_to_show = fields_to_show - fields_to_remove
|
||||||
|
|
||||||
plugin_datas = datas.sort_for_frontend.collect.with_index do |p,index|
|
plugin_datas = datas.sort_for_frontend.collect.with_index do |p,index|
|
||||||
|
@ -84,11 +90,13 @@ class Advising
|
||||||
if t == "award_name"
|
if t == "award_name"
|
||||||
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'academic_advising')}' title='#{p.send(t)}' target='_blank'>#{p.send(t)}</a>" }
|
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'academic_advising')}' title='#{p.send(t)}' target='_blank'>#{p.send(t)}</a>" }
|
||||||
elsif t == "academic_advising_type"
|
elsif t == "academic_advising_type"
|
||||||
pd_data << {"data_title" => (p.academic_advising_type.title rescue "")}
|
pd_data << {"data_title" => p.display_advising_type}
|
||||||
elsif t == "award_date"
|
elsif t == "award_date"
|
||||||
pd_data << {"data_title" => (p.send(t).strftime("%Y/%m/%d") rescue "")}
|
pd_data << {"data_title" => (p.send(t).strftime("%Y/%m/%d") rescue "")}
|
||||||
elsif t == "advising_students"
|
elsif t == "advising_students"
|
||||||
pd_data << {"data_title" => p.advising_students_front_data}
|
pd_data << {"data_title" => p.advising_students_front_data}
|
||||||
|
elsif t == "year"
|
||||||
|
pd_data << { "data_title" => p.display_year }
|
||||||
else
|
else
|
||||||
pd_data << { "data_title" => p.send(t) }
|
pd_data << { "data_title" => p.send(t) }
|
||||||
end
|
end
|
||||||
|
@ -113,11 +121,13 @@ class Advising
|
||||||
when "language"
|
when "language"
|
||||||
value = I18n.t(self.language) rescue ""
|
value = I18n.t(self.language) rescue ""
|
||||||
when "academic_advising_type"
|
when "academic_advising_type"
|
||||||
value = self.academic_advising_type.title rescue ""
|
value = self.display_advising_type
|
||||||
when "award_date"
|
when "award_date"
|
||||||
value = self.award_date.strftime("%Y/%m/%d") rescue ""
|
value = self.award_date.strftime("%Y/%m/%d") rescue ""
|
||||||
when "advising_students"
|
when "advising_students"
|
||||||
value = self.advising_students_front_data
|
value = self.advising_students_front_data
|
||||||
|
when "year"
|
||||||
|
value = self.display_year
|
||||||
else
|
else
|
||||||
value = self.send(field) rescue ""
|
value = self.send(field) rescue ""
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<% @academic_advisings.each do |academic_advising| %>
|
<% @academic_advisings.each do |academic_advising| %>
|
||||||
<tr id="<%= dom_id academic_advising %>" class="<%= academic_advising.is_hidden ? "checkHide" : "" %>">
|
<tr id="<%= dom_id academic_advising %>" class="<%= academic_advising.is_hidden ? "checkHide" : "" %>">
|
||||||
<td><%= academic_advising.year %></td>
|
<td><%= academic_advising.display_year %></td>
|
||||||
|
<td><%= academic_advising.display_advising_type %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to academic_advising.award_name, OrbitHelper.url_to_plugin_show(academic_advising.to_param,'academic_advising'), target: "blank"%>
|
<%= link_to academic_advising.award_name, OrbitHelper.url_to_plugin_show(academic_advising.to_param,'academic_advising'), target: "blank"%>
|
||||||
<div class="quick-edit">
|
<div class="quick-edit">
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="span3"><%= t('academic_advising.year') %></th>
|
<th class="span3"><%= t('academic_advising.year') %></th>
|
||||||
|
<th class="span3"><%= t('academic_advising.academic_advising_type') %></th>
|
||||||
<th class="span3"><%= t('academic_advising.award_name') %></th>
|
<th class="span3"><%= t('academic_advising.award_name') %></th>
|
||||||
<th class="span3"><%= t('academic_advising.awarding_unit') %></th>
|
<th class="span3"><%= t('academic_advising.awarding_unit') %></th>
|
||||||
<th class="span3"><%= t('academic_advising.academic_advisingee') %></th>
|
<th class="span3"><%= t('academic_advising.academic_advisingee') %></th>
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
<th><input type="checkbox" /></th>
|
<th><input type="checkbox" /></th>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<th class="span3"><%= t('academic_advising.year') %></th>
|
<th class="span3"><%= t('academic_advising.year') %></th>
|
||||||
|
<th class="span3"><%= t('academic_advising.academic_advising_type') %></th>
|
||||||
<th class="span3"><%= t('academic_advising.award_name') %></th>
|
<th class="span3"><%= t('academic_advising.award_name') %></th>
|
||||||
<th class="span3"><%= t('academic_advising.awarding_unit') %></th>
|
<th class="span3"><%= t('academic_advising.awarding_unit') %></th>
|
||||||
<th class="span3"><%= t('academic_advising.award_winner') %></th>
|
<th class="span3"><%= t('academic_advising.award_winner') %></th>
|
||||||
|
@ -42,7 +43,8 @@
|
||||||
<%= check_box_tag 'to_change[]', academic_advising.id.to_s, false, :class => "list-check" %>
|
<%= check_box_tag 'to_change[]', academic_advising.id.to_s, false, :class => "list-check" %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td><%= academic_advising.year %></td>
|
<td><%= academic_advising.display_year %></td>
|
||||||
|
<td><%= academic_advising.display_advising_type %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to academic_advising.award_name, OrbitHelper.url_to_plugin_show(academic_advising.to_param,'academic_advising'), target: "blank"%>
|
<%= link_to academic_advising.award_name, OrbitHelper.url_to_plugin_show(academic_advising.to_param,'academic_advising'), target: "blank"%>
|
||||||
<div class="quick-edit">
|
<div class="quick-edit">
|
||||||
|
|
|
@ -4,7 +4,7 @@ module AcademicAdvising
|
||||||
OrbitApp.registration "AcademicAdvising",:type=> 'ModuleApp' do
|
OrbitApp.registration "AcademicAdvising",:type=> 'ModuleApp' do
|
||||||
module_label 'module_name.academic_advising'
|
module_label 'module_name.academic_advising'
|
||||||
base_url File.expand_path File.dirname(__FILE__)
|
base_url File.expand_path File.dirname(__FILE__)
|
||||||
personal_plugin :enable => true, :sort_number => '50', :app_name=>"Advising", :intro_app_name=>"AdvisingIntro",:path=>"/plugin/academic_advising/profile",:front_path=>"/profile",:admin_path=>"/admin/academic_advisings",:i18n=>'module_name.academic_advising', :module_app_name=>'AcademicAdvising', :field_modifiable => true, :analysis => true, :analysis_path => "/admin/academic_advisings/analysis"
|
personal_plugin :enable => true, :sort_number => '50', :app_name=>"Advising", :intro_app_name=>"AdvisingIntro",:path=>"/plugin/academic_advising/profile",:front_path=>"/profile",:admin_path=>"/admin/academic_advisings/",:i18n=>'module_name.academic_advising', :module_app_name=>'AcademicAdvising', :field_modifiable => true, :analysis => true, :analysis_path => "/admin/academic_advisings/analysis"
|
||||||
|
|
||||||
version "0.1"
|
version "0.1"
|
||||||
desktop_enabled true
|
desktop_enabled true
|
||||||
|
|
Loading…
Reference in New Issue