Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create, Realize, Produceモデルにnameを追加 #1843

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
14 changes: 5 additions & 9 deletions app/helpers/enju_biblio/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,14 @@ def agent_type_icon(agent_type)
end
end

def agents_list(agents = [], options = {})
return nil if agents.blank?

agents_list = []
def agents_list(authors, options = {})
list = []
if options[:nolink]
agents_list = agents.map{|agent| agent.full_name}
return authors.pluck(:name)
else
agents_list = agents.map{|agent|
link_to(agent.full_name, manifestations_path(query: "\"#{agent.full_name}\""), options) + ' ' + (link_to("[A]", agent_path(agent)) if agent.ndla_record)
}
list = authors.map{|author| link_to(author.name, manifestations_path(query: "\"#{author.name}\""), options)}
list.join(" ").html_safe
end
agents_list.join(" ").html_safe
end

def ndl_bib_id_record_link(ndl_bib_id_record)
Expand Down
1 change: 1 addition & 0 deletions app/models/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ def reindex
# created_at :datetime not null
# updated_at :datetime not null
# create_type_id :bigint
# name :text
#
6 changes: 3 additions & 3 deletions app/models/manifestation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class Manifestation < ApplicationRecord
has_one :lccn_record, dependent: :destroy
has_one :ndl_bib_id_record, dependent: :destroy

accepts_nested_attributes_for :creators, allow_destroy: true, reject_if: :all_blank
accepts_nested_attributes_for :contributors, allow_destroy: true, reject_if: :all_blank
accepts_nested_attributes_for :publishers, allow_destroy: true, reject_if: :all_blank
accepts_nested_attributes_for :creates, allow_destroy: true, reject_if: :all_blank
accepts_nested_attributes_for :realizes, allow_destroy: true, reject_if: :all_blank
accepts_nested_attributes_for :produces, allow_destroy: true, reject_if: :all_blank
accepts_nested_attributes_for :series_statements, allow_destroy: true, reject_if: :all_blank
accepts_nested_attributes_for :identifiers, allow_destroy: true, reject_if: :all_blank
accepts_nested_attributes_for :manifestation_custom_values, reject_if: :all_blank
Expand Down
1 change: 1 addition & 0 deletions app/models/produce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ def reindex
# created_at :datetime not null
# updated_at :datetime not null
# produce_type_id :bigint
# name :text
#
1 change: 1 addition & 0 deletions app/models/realize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ def reindex
# created_at :datetime not null
# updated_at :datetime not null
# realize_type_id :bigint
# name :text
#
18 changes: 9 additions & 9 deletions app/views/agents/_expression_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<ul>
<%- @expressions.each do |manifestation| -%>
<li>
[M]
<%= link_to manifestation.original_title, manifestation -%>
<%= form_icon(manifestation.carrier_type) -%>
<%= agents_list(manifestation.creators.readable_by(current_user)) -%>
<%= agents_list(manifestation.contributors.readable_by(current_user)) -%>
<%= agents_list(manifestation.publishers.readable_by(current_user)) -%>
<%- if manifestation.pub_date? -%>
(<%= manifestation.pub_date -%>)
<%- end -%>
[M]
<%= link_to manifestation.original_title, manifestation -%>
<%= form_icon(manifestation.carrier_type) -%>
<%= agents_list(manifestation.creates) -%>
<%= agents_list(manifestation.realizes) -%>
<%= agents_list(manifestation.produces) -%>
<%- if manifestation.pub_date? -%>
(<%= manifestation.pub_date -%>)
<%- end -%>
</li>
<%- end -%>
</ul>
Expand Down
6 changes: 3 additions & 3 deletions app/views/agents/_manifestation_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
[M]
<%= link_to manifestation.original_title, manifestation -%>
<%= form_icon(manifestation.carrier_type) -%>
<%= agents_list(manifestation.creators.readable_by(current_user)) -%>
<%= agents_list(manifestation.contributors.readable_by(current_user)) -%>
<%= agents_list(manifestation.publishers.readable_by(current_user)) -%>
<%= agents_list(manifestation.creates) -%>
<%= agents_list(manifestation.realizes) -%>
<%= agents_list(manifestation.produces) -%>
<%- if manifestation.pub_date? -%>
(<%= manifestation.pub_date -%>)
<%- end -%>
Expand Down
2 changes: 1 addition & 1 deletion app/views/agents/_work_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<li>
[W]
<%= link_to work.original_title, work -%>
<%= agents_list(work.creators.readable_by(current_user)) -%>
<%= agents_list(work.creates) -%>
</li>
<%- end -%>
</ul>
Expand Down
4 changes: 4 additions & 0 deletions app/views/manifestations/_create_fields.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="nested-fields">
<%= f.text_field :name, class: 'creator_name resource_name' %>
<%= link_to_remove_association t('page.remove'), f, data: {confirm: t('page.are_you_sure')} %><br />
</div>
18 changes: 9 additions & 9 deletions app/views/manifestations/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -71,31 +71,31 @@

