修復需求2.0
This commit is contained in:
parent
0d5fb4f05c
commit
bd9bab2b3e
|
@ -35,8 +35,8 @@ class AsiaDatabasesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# choice field
|
# choice field
|
||||||
choice_field = [{'choice_show'=> t('asia_database.extend_translate.select_field'), 'choice_value' => 'default', 'choice_select' => ''}]
|
choice_field = []
|
||||||
fields_to_select = ["discipline_expertise", "project", "paper", "patent", "tec_transfer", "exhibition"]
|
fields_to_select = ["patent", "project", "paper", "discipline_expertise", "tec_transfer", "exhibition"]
|
||||||
fields_to_select.each do |fs|
|
fields_to_select.each do |fs|
|
||||||
choice_field << {'choice_show'=> t("asia_database.extend_translate.#{fs}"), 'choice_value' => fs, 'choice_select' => ''}
|
choice_field << {'choice_show'=> t("asia_database.extend_translate.#{fs}"), 'choice_value' => fs, 'choice_select' => ''}
|
||||||
end
|
end
|
||||||
|
@ -46,29 +46,23 @@ class AsiaDatabasesController < ApplicationController
|
||||||
field_name = h['choice_value']
|
field_name = h['choice_value']
|
||||||
if field_name == params[:field]
|
if field_name == params[:field]
|
||||||
h['choice_select'] = 'selected'
|
h['choice_select'] = 'selected'
|
||||||
if field_name == 'default'
|
|
||||||
selected_field_int = 0
|
|
||||||
else
|
|
||||||
selected_field = field_name
|
selected_field = field_name
|
||||||
selected_field_int = i - 1
|
selected_field_int = i
|
||||||
end
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
fields_to_show = ['academy', 'department', 'teacher']
|
fields_to_show = ['academy', 'department', 'teacher']
|
||||||
if selected_field_int == 0
|
if selected_field == "discipline_expertise"
|
||||||
fields_to_show += ExtraFields[selected_field]
|
fields_to_show += ExtraFields[selected_field]
|
||||||
table_headers = fields_to_show.map do |fs|
|
table_headers = fields_to_show.map do |fs|
|
||||||
{
|
{
|
||||||
'head-title' => t("asia_database.#{fs}"),
|
'head-title' => t("asia_database.#{fs}")
|
||||||
'col' => (fs == 'teacher' ? 3 : 2)
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
table_headers = fields_to_show.map do |fs|
|
table_headers = fields_to_show.map do |fs|
|
||||||
{
|
{
|
||||||
'head-title' => t("asia_database.#{fs}"),
|
'head-title' => t("asia_database.#{fs}")
|
||||||
'col' => (fs == 'teacher' ? 3 : 2)
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
fields_to_show = fields_to_show.map{|fs| "asia_teacher.#{fs}"}
|
fields_to_show = fields_to_show.map{|fs| "asia_teacher.#{fs}"}
|
||||||
|
@ -76,13 +70,12 @@ class AsiaDatabasesController < ApplicationController
|
||||||
fields_to_show += extra_fields
|
fields_to_show += extra_fields
|
||||||
table_headers += extra_fields.map do |fs|
|
table_headers += extra_fields.map do |fs|
|
||||||
{
|
{
|
||||||
'head-title' => t("asia_database.asia_#{selected_field}.#{fs}"),
|
'head-title' => t("asia_database.asia_#{selected_field}.#{fs}")
|
||||||
'col' => 2
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
search_field = nil
|
search_field = nil
|
||||||
if selected_field_int == 0 #Discipline Expertise
|
if selected_field_int == 3 #Discipline Expertise
|
||||||
if selected_academy
|
if selected_academy
|
||||||
asia_data = selected_academy.asia_teachers
|
asia_data = selected_academy.asia_teachers
|
||||||
else
|
else
|
||||||
|
@ -103,7 +96,7 @@ class AsiaDatabasesController < ApplicationController
|
||||||
asia_data = AsiaPaper.all
|
asia_data = AsiaPaper.all
|
||||||
end
|
end
|
||||||
search_field = 'paper_name'
|
search_field = 'paper_name'
|
||||||
elsif selected_field_int == 3 #Patent
|
elsif selected_field_int == 0 #Patent
|
||||||
if selected_academy
|
if selected_academy
|
||||||
asia_data = AsiaPatent.where(:asia_teacher_id.in=>selected_academy.asia_teacher_ids)
|
asia_data = AsiaPatent.where(:asia_teacher_id.in=>selected_academy.asia_teacher_ids)
|
||||||
else
|
else
|
||||||
|
@ -132,6 +125,8 @@ class AsiaDatabasesController < ApplicationController
|
||||||
if for_frontend
|
if for_frontend
|
||||||
asia_data = asia_data.page(params[:page_no]).per(OrbitHelper.page_data_count)
|
asia_data = asia_data.page(params[:page_no]).per(OrbitHelper.page_data_count)
|
||||||
end
|
end
|
||||||
|
asia_data_list = []
|
||||||
|
if !params['keywords'].nil?
|
||||||
if for_frontend
|
if for_frontend
|
||||||
asia_data_list = asia_data.collect do |asia_record|
|
asia_data_list = asia_data.collect do |asia_record|
|
||||||
{'jps' => fields_to_show.map{|field| {"value"=> get_display_field(asia_record,field)}}}
|
{'jps' => fields_to_show.map{|field| {"value"=> get_display_field(asia_record,field)}}}
|
||||||
|
@ -144,6 +139,7 @@ class AsiaDatabasesController < ApplicationController
|
||||||
fields_to_show.map{|field| get_raw_field(asia_record, field)}
|
fields_to_show.map{|field| get_raw_field(asia_record, field)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return asia_data_list, asia_data, table_headers, choice_unit, choice_field
|
return asia_data_list, asia_data, table_headers, choice_unit, choice_field
|
||||||
end
|
end
|
||||||
def index
|
def index
|
||||||
|
@ -253,21 +249,25 @@ class AsiaDatabasesController < ApplicationController
|
||||||
end
|
end
|
||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
def get_display_field(asia_teacher,field)
|
def get_display_field(model,field)
|
||||||
text_only = false
|
text_only = false
|
||||||
value = asia_teacher.send(field) rescue ""
|
value = ""
|
||||||
if field.include?(".")
|
if field.include?(".")
|
||||||
value = asia_teacher
|
field_level = field.split(".")
|
||||||
field.split(".").each do |f|
|
field_level[0...-1].each do |f|
|
||||||
if f == 'teacher'
|
model = model.send(f) rescue model
|
||||||
tmp_value = value.teacher
|
end
|
||||||
value = "<a class=\"teacher_url\" target=\"_blank\" href=\"#{value.url}\" title=\"#{tmp_value}\">#{tmp_value}</a>"
|
if field_level[-1] == 'teacher'
|
||||||
|
value = teacher_frontend_text(model)
|
||||||
else
|
else
|
||||||
value = value.send(f) rescue nil
|
value = model.send(field_level[-1])
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if field == 'teacher'
|
||||||
|
value = teacher_frontend_text(model)
|
||||||
|
else
|
||||||
|
value = model.send(field)
|
||||||
end
|
end
|
||||||
elsif field == 'teacher'
|
|
||||||
value = "<a class=\"teacher_url\" target=\"_blank\" href=\"#{asia_teacher.url}\" title=\"#{value}\">#{value}</a>"
|
|
||||||
end
|
end
|
||||||
if value.class == Array
|
if value.class == Array
|
||||||
tmp = '<ul>'
|
tmp = '<ul>'
|
||||||
|
@ -341,7 +341,7 @@ class AsiaDatabasesController < ApplicationController
|
||||||
member_fields = []
|
member_fields = []
|
||||||
file_fields = []
|
file_fields = []
|
||||||
link_fields = []
|
link_fields = []
|
||||||
if select_field == "default"
|
if select_field == nil
|
||||||
asia_data = asia_data.where(:slug_title=>/#{gsub_invalid_character(keywords)}/)
|
asia_data = asia_data.where(:slug_title=>/#{gsub_invalid_character(keywords)}/)
|
||||||
elsif select_field == "member_profile"
|
elsif select_field == "member_profile"
|
||||||
ms = MemberProfile.all.select{|m| m.name.include?(keywords)}
|
ms = MemberProfile.all.select{|m| m.name.include?(keywords)}
|
||||||
|
@ -403,4 +403,8 @@ class AsiaDatabasesController < ApplicationController
|
||||||
def gsub_invalid_character(text)
|
def gsub_invalid_character(text)
|
||||||
::Regexp.escape(text.to_s)
|
::Regexp.escape(text.to_s)
|
||||||
end
|
end
|
||||||
|
def teacher_frontend_text(value)
|
||||||
|
tmp_value = value.teacher
|
||||||
|
"<a class=\"teacher_url link-primary\" target=\"_blank\" href=\"#{value.url}\" title=\"#{tmp_value}\">#{tmp_value}</a>"
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -4,5 +4,5 @@ class AsiaAcademy
|
||||||
include Slug
|
include Slug
|
||||||
field :academy_name, :type => String, :default => "", :localize => true, :as => :slug_title
|
field :academy_name, :type => String, :default => "", :localize => true, :as => :slug_title
|
||||||
has_many :asia_departments
|
has_many :asia_departments
|
||||||
has_many :asia_teachers
|
has_many :asia_teachers, :order => 'ukey DESC'
|
||||||
end
|
end
|
|
@ -18,8 +18,8 @@ class AsiaTeacher
|
||||||
has_many :asia_patents
|
has_many :asia_patents
|
||||||
has_many :asia_tec_transfers
|
has_many :asia_tec_transfers
|
||||||
has_many :asia_exhibitions
|
has_many :asia_exhibitions
|
||||||
scope :sort_order, ->{order({ukey: 1})}
|
scope :sort_order, ->{order({ukey: -1})}
|
||||||
index({ukey: 1}, { unique: false, background: true })
|
index({ukey: -1}, { unique: false, background: true })
|
||||||
before_save do
|
before_save do
|
||||||
if self.asia_academy_id_changed?
|
if self.asia_academy_id_changed?
|
||||||
self.academy_translations = self.asia_academy.academy_name_translations rescue ""
|
self.academy_translations = self.asia_academy.academy_name_translations rescue ""
|
||||||
|
|
|
@ -2,7 +2,22 @@ $:.push File.expand_path("../lib", __FILE__)
|
||||||
|
|
||||||
# Maintain your gem's version:
|
# Maintain your gem's version:
|
||||||
require "asia_database/version"
|
require "asia_database/version"
|
||||||
|
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
|
||||||
|
if bundle_update_flag
|
||||||
|
app_path = File.expand_path(__dir__)
|
||||||
|
template_path = ENV['PWD'] + '/app/templates'
|
||||||
|
all_template = Dir.glob(template_path+'/*/')
|
||||||
|
puts 'copying module'
|
||||||
|
all_template.each do |folder|
|
||||||
|
if folder.split('/')[-1] != 'mobile'
|
||||||
|
begin
|
||||||
|
system ('cp -r '+ app_path + '/modules/ ' + folder)
|
||||||
|
rescue
|
||||||
|
puts 'error copy'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
# Describe your gem and declare its dependencies:
|
# Describe your gem and declare its dependencies:
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = "asia_database"
|
s.name = "asia_database"
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
<div id="asia-db-block" style="font-family: Microsoft JhengHei;">
|
||||||
|
<style type="text/css">
|
||||||
|
.clear-btn{
|
||||||
|
margin-right: 3em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$( ".selectbox" ).ready(function() {
|
$( ".selectbox" ).ready(function() {
|
||||||
var option_len = $(".search-widget option").length
|
var option_len = $(".search-widget option").length
|
||||||
|
@ -24,11 +30,11 @@ $( ".selectbox" ).ready(function() {
|
||||||
</select>
|
</select>
|
||||||
{{search_text}}
|
{{search_text}}
|
||||||
<input name="keywords" placeholder="Keywords" type="text" value="{{search_value}}">
|
<input name="keywords" placeholder="Keywords" type="text" value="{{search_value}}">
|
||||||
<button>{{search_trans}}</button>
|
<button class="btn btn-light">{{search_trans}}</button>
|
||||||
<a class="btn btn-danger" id="filter" style="" href="{{url}}">Clear</a>
|
<a aria-pressed="true" class="btn btn-default clear-btn" href="{{url}}">Clear</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-hover table-striped asia_teachers-index dt-responsive nowrap">
|
<table class="asia_teachers-index table table-hover table-striped dt-responsive dataTable no-footer dtr-inline">
|
||||||
<caption style="display: none;"><h3>{{widget-title}}</h3></caption>
|
<caption style="display: none;"><h3>{{widget-title}}</h3></caption>
|
||||||
<thead>
|
<thead>
|
||||||
<tr data-level="0" data-list="headers">
|
<tr data-level="0" data-list="headers">
|
||||||
|
@ -49,6 +55,8 @@ $('table.asia_teachers-index').DataTable({
|
||||||
paging: false,
|
paging: false,
|
||||||
ordering: false,
|
ordering: false,
|
||||||
info: false,
|
info: false,
|
||||||
autoWidth: false
|
autoWidth: false,
|
||||||
|
responsive: true
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
</div>
|
|
@ -8,6 +8,28 @@
|
||||||
width: 80%;
|
width: 80%;
|
||||||
max-width: 37.5em;
|
max-width: 37.5em;
|
||||||
}
|
}
|
||||||
|
.clear-btn{
|
||||||
|
margin-right: 3em;
|
||||||
|
}
|
||||||
|
#asia-db-form > span{
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
#asia-db-form > span{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.link-primary.teacher_url{
|
||||||
|
color: #337ab7;
|
||||||
|
text-decoration-line: underline;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.asia_databases-index{
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
.asia_databases-index ul{
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
@ -26,7 +48,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="asia-db-block">
|
<div id="asia-db-block" style="font-family: Microsoft JhengHei;">
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$( ".selectbox" ).ready(function() {
|
$( ".selectbox" ).ready(function() {
|
||||||
var option_len = $(".search-widget option").length
|
var option_len = $(".search-widget option").length
|
||||||
|
@ -39,30 +61,39 @@
|
||||||
</script>
|
</script>
|
||||||
<h3>{{widget-title}}</h3>
|
<h3>{{widget-title}}</h3>
|
||||||
<div class="search-widget">
|
<div class="search-widget">
|
||||||
<form action="{{url}}" method="get" id="asia-db-form">
|
<form action="{{url}}" method="get" id="asia-db-form" class="form-horizontal" role="form">
|
||||||
<input type="hidden" name="authenticity_token" value="{{csrf_value}}">
|
<input type="hidden" name="authenticity_token" value="{{csrf_value}}">
|
||||||
|
<span>
|
||||||
{{unit_trans}}
|
{{unit_trans}}
|
||||||
<select class="selectbox" name="unit" data-level="0" data-list="choice_unit">
|
<select class="selectbox" name="unit" data-level="0" data-list="choice_unit">
|
||||||
<option value={{choice_value}} data-selected='{{choice_select}}' >
|
<option value={{choice_value}} data-selected='{{choice_select}}' >
|
||||||
{{choice_show}}</option>
|
{{choice_show}}</option>
|
||||||
</select>
|
</select>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
{{select_field_text}}
|
{{select_field_text}}
|
||||||
<select class="selectbox" name="field" data-level="0" data-list="choice_field">
|
<select class="selectbox" name="field" data-level="0" data-list="choice_field">
|
||||||
<option value={{choice_value}} data-selected='{{choice_select}}' >
|
<option value={{choice_value}} data-selected='{{choice_select}}' >
|
||||||
{{choice_show}}</option>
|
{{choice_show}}</option>
|
||||||
</select>
|
</select>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
{{search_text}}
|
{{search_text}}
|
||||||
<input name="keywords" placeholder="Keywords" type="text" value="{{search_value}}">
|
<input name="keywords" placeholder="Keywords" type="text" value="{{search_value}}">
|
||||||
<button>{{search_trans}}</button>
|
<button class="btn btn-default">{{search_trans}}</button>
|
||||||
<a class="btn btn-danger" id="clear-asia-db-form" style="" href="{{url}}">Clear</a>
|
</span>
|
||||||
<a class="btn btn-success" id="export-asia-db" style="" href="javascript:void(0)" data-href="{{export_url}}">Export</a>
|
<span>
|
||||||
|
<a aria-pressed="true" class="btn btn-default clear-btn" href="{{url}}">Clear</a>
|
||||||
|
<button type="button" class="btn btn-default" id="export-asia-db" data-href="{{export_url}}">Export</a>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-hover table-striped asia_databases-index dt-responsive nowrap">
|
<table class="asia_databases-index table table-hover table-striped">
|
||||||
<caption style="display: none;"><h3>{{widget-title}}</h3></caption>
|
<caption style="display: none;"><h3>{{widget-title}}</h3></caption>
|
||||||
<thead>
|
<thead>
|
||||||
<tr data-level="0" data-list="headers">
|
<tr data-level="0" data-list="headers">
|
||||||
<th class="col-md-{{col}}">{{head-title}}</th>
|
<th>{{head-title}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody data-level="0" data-list="asia_databases">
|
<tbody data-level="0" data-list="asia_databases">
|
||||||
|
@ -98,12 +129,22 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
var columnDefs = [
|
||||||
|
{ "width": "7em", targets: 0 },
|
||||||
|
{ "width": "7em", targets: 1 },
|
||||||
|
{ "width": "4em", targets: 2 }
|
||||||
|
]
|
||||||
|
if ($('table.asia_databases-index th').length > 4){
|
||||||
|
columnDefs.push({ "width": "40%", targets: 3 });
|
||||||
|
}
|
||||||
$('table.asia_databases-index').DataTable({
|
$('table.asia_databases-index').DataTable({
|
||||||
searching: false,
|
searching: false,
|
||||||
paging: false,
|
paging: false,
|
||||||
ordering: false,
|
ordering: false,
|
||||||
info: false,
|
info: false,
|
||||||
autoWidth: false
|
autoWidth: false,
|
||||||
|
responsive: true,
|
||||||
|
columnDefs: columnDefs
|
||||||
});
|
});
|
||||||
$("#export-excel-modal").on('hidden.bs.modal', function (e) {
|
$("#export-excel-modal").on('hidden.bs.modal', function (e) {
|
||||||
closed_export_modal = true;
|
closed_export_modal = true;
|
||||||
|
|
Loading…
Reference in New Issue