something fix

This commit is contained in:
spen 2015-01-09 15:42:05 +08:00
parent 97ef6f3706
commit 865f0265a2
7 changed files with 150 additions and 106 deletions

View File

@ -35,9 +35,7 @@ class PersonalDiplomasController < ApplicationController
"country", "country",
"department", "department",
"degree", "degree",
"url", "url"
"keywords",
"note"
] ]
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)} {"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}

View File

@ -27,7 +27,7 @@ class Diploma
def duration def duration
if !self.start_date.nil? or !self.end_date.nil? if !self.start_date.nil? or !self.end_date.nil?
(self.start_date.strftime('%Y.%m') rescue "")+' ~ '+(self.end_date.strftime('%Y.%m') rescue "") (self.start_date.strftime('%Y.%m') rescue "")+' ~ '+(self.end_date.strftime('%Y.%m') rescue I18n.t('personal_diploma.up_to_today'))
else else
"" ""
end end
@ -37,6 +37,50 @@ class Diploma
[self.school_name,self.department,self.degree].join(' ') [self.school_name,self.department,self.degree].join(' ')
end end
def self.get_plugin_datas_to_member(datas)
fields_to_show = [
"school_name",
"country",
"department",
"degree",
"duration"
]
pd_title = fields_to_show.collect do |t|
{
"plugin_data_title" => I18n.t("personal_diploma.#{t}")
}
end
plugin_datas = datas.where(:is_hidden=>false).order_by(:end_date=>'desc', :start_date=>'desc').collect do |p|
pd_data = []
fields_to_show.collect do |t|
if t == "school_name"
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'personal_diploma')}'>#{p.send(t)}" }
elsif t == "duration"
if !p.send('start_date').nil? or !p.send('end_date').nil?
date = (p.send('start_date').strftime('%Y.%m') rescue "")+' ~ '+(p.send('end_date').strftime('%Y.%m') rescue I18n.t('personal_diploma.up_to_today'))
else
date = ""
end
pd_data << { "data_title" => date }
else
pd_data << { "data_title" => p.send(t) }
end
end
{
"pd_datas" => pd_data
}
end
return [pd_title,plugin_datas]
end
def get_plugin_data(fields_to_show) def get_plugin_data(fields_to_show)
plugin_datas = [] plugin_datas = []
fields_to_show.each do |field| fields_to_show.each do |field|

View File

@ -1,6 +1,5 @@
<% @diplomas.each do |diploma| %> <% @diplomas.each do |diploma| %>
<tr id="<%= dom_id diploma %>" class="<%= diploma.is_hidden ? "checkHide" : "" %>"> <tr id="<%= dom_id diploma %>" class="<%= diploma.is_hidden ? "checkHide" : "" %>">
<td><%= diploma.member_profile.name rescue "" %></td>
<td><%= diploma.duration %></td> <td><%= diploma.duration %></td>
<td> <td>
<%= link_to diploma.school_name, OrbitHelper.url_to_plugin_show(diploma.to_param,'personal_diploma'), target: "blank"%> <%= link_to diploma.school_name, OrbitHelper.url_to_plugin_show(diploma.to_param,'personal_diploma'), target: "blank"%>
@ -13,5 +12,6 @@
</td> </td>
<td><%= diploma.department %></td> <td><%= diploma.department %></td>
<td><%= diploma.degree %></td> <td><%= diploma.degree %></td>
<td><%= diploma.member_profile.name rescue "" %></td>
</tr> </tr>
<% end %> <% end %>

View File