<div class="field" id="creator_form">
<%= f.label :creator_string -%><br />
<%= f.fields_for :creators, @manifestation.creators.order(Create.arel_table[:position].asc) do |creator_form| %>
<%= render 'creator_fields', f: creator_form %>
<%= f.fields_for :creates, @manifestation.creates.order(:position) do |create_form| %>
<%= render 'create_fields', f: create_form %>
<% end %>
<div class="links">
<p><%= link_to_add_association t('page.add'), f, :creators %></p>
<p><%= link_to_add_association t('page.add'), f, :creates %></p>
</div>
</div>

<div class="field" id="contributor_form">
<%= f.label :contributor_string -%><br />
<%= f.fields_for :contributors, @manifestation.contributors.order(Realize.arel_table[:position].asc) do |contributor_form| %>
<%= render 'contributor_fields', f: contributor_form %>
<%= f.fields_for :realizes, @manifestation.realizes.order(:position) do |realize_form| %>
<%= render 'realize_fields', f: realize_form %>
<% end %>
<div class="links">
<p><%= link_to_add_association t('page.add'), f, :contributors %></p>
<p><%= link_to_add_association t('page.add'), f, :realizes %></p>
</div>
</div>

<div class="field" id="publisher_form">
<%= f.label :publisher_string -%><br />
<%= f.fields_for :publishers, @manifestation.publishers.order(Produce.arel_table[:position].asc) do |publisher_form| %>
<%= render 'publisher_fields', f: publisher_form %>
<%= f.fields_for :produces, @manifestation.produces.order(:position) do |produce_form| %>
<%= render 'produce_fields', f: produce_form %>
<% end %>
<div class="links">
<p><%= link_to_add_association t('page.add'), f, :publishers %></p>
<p><%= link_to_add_association t('page.add'), f, :produces %></p>
</div>
</div>

