Skip to content
Permalink
Browse files

Merge branch 'development'

  • Loading branch information...
mjy committed Oct 5, 2019
2 parents 1803af8 + feda268 commit b284c4955e55efa17d1ca57f4e61d6f179171602
@@ -39,6 +39,7 @@ Object.assign(TW.view.sources, {
that.toggle_source_form_fields(this.value);
});
},

toggle_source_form_fields: function (type_label) {
var types = ['bibtex', 'verbatim', 'human'];
var to_show = type_label.split('::')[1].toLowerCase();
@@ -60,15 +61,17 @@ Object.assign(TW.view.sources, {
}
});

// TODO: revisit
// misc form cleanup (for ajax/selects)
if (to_show != 'bibtex') {
$('#source_bibtex_type').val("")
$('[name=source\\[serial_id\\]]').val("")
$('[name=source\\[language_id\\]]').val("")
}
$('[name=source\\[serial_id\\]]').val("")

}
});

document.addEventListener('turbolinks:load', (event) => {
TW.view.sources.init();

});
@@ -7,10 +7,11 @@ def serial_tag(serial)

def serial_autocomplete_tag(serial, term = '')
return nil if serial.nil?
show_this = serial.name.gsub(/#{Regexp.escape(term)}/, "<mark>#{term}</mark>") # weee bit simpler
# show_this += " (#{geographic_area.geographic_area_type.name})" unless geographic_area.geographic_area_type.nil?
# show_this += " [#{geographic_area.parent.name}]" unless geographic_area.parent.nil?
show_this.html_safe
[ serial.name.gsub(/#{Regexp.escape(term)}/, "<mark>#{term}</mark>"),
content_tag(:span, "Project uses: #{Serial.joins(sources: [:project_sources]).where('project_sources.project_id = ? and serials.id = ?', sessions_current_project_id, serial.id).count}", class: [:feedback, 'feedback-primary', 'feedback-thin']),
content_tag(:span, "All uses: #{serial.sources.count}", class: [:feedback, 'feedback-secondary', 'feedback-thin'])

].join('&nbsp;').html_safe
end

def serial_link(serial)
@@ -25,5 +26,4 @@ def serials_search_form
def serial_for_select(serial)
serial.name if serial
end

end
@@ -209,8 +209,6 @@ class Source < ApplicationRecord
# When true, cached values are not built
attr_accessor :no_year_suffix_validation



# Keep this order for citations/topics
has_many :citations, inverse_of: :source, dependent: :restrict_with_error
has_many :citation_topics, through: :citations, inverse_of: :source
@@ -122,8 +122,7 @@
# The sponsoring institution of a technical report
#
# @!attribute journal
# @return[String] the name of the journal (serial) associated with this source
# @return [nil] means the attribute is not stored in the database.
# @return[String, nil] the name of the journal (serial) associated with this source
# BibTeX standard field (required for types: )(optional for types:)
# A TW required attribute (TW requires a value in one of the required attributes.)
# A journal name. Many BibTeX processors have standardized abbreviations for many journals
@@ -433,7 +432,7 @@ def self.new_from_bibtex(bibtex_entry = nil)

# @return [Array] journal, nil or name
def journal
[read_attribute(:journal), (self.serial.blank? ? nil : self.serial.name)].compact.first
[read_attribute(:journal), (serial.blank? ? nil : serial.name)].compact.first
end

# @return [String]
@@ -1,6 +1,5 @@
<%= form_for(@source, as: :source, url: (@source.new_record? ? sources_path : source_path(@source)), method: (@source.new_record? ? :post : :patch)) do |f| %>


<%= render 'shared/errors', object: @source %>

<div class="actions">
@@ -65,16 +64,17 @@
</div>

<div class="field">
<%= f.label :serial %><br>
<%= f.label :serial_id %><br>
<%= render partial: 'workbench/elements/forms/ajax_select',
locals: {controller: 'serials',
object: 'source',
method: 'serial_id',
tag_id: 'serial_id_for_source',
size: '60',
display:@source.respond_to?(:serial) ? serial_for_select(@source.serial) : nil} %>
locals: {controller: 'serials',
object: 'source',
method: 'serial_id',
tag_id: 'serial_id_for_source',
size: '60',
display: @source.respond_to?(:serial) ? serial_for_select(@source.serial) : nil} %>
</div>


<div class="side_by_side_fields">
<div class="field">
<%= f.label :volume %><br>
@@ -93,13 +93,13 @@

<div class="field">
<%= f.label :language_id %><br>
<%= render :partial => 'workbench/elements/forms/ajax_select',
locals: {controller: 'languages',
<%= render partial: 'workbench/elements/forms/ajax_select',
locals: {controller: 'languages',
object: 'source',
method: 'language_id',
tag_id: 'language_id_for_source',
size: '60',
display:@source.respond_to?(:source_language) ? language_tag(@source.source_language) : nil} %>
display: @source.respond_to?(:source_language) ? language_tag(@source.source_language) : nil} %>
</div>
</div>

@@ -7,6 +7,6 @@ json.array! @taxon_names do |t|
if params[:method]
json.set! params[:method], t.id
end
end
end
end

@@ -30,5 +30,5 @@
<% if fields_for_object -%>
<%= fields_for_object.hidden_field(method, id: "#{tag_id}_hidden_value" ) -%>
<% else %>
<%= hidden_field(object, method, id: "#{tag_id}_hidden_value") -%>
<%= hidden_field(object, method, id: "#{tag_id}_hidden_value") -%>
<% end %>

0 comments on commit b284c49

Please sign in to comment.
You can’t perform that action at this time.