@ -2,6 +2,7 @@
<% content_for :page_specific_css do %> <% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %> <%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/main-list" %> <%= stylesheet_link_tag "lib/main-list" %>
<%= stylesheet_link_tag "lib/main-form-col2" %>
<% end %> <% end %>
<% content_for :page_specific_javascript do %> <% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %> <%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
@ -12,103 +13,6 @@
<!-- Input Area --> <!-- Input Area -->
<div class="input-area"> <div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<div class="control-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id if !@member.nil? %>
</div>
</div>
<!-- start_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_diploma.start_date") %></label>
<div class="controls">
<%= f.datetime_picker :start_date, :no_label => true, :format=>"yyyy/MM", :placeholder=>"YYYY/MM" %>
</div>
</div>
<!-- end_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_diploma.end_date") %></label>
<div class="controls">
<%= f.datetime_picker :end_date, :no_label => true, :format=>"yyyy/MM", :placeholder=>"YYYY/MM" %>
</div>
</div>
<!-- language -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_diploma.language") %></label>
<div class="controls">
<select id="diploma_language" name="diploma[language]">
<% @site_in_use_locales.each do |locale| %>
<option value="<%= locale %>" <%= @diploma.language.eql?(locale.to_s) ? "selected" : ""%>><%= t(locale) %></option>
<% end %>
</select>
</div>
</div>
<!-- url -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_diploma.url") %></label>
<div class="controls">
<%= f.text_field :url, :class => "span5" %>
</div>
</div>
<!-- keywords -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_diploma.keywords") %></label>
<div class="controls">
<%= f.text_field :keywords, :class => "span5" %>
</div>
</div>
<!-- note -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_diploma.note") %></label>
<div class="controls">
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @diploma.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
</div>
<!-- Language Tabs --> <!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div> <div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav"> <ul class="nav nav-pills language-nav">
@ -172,6 +76,103 @@
</div> </div>
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id if !@member.nil? %>
</div>
</div>
<!-- start_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_diploma.start_date") %></label>
<div class="controls">
<%= f.datetime_picker :start_date, :no_label => true, :format=>"yyyy/MM", :placeholder=>"YYYY/MM" %>
</div>
</div>
<!-- end_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_diploma.end_date") %></label>
<div class="controls">
<%= f.datetime_picker :end_date, :no_label => true, :format=>"yyyy/MM", :placeholder=>"YYYY/MM" %>
</div>
</div>
<!-- language -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_diploma.language") %></label>
<div class="controls">
<select id="diploma_language" name="diploma[language]">
<% @site_in_use_locales.each do |locale| %>
<option value="<%= locale %>" <%= @diploma.language.eql?(locale.to_s) ? "selected" : ""%>><%= t(locale) %></option>
<% end %>
</select>
</div>
</div>
<!-- url -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_diploma.url") %></label>
<div class="controls">
<%= f.text_field :url, :class => "span5" %>
</div>
</div>
<!-- keywords -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_diploma.keywords") %></label>
<div class="controls">
<%= f.text_field :keywords, :class => "span5" %>
</div>
</div>
<!-- note -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_diploma.note") %></label>
<div class="controls">
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @diploma.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
</div>
</div> </div>
<!-- Form Actions --> <!-- Form Actions -->

View File

@ -1,11 +1,11 @@
<table class="table main-list"> <table class="table main-list">
<thead> <thead>
<tr> <tr>
<th class="span2"><%= t('users.name') %></th>
<th class="span3"><%= t('personal_diploma.duration') %></th> <th class="span3"><%= t('personal_diploma.duration') %></th>
<th class="span3"><%= t('personal_diploma.school_name') %></th> <th class="span3"><%= t('personal_diploma.school_name') %></th>
<th class="span2"><%= t('personal_diploma.department') %></th> <th class="span2"><%= t('personal_diploma.department') %></th>
<th class="span2"><%= t('personal_diploma.degree') %></th> <th class="span2"><%= t('personal_diploma.degree') %></th>
<th class="span1"><%= t('users.name') %></th>
</tr> </tr>
</thead> </thead>
<tbody id="tbody_diplomas" class="sort-holder"> <tbody id="tbody_diplomas" class="sort-holder">

View File

@ -18,6 +18,7 @@ en:
issue_no : "Issue.No" issue_no : "Issue.No"
form_to_start : "From" form_to_start : "From"
form_to_end : "To" form_to_end : "To"
up_to_today : "Up to today"
total_pages : "Total Pages" total_pages : "Total Pages"
keywords : "Keywords" keywords : "Keywords"
abstract : "Abstract" abstract : "Abstract"

View File

@ -19,7 +19,8 @@ zh_tw:
vol_no : "卷數" vol_no : "卷數"
issue_no : "期數" issue_no : "期數"
form_to_start : "起" form_to_start : "起"
form_to_end : "訖" form_to_end : "迄"
up_to_today : "迄今"
total_pages : "總頁數" total_pages : "總頁數"
keywords : "關鍵字" keywords : "關鍵字"
abstract : "摘要" abstract : "摘要"
@ -29,12 +30,11 @@ zh_tw:
level_type : "期刊類別" level_type : "期刊類別"
author_type : "作者類別" author_type : "作者類別"
from : "起" from : "起"
to : "" to : ""
file : "檔案" file : "檔案"
file_name : "檔案名稱" file_name : "檔案名稱"
description : "描述" description : "描述"
pages : "Pages" pages : "Pages"
country : "國家" country : "國家"
department : "系所" department : "系所"
degree : "學位" degree : "學位"