Expand Down
12 changes: 6 additions & 6 deletions app/views/manifestations/_manifestation_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<%= link_to manifestation.original_title, manifestation -%>
<%= form_icon(manifestation.carrier_type) -%>
<%= link_to image_tag('icons/world_go.png', size: '16x16', class: 'enju_icon', alt: t('manifestation.web')), manifestation.access_address if manifestation.access_address? -%>
<%= agents_list(manifestation.creators.readable_by(current_user)) -%>
<%= agents_list(manifestation.contributors.readable_by(current_user)) -%>
<%= agents_list(manifestation.publishers.readable_by(current_user)) -%>
<%= agents_list(manifestation.creates) -%>
<%= agents_list(manifestation.realizes) -%>
<%= agents_list(manifestation.produces) -%>
<%- if manifestation.pub_date? -%>
(<%= manifestation.pub_date -%>)
<%- end -%>
Expand All @@ -20,9 +20,9 @@
<%= link_to manifestation.original_title, manifestation -%>
<%= form_icon(manifestation.carrier_type) -%>
<%= link_to image_tag('icons/world_go.png', size: '16x16', class: 'enju_icon', alt: t('manifestation.web')), manifestation.access_address if manifestation.access_address? -%>
<%= agents_list(manifestation.creators.readable_by(current_user)) -%>
<%= agents_list(manifestation.contributors.readable_by(current_user)) -%>
<%= agents_list(manifestation.publishers.readable_by(current_user)) -%>
<%= agents_list(manifestation.creates) -%>
<%= agents_list(manifestation.realizes) -%>
<%= agents_list(manifestation.produces) -%>
<%- if manifestation.pub_date? -%>
(<%= manifestation.pub_date -%>)
<%- end -%>
Expand Down
4 changes: 4 additions & 0 deletions app/views/manifestations/_produce_fields.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="nested-fields">
<%= f.text_field :name, class: 'resource_name' %>
<%= link_to_remove_association t('page.remove'), f, data: {confirm: t('page.are_you_sure')} %><br />
</div>
4 changes: 4 additions & 0 deletions app/views/manifestations/_realize_fields.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="nested-fields">
<%= f.text_field :name, class: 'resource_name' %>
<%= link_to_remove_association t('page.remove'), f, data: {confirm: t('page.are_you_sure')} %><br />
</div>
30 changes: 15 additions & 15 deletions app/views/manifestations/_show_creators.html+phone.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<%- if params[:mode] == 'show_all_creators' -%>
<%= agents_list(manifestation.creators.readable_by(current_user)) %>
<%- if manifestation.creators.readable_by(current_user).size > 5 -%>
(<a href="#" onclick="$.ajax({data:'authenticity_token=' + encodeURIComponent('<%= form_authenticity_token %>'), success:function(request){$('#creator_list_<%= manifestation.id %>').html(request);}, type:'get', url:'<%= manifestation_path(manifestation, index_num: manifestation.id, mode: 'show_creators') %>'}); return false;"><%= t('page.hide') %></a>)
<%- end -%>
<%- else -%>
<%= agents_list(manifestation.creators.readable_by(current_user)[0..2]) %>
<%- if manifestation.creators.readable_by(current_user).size > 5 -%>
(<a href="#" onclick="$.ajax({data:'authenticity_token=' + encodeURIComponent('<%= form_authenticity_token %>'), success:function(request){$('#creator_list_<%= manifestation.id %>').html(request);}, type:'get', url:'<%= manifestation_path(manifestation, index_num: manifestation.id, mode: 'show_all_creators') %>'}); return false;"><%= t('page.show_all') %></a>)
<%- end -%>
<%- if params[:mode] == 'show_all_creators' -%>
<%= agents_list(manifestation.creates) %>
<%- if manifestation.creates.count > 5 -%>
(<a href="#" onclick="$.ajax({data:'authenticity_token=' + encodeURIComponent('<%= form_authenticity_token %>'), success:function(request){$('#creator_list_<%= manifestation.id %>').html(request);}, type:'get', url:'<%= manifestation_path(manifestation, index_num: manifestation.id, mode: 'show_creators') %>'}); return false;"><%= t('page.hide') %></a>)
<%- end -%>

<%= agents_list(manifestation.contributors.readable_by(current_user)) %>
<%= agents_list(manifestation.publishers.readable_by(current_user)) %>
<%- if manifestation.pub_date.present? -%>
(<%= manifestation.pub_date -%>)
<%- else -%>
<%= agents_list(manifestation.creates[0..2]) %>
<%- if manifestation.creates.count > 5 -%>
(<a href="#" onclick="$.ajax({data:'authenticity_token=' + encodeURIComponent('<%= form_authenticity_token %>'), success:function(request){$('#creator_list_<%= manifestation.id %>').html(request);}, type:'get', url:'<%= manifestation_path(manifestation, index_num: manifestation.id, mode: 'show_all_creators') %>'}); return false;"><%= t('page.show_all') %></a>)
<%- end -%>
<%- end -%>

