Update fields and fix bugs
This commit is contained in:
parent
b763b047eb
commit
736ba69bc4
|
@ -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'] }
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
<div class="input-area">
|
||||
|
||||
<!-- Module Tabs -->
|
||||
<div class="nav-name"><strong><%= t(:module) %></strong></div>
|
||||
<ul class="nav nav-pills module-nav">
|
||||
<ul class="nav nav-pills module-nav">
|
||||
<li></li>
|
||||
<li class="active">
|
||||
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
|
||||
|
@ -37,16 +36,13 @@
|
|||
<!-- Basic Module -->
|
||||
<div class="tab-pane fade in active" id="basic">
|
||||
|
||||
<% if !params[:user_id].blank? %>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
|
||||
<div class="controls">
|
||||
<%= User.from_id(params[:user_id]).name rescue ''%>
|
||||
<%= @member.name rescue ''%>
|
||||
<%= f.hidden_field :member_profile_id, :value => @member.id %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- year -->
|
||||
<div class="control-group">
|
||||
|
@ -60,7 +56,11 @@
|
|||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_journal.language") %></label>
|
||||
<div class="controls">
|
||||
<%= f.select :language, @site_valid_locales, :prompt => 'Select', :class => "span3" %>
|
||||
<select id="journal_paper_language" name="journal_paper[language]">
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<option value="<%= locale %>" <%= @journal_paper.language.eql?(locale.to_s) ? "selected" : ""%>><%= t(locale) %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -86,16 +86,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- authors-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_journal.author") %></label>
|
||||
<div class="controls">
|
||||
<%= 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" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- author_type -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_journal.author_type") %></label>
|
||||
|
@ -109,6 +99,22 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- number_of_authors -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_journal.number_of_authors") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :number_of_authors, :class=>'span1' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- associated_project -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_journal.associated_project") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :associated_project %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- vol_no -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_journal.vol_no") %></label>
|
||||
|
@ -161,7 +167,7 @@
|
|||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_journal.publication_date") %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :publication_date, :no_label => true %>
|
||||
<%= f.datetime_picker :publication_date, :no_label => true, :format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -228,7 +234,7 @@
|
|||
<!-- paper_title-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_journal.paper_title") %></label>
|
||||
<div class="controls">
|
||||
<div class="controls">
|
||||
<%= 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 @@
|
|||
<!-- journal_title-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_journal.journal_title") %></label>
|
||||
<div class="controls">
|
||||
<div class="controls">
|
||||
<%= 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 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- authors-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_journal.authors") %></label>
|
||||
<div class="controls">
|
||||
<%= 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 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_journal.co-authors") %></label>
|
||||
<div class="controls">
|
||||
|
||||
<% if @journal_paper && !@journal_paper.journal_paper_authors.blank? %>
|
||||
<div class="exist">
|
||||
<% @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 %>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Add -->
|
||||
<div class="add-target-box">
|
||||
</div>
|
||||
<p class="add-btn-box">
|
||||
<a id="add_author" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- File -->
|
||||
<div class="control-group">
|
||||
|
@ -299,12 +292,8 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Form Actions -->
|
||||
|
@ -313,7 +302,6 @@
|
|||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
|
||||
</div>
|
||||
<%= render 'author_autocomplete'%>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.main-forms .add-on').tooltip();
|
||||
|
@ -339,30 +327,4 @@
|
|||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.main-forms .add-on').tooltip();
|
||||
$(document).on('click', '#add_author', function(){
|
||||
var new_id = $(this).prev().attr('value');
|
||||
var old_id = new RegExp("new_authors", "g");
|
||||
var on = $('.language-nav li.active').index();
|
||||
var le = $(this).parent('.add-btn-box').prev('.add-target-box').children('.start-line').length;
|
||||
$(this).prev().attr('value', parseInt(new_id) + 1);
|
||||
$(this).parent().siblings('.add-target-box').append(("<%= escape_javascript(add_attribute 'form_author', f, :journal_paper_authors) %>").replace(old_id, new_id));
|
||||
$(this).parent('.add-btn-box').prev('.add-target-box').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
|
||||
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
|
||||
});
|
||||
formTip();
|
||||
});
|
||||
$(document).on('click', '.delete_file', function(){
|
||||
$(this).parents('.input-prepend').remove();
|
||||
});
|
||||
$(document).on('click', '.remove_existing_record', function(){
|
||||
if(confirm("<%= I18n.t(:sure?)%>")){
|
||||
$(this).children('.should_destroy').attr('value', 1);
|
||||
$(this).parents('.start-line').hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -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 %>
|
||||
<div class="input-prepend input-append">
|
||||
|
|
|
@ -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 @@
|
|||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills hide">
|
||||
<% if has_access? %>
|
||||
<li><%= link_to t('edit'), edit_admin_journal_paper_path(writing_journal, member_profile_id: @member.id) %></li>
|
||||
<li><%= link_to t('edit'), edit_admin_journal_paper_path(writing_journal) %></li>
|
||||
<li><%= link_to t(:delete_), admin_journal_paper_path(id: writing_journal.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
@ -90,10 +72,10 @@
|
|||
<div class="action pull-right">
|
||||
<%= 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' %>
|
||||
</div>
|
||||
<div class="pagination pagination-centered">
|
||||
<%= paginate @writing_journals, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>
|
||||
<%= paginate @writing_journals, :params => {:direction => params[:direction], :sort => params[:sort]} %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 : "語言"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue