diff --git a/app/controllers/personal_projects_controller.rb b/app/controllers/personal_projects_controller.rb index 68a50b5..8a25308 100644 --- a/app/controllers/personal_projects_controller.rb +++ b/app/controllers/personal_projects_controller.rb @@ -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)} diff --git a/app/models/project.rb b/app/models/project.rb index 7bc9428..68c05ec 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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" => "#{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| diff --git a/app/views/admin/projects/_form.html.erb b/app/views/admin/projects/_form.html.erb index 7a79ff0..56c2982 100644 --- a/app/views/admin/projects/_form.html.erb +++ b/app/views/admin/projects/_form.html.erb @@ -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 @@
- - - - - -
- - -
- -
- -
- <%= @member.name rescue ''%> - <%= f.hidden_field :member_profile_id, :value => @member.id if !@member.nil? %> -
-
- - -
- -
- <%= select_year((@project.year ? @project.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'project[year]',:class => 'span1'} ) %> -
-
- - -
- -
- <%= f.select :project_type_id, @project_types.collect {|t| [ t.title, t.id ]} %> -
-
- - -
- -
- <%= f.datetime_picker :period_start_date, :no_label => true, :format=>"yyyy/MM" %> -
-
- - -
- -
- <%= f.datetime_picker :period_end_date, :no_label => true, :format=>"yyyy/MM" %> -
-
- - -
- -
- <%= f.text_field :url , :class => "span5" %> -
-
- - -
- -
- <%= f.text_field :keywords %> -
-
- - -
- -
- -
-
- - -
- -
- <%= f.text_area :abstract, rows: 2, class: "input-block-level" %> -
-
- - -
- - -
-
- -
- -
-
-
- -
-
- -
- -
- <%= 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 %> -
-
- <% end %> @@ -226,6 +106,126 @@ + + + + + + +
+ + +
+ +
+ +
+ <%= @member.name rescue ''%> + <%= f.hidden_field :member_profile_id, :value => @member.id if !@member.nil? %> +
+
+ + +
+ +
+ <%= select_year((@project.year ? @project.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'project[year]',:class => 'span1'} ) %> +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ <%= f.select :project_type_id, @project_types.collect {|t| [ t.title, t.id ]} %> +
+
+ + +
+ +
+ <%= f.datetime_picker :period_start_date, :no_label => true, :format=>"yyyy/MM" %> +
+
+ + +
+ +
+ <%= f.datetime_picker :period_end_date, :no_label => true, :format=>"yyyy/MM" %> +
+
+ + +
+ +
+ <%= f.text_field :url , :class => "span5" %> +
+
+ + +
+ +
+ <%= f.text_field :keywords %> +
+
+ + +
+ +
+ <%= f.text_area :abstract, rows: 2, class: "input-block-level" %> +
+
+ + +
+ +
+ <%= f.text_area :note, rows: 2, class: "input-block-level" %> +
+
+ + +
+ + +
+
+ +
+ +
+
+
+ +
+ diff --git a/config/locales/en.yml b/config/locales/en.yml index 63859ad..f37dd1b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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" diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 52bf83c..dc35c66 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -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 : "描述"