forked from saurabh/personal-project
something fix
This commit is contained in:
parent
b27d11a045
commit
4cfaf42ea6
|
@ -3,10 +3,12 @@ class PersonalProjectsController < ApplicationController
|
|||
projects = Project.where(:is_hidden=>false).order_by(:period_start_date=>'desc',:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
||||
project_list = projects.collect do |project|
|
||||
{
|
||||
"year" => project.year,
|
||||
"duration" => project.duration,
|
||||
"project_title" => project.project_title,
|
||||
"job_title" => project.job_title,
|
||||
"participator" => project.participator,
|
||||
"unit" => project.unit,
|
||||
"authors" => (project.member_profile.name rescue ""),
|
||||
"link_to_show" => OrbitHelper.url_to_show(project.to_param)
|
||||
}
|
||||
|
@ -15,10 +17,12 @@ class PersonalProjectsController < ApplicationController
|
|||
"projects" => project_list,
|
||||
"extras" => {
|
||||
"widget-title" => t("module_name.personal_project"),
|
||||
"th_year" => t('personal_project.year'),
|
||||
"th_duration" => t('personal_project.period'),
|
||||
"th_project_title" => t("personal_project.project_title"),
|
||||
"th_job_title" => t('personal_project.job_title'),
|
||||
"th_participator" => t("personal_project.participator"),
|
||||
"th_unit" => t("personal_project.unit"),
|
||||
"th_authors" => t('users.name')
|
||||
},
|
||||
"total_pages" => projects.total_pages
|
||||
|
@ -29,19 +33,17 @@ class PersonalProjectsController < ApplicationController
|
|||
params = OrbitHelper.params
|
||||
plugin = Project.where(:is_hidden=>false).find_by(uid: params[:uid])
|
||||
fields_to_show = [
|
||||
"project_title",
|
||||
"project_type",
|
||||
"job_title",
|
||||
"participator",
|
||||
"unit",
|
||||
"year",
|
||||
"language",
|
||||
"keywords",
|
||||
"abstract",
|
||||
"project_type",
|
||||
"project_title",
|
||||
"participator",
|
||||
"job_title",
|
||||
"period",
|
||||
"unit",
|
||||
"abstract",
|
||||
"url",
|
||||
"note",
|
||||
"file"
|
||||
"file",
|
||||
"language",
|
||||
]
|
||||
|
||||
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
|
||||
|
|
|
@ -2,6 +2,7 @@ class Project
|
|||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include OrbitModel::Status
|
||||
include MemberHelper
|
||||
include Slug
|
||||
|
||||
belongs_to :project_type
|
||||
|
@ -11,7 +12,6 @@ class Project
|
|||
field :job_title, localize: true
|
||||
field :participator, localize: true
|
||||
field :unit, localize: true
|
||||
field :note, localize: true
|
||||
|
||||
field :year
|
||||
field :language
|
||||
|
@ -20,6 +20,7 @@ class Project
|
|||
field :period_start_date, :type => Date
|
||||
field :period_end_date, :type => Date
|
||||
field :url
|
||||
field :note
|
||||
|
||||
field :rss2_id
|
||||
field :create_user_id, :type => BSON::ObjectId
|
||||
|
@ -37,6 +38,53 @@ class Project
|
|||
"#{self.period_start_date.strftime("%Y.%m") rescue ""} ~ #{self.period_end_date.strftime("%Y.%m") rescue ""}"
|
||||
end
|
||||
|
||||
def self.get_plugin_datas_to_member(datas)
|
||||
|
||||
fields_to_show = [
|
||||
"year",
|
||||
"project_title",
|
||||
"participator",
|
||||
"job_title",
|
||||
"period",
|
||||
"unit"
|
||||
]
|
||||
|
||||
pd_title = fields_to_show.collect do |t|
|
||||
{
|
||||
"plugin_data_title" => I18n.t("personal_project.#{t}")
|
||||
}
|
||||
end
|
||||
|
||||
plugin_datas = datas.where(:is_hidden=>false).order_by(:period_start_date=>'desc',:year=>'desc').collect do |p|
|
||||
|
||||
pd_data = []
|
||||
fields_to_show.collect do |t|
|
||||
if t == "project_title"
|
||||
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'personal_project')}'>#{p.send(t)}" }
|
||||
elsif t == "period"
|
||||
|
||||
if !p.send('period_start_date').nil? or !p.send('period_end_date').nil?
|
||||
date = (p.send('period_start_date').strftime('%Y.%m') rescue "")+' ~ '+(p.send('period_end_date').strftime('%Y.%m') rescue I18n.t('personal_project.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)
|
||||
plugin_datas = []
|
||||
fields_to_show.each do |field|
|
||||
|
@ -55,6 +103,8 @@ class Project
|
|||
value = self.project_type.title rescue ""
|
||||
when "period"
|
||||
value = self.duration
|
||||
when "abstract"
|
||||
value = nl2br(self.abstract)
|
||||
when "file"
|
||||
files = []
|
||||
self.project_files.each do |project_file|
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<%= stylesheet_link_tag "lib/main-form-col2" %>
|
||||
<% end %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
||||
|
@ -15,117 +16,6 @@
|
|||
<!-- 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>
|
||||
|
||||
<!-- year -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.year") %></label>
|
||||
<div class="controls">
|
||||
<%= select_year((@project.year ? @project.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'project[year]',:class => 'span1'} ) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- project_category -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.project_category") %></label>
|
||||
<div class="controls">
|
||||
<%= f.select :project_type_id, @project_types.collect {|t| [ t.title, t.id ]} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- period_start_date -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.start_date") %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :period_start_date, :no_label => true, :format=>"yyyy/MM" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- period_end_date -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.end_date") %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :period_end_date, :no_label => true, :format=>"yyyy/MM" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- url -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.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_project.keywords") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :keywords %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- language -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.language") %></label>
|
||||
<div class="controls">
|
||||
<select id="project_language" name="project[language]">
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<option value="<%= locale %>" <%= @project.language.eql?(locale.to_s) ? "selected" : ""%>><%= t(locale) %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- abstract -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.abstract") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_area :abstract, rows: 2, class: "input-block-level" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Status Module -->
|
||||
<div class="tab-pane fade" id="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 @project.is_hidden? %>">
|
||||
<%= f.check_box :is_hidden %> <%= t(:hide) %>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Language Tabs -->
|
||||
<div class="nav-name"><strong><%= t(:language) %></strong></div>
|
||||
<ul class="nav nav-pills language-nav">
|
||||
|
@ -183,16 +73,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- note -->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_project.note") %></label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :note_translations do |f| %>
|
||||
<%= f.text_area locale, rows: 2, class: "input-block-level", value: (@project.note_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
@ -226,6 +106,126 @@
|
|||
</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>
|
||||
|
||||
<!-- year -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.year") %></label>
|
||||
<div class="controls">
|
||||
<%= select_year((@project.year ? @project.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'project[year]',:class => 'span1'} ) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- language -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.language") %></label>
|
||||
<div class="controls">
|
||||
<select id="project_language" name="project[language]">
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<option value="<%= locale %>" <%= @project.language.eql?(locale.to_s) ? "selected" : ""%>><%= t(locale) %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- project_category -->
|
||||
<div class="control-group big-group">
|
||||
<label class="control-label muted"><%= t("personal_project.project_category") %></label>
|
||||
<div class="controls">
|
||||
<%= f.select :project_type_id, @project_types.collect {|t| [ t.title, t.id ]} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- period_start_date -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.start_date") %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :period_start_date, :no_label => true, :format=>"yyyy/MM" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- period_end_date -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.end_date") %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :period_end_date, :no_label => true, :format=>"yyyy/MM" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- url -->
|
||||
<div class="control-group big-group">
|
||||
<label class="control-label muted"><%= t("personal_project.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_project.keywords") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :keywords %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- abstract -->
|
||||
<div class="control-group big-group">
|
||||
<label class="control-label muted"><%= t("personal_project.abstract") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_area :abstract, rows: 2, class: "input-block-level" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- note -->
|
||||
<div class="control-group big-group">
|
||||
<label class="control-label muted"><%= t("personal_project.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">
|
||||
<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 @project.is_hidden? %>">
|
||||
<%= f.check_box :is_hidden %> <%= t(:hide) %>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Form Actions -->
|
||||
|
|
|
@ -22,6 +22,7 @@ en:
|
|||
issue_no : "Issue.No"
|
||||
form_to_start : "From"
|
||||
form_to_end : "To"
|
||||
up_to_today : "Up to today"
|
||||
total_pages : "Total Pages"
|
||||
keywords : "Keywords"
|
||||
abstract : "Abstract"
|
||||
|
|
|
@ -21,7 +21,8 @@ zh_tw:
|
|||
vol_no : "卷數"
|
||||
issue_no : "期數"
|
||||
form_to_start : "起"
|
||||
form_to_end : "訖"
|
||||
form_to_end : "迄"
|
||||
up_to_today : "迄今"
|
||||
total_pages : "總頁數"
|
||||
keywords : "關鍵字"
|
||||
abstract : "摘要"
|
||||
|
@ -31,7 +32,7 @@ zh_tw:
|
|||
level_type : "期刊類別"
|
||||
author_type : "作者類別"
|
||||
from : "起"
|
||||
to : "訖"
|
||||
to : "迄"
|
||||
file : "檔案"
|
||||
file_name : "檔案名稱"
|
||||
description : "描述"
|
||||
|
|
Loading…
Reference in New Issue