<%= agents_list(manifestation.realizes) %>
<%= agents_list(manifestation.produces) %>
<%- if manifestation.pub_date.present? -%>
(<%= manifestation.pub_date -%>)
<%- end -%>
39 changes: 19 additions & 20 deletions app/views/manifestations/_show_creators.html.erb
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<%- if params[:mode] == 'show_all_creators' -%>
<%= agents_list(manifestation.creators.readable_by(current_user)) %>
<%- if manifestation.creators.readable_by(current_user).size > 5 -%>
(<a href="#" onclick="$.ajax({data:'authenticity_token=' + encodeURIComponent('<%= form_authenticity_token %>'), success:function(request){$('#creator_list_<%= manifestation.id %>').html(request);}, type:'get', url:'<%= manifestation_path(manifestation, index_num: manifestation.id, mode: 'show_creators') %>'}); return false;"><%= t('page.hide') %></a>)
<%- end -%>
<%- else -%>
<%= agents_list(manifestation.creators.readable_by(current_user)[0..2]) %>
<%- if manifestation.creators.readable_by(current_user).size > 5 -%>
(<a href="#" onclick="$.ajax({data:'authenticity_token=' + encodeURIComponent('<%= form_authenticity_token %>'), success:function(request){$('#creator_list_<%= manifestation.id %>').html(request);}, type:'get', url:'<%= manifestation_path(manifestation, index_num: manifestation.id, mode: 'show_all_creators') %>'}); return false;"><%= t('page.show_all') %></a>)
<%- end -%>
<%- if params[:mode] == 'show_all_creators' -%>
<%= agents_list(manifestation.creates) %>
<%- if manifestation.creates.count > 5 -%>
(<a href="#" onclick="$.ajax({data:'authenticity_token=' + encodeURIComponent('<%= form_authenticity_token %>'), success:function(request){$('#creator_list_<%= manifestation.id %>').html(request);}, type:'get', url:'<%= manifestation_path(manifestation, index_num: manifestation.id, mode: 'show_creators') %>'}); return false;"><%= t('page.hide') %></a>)
<%- end -%>

<%= agents_list(manifestation.contributors.readable_by(current_user)) %>
<%= agents_list(manifestation.publishers.readable_by(current_user)) %>
<%- if manifestation.pub_date.present? -%>
(<%= manifestation.pub_date -%>)
<%- else -%>
<%= agents_list(manifestation.creates[0..2]) %>
<%- if manifestation.creates.count > 5 -%>
(<a href="#" onclick="$.ajax({data:'authenticity_token=' + encodeURIComponent('<%= form_authenticity_token %>'), success:function(request){$('#creator_list_<%= manifestation.id %>').html(request);}, type:'get', url:'<%= manifestation_path(manifestation, index_num: manifestation.id, mode: 'show_all_creators') %>'}); return false;"><%= t('page.show_all') %></a>)
<%- end -%>
<% if defined?(EnjuSubject) %>
<% manifestation.classifications.each_with_index do |classification| %>
<%= link_to "#{classification.classification_type.display_name.localize}: #{classification.category}", manifestations_path(query: "classification_sm:#{classification.classification_type.name}_#{classification.category}") %>
<% end %>
<% end %>
<%- end -%>

<%= agents_list(manifestation.realizes) %>
<%= agents_list(manifestation.produces) %>
<%- if manifestation.pub_date.present? -%>
(<%= manifestation.pub_date -%>)
<%- end -%>

<% manifestation.classifications.each_with_index do |classification| %>
<%= link_to "#{classification.classification_type.display_name.localize}: #{classification.category}", manifestations_path(query: "classification_sm:#{classification.classification_type.name}_#{classification.category}") %>
<% end %>
12 changes: 6 additions & 6 deletions app/views/manifestations/_title.html+phone.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
</h2>
<p>
<%= manifestation.statement_of_responsibility %><br />
<%- unless manifestation.creators.readable_by(current_user).empty? -%>
<%= t('agent.creator') -%>: <%= agents_list(manifestation.creators.readable_by(current_user), itemprop: 'author') -%>
<%- unless manifestation.creates.empty? -%>
<%= t('agent.creator') -%>: <%= agents_list(manifestation.creates, itemprop: 'author') -%>
<%- end -%>
<%- unless manifestation.contributors.readable_by(current_user).empty? -%>
<%= t('agent.contributor') -%>: <%= agents_list(manifestation.contributors.readable_by(current_user), itemprop: 'editor') -%>
<%- unless manifestation.realizes.empty? -%>
<%= t('agent.contributor') -%>: <%= agents_list(manifestation.realizes, itemprop: 'editor') -%>
<%- end -%>
<%- unless manifestation.publishers.readable_by(current_user).empty? -%>
<%= t('agent.publisher') -%>: <%= agents_list(manifestation.publishers.readable_by(current_user), itemprop: 'publisher') -%>
<%- unless manifestation.produces.empty? -%>
<%= t('agent.publisher') -%>: <%= agents_list(manifestation.produces, itemprop: 'publisher') -%>
<% end %>
<%- if manifestation.date_of_publication? -%>
<meta itemprop="publishDate" content="<%= manifestation.date_of_publication.iso8601 %>" />
Expand Down
12 changes: 6 additions & 6 deletions app/views/manifestations/_title.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
</h2>
<p>
<%= manifestation.statement_of_responsibility %><br />
<%- unless manifestation.creators.readable_by(current_user).empty? -%>
<%= t('agent.creator') -%>: <%= agents_list(manifestation.creators.readable_by(current_user), itemprop: 'author') -%>
<%- unless manifestation.creates.empty? -%>
<%= t('agent.creator') -%>: <%= agents_list(manifestation.creates, itemprop: 'author') -%>
<%- end -%>
<%- unless manifestation.contributors.readable_by(current_user).empty? -%>
<%= t('agent.contributor') -%>: <%= agents_list(manifestation.contributors.readable_by(current_user), itemprop: 'editor') -%>
<%- unless manifestation.realizes.empty? -%>
<%= t('agent.contributor') -%>: <%= agents_list(manifestation.realizes, itemprop: 'editor') -%>
<%- end -%>
<%- unless manifestation.publishers.readable_by(current_user).empty? -%>
<%= t('agent.publisher') -%>: <%= agents_list(manifestation.publishers.readable_by(current_user), itemprop: 'publisher') -%>
<%- unless manifestation.produces.empty? -%>
<%= t('agent.publisher') -%>: <%= agents_list(manifestation.produces, itemprop: 'publisher') -%>
<% end %>
<%- if manifestation.date_of_publication? -%>
<meta itemprop="publishDate" content="<%= manifestation.date_of_publication.iso8601 %>" />
Expand Down
4 changes: 2 additions & 2 deletions app/views/manifestations/index.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ atom_feed(url: manifestations_url(format: :atom)) do |feed|
entry.content(manifestation.tags.join(' '), type: 'html')
end

manifestation.creators.readable_by(current_user).each do |agent|
manifestation.creates.each do |create|
entry.author do |author|
author.name(agent.full_name)
author.name(create.name)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/manifestations/index.opds.builder
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ atom_feed(url: manifestations_url(format: :atom),
entry.content(manifestation.tags.join(' '), type: 'html')
end

manifestation.creators.readable_by(current_user).each do |agent|
manifestation.creates.each do |create|
entry.author do |author|
author.name(agent.full_name)
author.name(create.name)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/manifestations/index.rss.builder
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ xml.rss('version' => "2.0",
xml.title manifestation.original_title
#xml.description(manifestation.original_title)
# rfc822
manifestation.creators.readable_by(current_user).each do |creator|
xml.tag! "dc:creator", creator.full_name
manifestation.creates.each do |create|
xml.tag! "dc:creator", create.name
end
xml.pubDate manifestation.date_of_publication.try(:utc).try(:rfc822)
xml.link manifestation_url(manifestation)
Expand Down
4 changes: 2 additions & 2 deletions app/views/notifier/manifestation_info.en.text.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<%= @user.username -%> :

Title: <%= @manifestation.original_title %>
Creator(s): <%= @manifestation.creators.readable_by(@user).collect(&:full_name).join("/") %>
Contributor(s): <%= @manifestation.contributors.readable_by(@user).collect(&:full_name).join("/") %>
Creator(s): <%= @manifestation.creates.pluck(:name).join("/") %>
Contributor(s): <%= @manifestation.realizes.pluck(:name).join("/") %>
Publisher(s): <%= @manifestation.publishers.readable_by(@user).collect(&:full_name).join("/") %>
ISBN: <%= @manifestation.isbn_records.pluck(:body).join(" ") %>
URL: <%= @manifestation.access_address %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/notifier/manifestation_info.ja.text.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<%= @user.username -%> さん

資料名: <%= @manifestation.original_title %>
著者: <%= @manifestation.creators.readable_by(@user).collect(&:full_name).join("/") %>
編者: <%= @manifestation.contributors.readable_by(@user).collect(&:full_name).join("/") %>
著者: <%= @manifestation.creates.pluck(:name).join("/") %>
編者: <%= @manifestation.realizes.pluck(:name).join("/") %>
出版者: <%= @manifestation.publishers.readable_by(@user).collect(&:full_name).join("/") %>
ISBN: <%= @manifestation.isbn_records.pluck(:body).join(" ") %>
URL: <%= @manifestation.access_address %>
Expand Down
Loading
Loading