diff --git a/app/controllers/admin/journal_papers_controller.rb b/app/controllers/admin/journal_papers_controller.rb index 9f21bfb..3fb3c4e 100644 --- a/app/controllers/admin/journal_papers_controller.rb +++ b/app/controllers/admin/journal_papers_controller.rb @@ -30,11 +30,11 @@ class Admin::JournalPapersController < OrbitMemberController def new @journal_paper = JournalPaper.new - @members_data = JournalPaper.member_data rescue nil + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil end def edit - @members_data = JournalPaper.member_data rescue nil + @member = @journal_paper.member_profile end def create @@ -51,8 +51,6 @@ class Admin::JournalPapersController < OrbitMemberController end def update - @journal_paper_authors = @journal_paper.journal_paper_authors - respond_to do |format| if @journal_paper.update_attributes(journal_paper_attributes) format.html { redirect_to params['referer_url'] } diff --git a/app/controllers/journal_papers_controller.rb b/app/controllers/journal_papers_controller.rb index 0b419e7..cd2477c 100644 --- a/app/controllers/journal_papers_controller.rb +++ b/app/controllers/journal_papers_controller.rb @@ -29,6 +29,7 @@ class JournalPapersController < ApplicationController "journal_title", "level_type", "paper_type", + "author_name", "authors", "author_type", "year", @@ -41,6 +42,7 @@ class JournalPapersController < ApplicationController "total_pages", "isbn", "url", + "associated_project", "note", "file" ] diff --git a/app/models/journal_paper.rb b/app/models/journal_paper.rb index 39426e4..e321ecb 100644 --- a/app/models/journal_paper.rb +++ b/app/models/journal_paper.rb @@ -9,6 +9,9 @@ class JournalPaper field :paper_title, as: :slug_title, type: String, localize: true field :journal_title, type: String, localize: true + field :authors, type: String, localize: true + field :associated_project , type: String, localize: true + field :year, type: String field :language, type: String field :isbn, type: String @@ -22,6 +25,7 @@ class JournalPaper field :publication_date, type: DateTime field :url, type: String field :note, type: String + field :number_of_authors field :rss2_id paginates_per 10 @@ -34,12 +38,12 @@ class JournalPaper has_many :journal_paper_files, autosave: true, dependent: :destroy accepts_nested_attributes_for :journal_paper_files - has_and_belongs_to_many :journal_paper_authors, dependent: :destroy - accepts_nested_attributes_for :journal_paper_authors + # has_and_belongs_to_many :journal_paper_authors, dependent: :destroy + # accepts_nested_attributes_for :journal_paper_authors has_and_belongs_to_many :journal_paper_author_types - after_save :save_journal_paper_files, :save_journal_paper_authors + # after_save :save_journal_paper_files, :save_journal_paper_authors before_validation :add_http # validates :paper_title, presence: true @@ -48,7 +52,7 @@ class JournalPaper title = [] title << self.member_profile.name if self.member_profile_id.present? - title << (!self.journal_paper_authors.blank? ? "#{self.journal_paper_authors.collect{|j| j.name}.join(', ')}" : nil) + title << (!self.authors.blank? ? self.authors : nil) if !self.publication_date.nil? pd = self.publication_date.strftime("%Y-%m-%d").split('-') title << pd[0] @@ -62,41 +66,34 @@ class JournalPaper title.join(', ').gsub(', ,',',') end - def authors - authors = [] - authors << self.member_profile.name if self.member_profile_id.present? - authors << self.journal_paper_authors.collect{|j| j.name}.join(', ') unless self.journal_paper_authors.blank? - authors.join(', ') - end + # def self.member_data + # members = MemberProfile.all + # member_data = [] + # members.each do |m| + # if (m.first_name || m.last_name) + # member_data << {"memberId" => m.id.to_s, "memberName" => m.name} + # else + # member_data << {"memberId" => m.id.to_s, "memberName" => "No Name"} + # end + # end + # member_data.to_json + # end - def self.member_data - members = MemberProfile.all - member_data = [] - members.each do |m| - if (m.first_name || m.last_name) - member_data << {"memberId" => m.id.to_s, "memberName" => m.name} - else - member_data << {"memberId" => m.id.to_s, "memberName" => "No Name"} - end - end - member_data.to_json - end + # def save_journal_paper_files + # self.journal_paper_files.each do |t| + # if t.should_destroy + # t.destroy + # end + # end + # end - def save_journal_paper_files - self.journal_paper_files.each do |t| - if t.should_destroy - t.destroy - end - end - end - - def save_journal_paper_authors - self.journal_paper_authors.each do |t| - if t.should_destroy - t.destroy - end - end - end + # def save_journal_paper_authors + # self.journal_paper_authors.each do |t| + # if t.should_destroy + # t.destroy + # end + # end + # end def get_plugin_data(fields_to_show) plugin_datas = [] @@ -116,6 +113,14 @@ class JournalPaper value = self.journal_paper_author_types.collect{|type| type.title}.join(',') rescue "" when "paper_type" value = self.journal_paper_type.title rescue "" + when "author_name" + value = [] + ([I18n.locale]+(Site.first.in_use_locales-[I18n.locale])).each do |locale| + if self.member_profile.first_name_translations[locale] || self.member_profile.last_name_translations[locale] + value << "#{self.member_profile.first_name_translations[locale]} #{self.member_profile.last_name_translations[locale]}" + end + end + value = value.join(" / ") when "publication_date" value = self.publication_date.to_date.strftime("%Y-%m-%d") rescue "" when "language" diff --git a/app/views/admin/journal_papers/_form.html.erb b/app/views/admin/journal_papers/_form.html.erb index 793efd0..46f5fd0 100644 --- a/app/views/admin/journal_papers/_form.html.erb +++ b/app/views/admin/journal_papers/_form.html.erb @@ -20,8 +20,7 @@
- -
- -
- -
- <%= f.text_field :member_profile_id, id: "member_autocomplete", autocomplete: "off", data: { provide: "typeahead"}, class: "input-block-level", value: (@journal_paper.member_profile.name rescue nil), placeholder: t("personal_journal.author")%> - - <%= f.hidden_field :member_profile_id, value: (@journal_paper.member_profile_id ? @journal_paper.member_profile_id : ""), id: "member_value" %> -
-
-
@@ -109,6 +99,22 @@
+ +
+ +
+ <%= f.text_field :number_of_authors, :class=>'span1' %> +
+
+ + +
+ +
+ <%= f.text_field :associated_project %> +
+
+
@@ -161,7 +167,7 @@
- <%= f.datetime_picker :publication_date, :no_label => true %> + <%= f.datetime_picker :publication_date, :no_label => true, :format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD" %>
@@ -228,7 +234,7 @@
-
+
<%= f.fields_for :paper_title_translations do |f| %> <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_journal.paper_title"), value: (@journal_paper.paper_title_translations[locale] rescue nil) %> <% end %> @@ -238,39 +244,26 @@
-
+
<%= f.fields_for :journal_title_translations do |f| %> <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_journal.journal_title"), value: (@journal_paper.journal_title_translations[locale] rescue nil) %> <% end %>
+ +
+ +
+ <%= f.fields_for :authors_translations do |f| %> + <%= f.text_area locale, class: "input-block-level", placeholder: t("personal_journal.authors"), value: (@journal_paper.authors_translations[locale] rescue nil) %> + <% end %> +
+
+
<% end %> -
- -
- - <% if @journal_paper && !@journal_paper.journal_paper_authors.blank? %> -
- <% @journal_paper.journal_paper_authors.each_with_index do |author, i| %> - <%= f.fields_for :journal_paper_authors, author do |f| %> - <%= render :partial => 'form_author', :object => author, :locals => {:f => f, :i => i} %> - <% end %> - <% end %> -
-
- <% end %> - - -
-
-

- <%= t(:add) %> -

-
-
@@ -299,12 +292,8 @@
- -
- -
@@ -313,7 +302,6 @@ <%= f.submit t('submit'), class: 'btn btn-primary' %> <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
- <%= render 'author_autocomplete'%> - \ No newline at end of file diff --git a/app/views/admin/journal_papers/_form_file.html.erb b/app/views/admin/journal_papers/_form_file.html.erb index 0a3aaab..7d52692 100644 --- a/app/views/admin/journal_papers/_form_file.html.erb +++ b/app/views/admin/journal_papers/_form_file.html.erb @@ -5,7 +5,7 @@ <% if form_file.journal_file.blank? %> <%= t(:no_file) %> <% else %> - <%= link_to content_tag(:i) + form_file.title, form_file.journal_file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.title} %> + <%= link_to content_tag(:i) + form_file.journal_file_identifier, form_file.journal_file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.journal_file_identifier} %> <% end %> <% end %>
diff --git a/app/views/plugin/journal_paper/_profile.html.erb b/app/views/plugin/journal_paper/_profile.html.erb index bcab675..3925104 100644 --- a/app/views/plugin/journal_paper/_profile.html.erb +++ b/app/views/plugin/journal_paper/_profile.html.erb @@ -6,29 +6,11 @@ <% end %> <% - @filter = params[:filter] - new_filter = params[:new_filter] - - if @filter && params[:clear] - @filter.delete(params[:type]) - elsif @filter && new_filter - if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s) - @filter[new_filter[:type]].delete(new_filter[:id].to_s) - elsif @filter.has_key?(new_filter[:type]) - @filter[new_filter[:type]] << new_filter[:id].to_s - else - @filter.merge!({new_filter[:type] => [new_filter[:id].to_s]}) - end - elsif new_filter - @filter = {new_filter[:type] => [new_filter[:id].to_s]} - end - if has_access? @writing_journals = JournalPaper.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10) else @writing_journals = JournalPaper.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10) end - %> <% if has_access? %> @@ -69,7 +51,7 @@
@@ -90,10 +72,10 @@
<%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),admin_journal_paper_intros_path(member_profile_id: @member.id), :class => 'btn btn-primary' %> - <%= link_to content_tag(:i, nil, :class => 'icon-plus') + t('new_'), new_admin_journal_paper_path(member_profile_id: @member.id), :class => 'btn btn-primary' %> + <%= link_to content_tag(:i, nil, :class => 'icon-plus') + t('new_'), '/admin/members/'+@member.to_param+'/journal_papers/new', :class => 'btn btn-primary' %>
<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index d5fd8f1..ae31ccc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -6,6 +6,7 @@ en: journal_title : "Journal Title" authors : "Authors" author: "Author" + author_name: "Author Name" co-authors: "Co-Authors" tags : "Tags" year : "Year" diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index a68e1a4..63180f3 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -2,10 +2,13 @@ zh_tw: module_name: journal_paper: 期刊論文 personal_journal: + associated_project: "所屬計畫案" + number_of_authors: "著作人數" paper_title : "論文名稱" journal_title : "期刊名稱" - authors : "作者" + authors : "全部作者" author: "作者" + author_name: "作者姓名" tags : "領域" year : "年度" language : "語言" diff --git a/config/routes.rb b/config/routes.rb index 41cc017..b39af43 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,20 @@ Rails.application.routes.draw do match "add_paper_type" => "journal_papers#add_paper_type" ,as: :add_paper_type, via: [:get, :post] match "edit_paper_type" => "journal_papers#edit_paper_type" ,as: :edit_paper_type, via: [:get, :post] end + + resources :members do + collection do + scope '(:name-:uid)' do + resources :journal_papers do + collection do + get 'frontend_setting' => 'journal_papers#frontend_setting' + post 'update_frontend_setting' => 'journal_papers#update_frontend_setting' + end + end + end + end + end + resources :journal_levels resources :journal_paper_author_types resources :journal_paper_types