Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
mjy committed Sep 24, 2018
2 parents fb088f8 + a835d54 commit 71d5c9c
Show file tree
Hide file tree
Showing 203 changed files with 1,584 additions and 3,712 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function displayMessage(event) {
message = undefined;

if (event.origin !== "http://www.museum.tulane.edu") {
if (event.origin !== "http://www.geo-locate.org") {
message = "iframe url does not have permision to interact with me";
}
else {
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/alternate_values_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def index
render '/shared/data/all/index'
}
format.json {
@alternate_values = Queries::AlternateValue::Filter.new(params).all.limit(500)
.where(project_id: sessions_current_project_id).order(:id)
@alternate_values = Queries::AlternateValue::Filter.new(params).all
.where(project_id: sessions_current_project_id).page(param[:page]).per(500)
}
end
end
Expand Down
39 changes: 22 additions & 17 deletions app/controllers/citations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def create
@citation = Citation.new(citation_params)
respond_to do |format|
if @citation.save
format.html { redirect_to url_for(@citation.citation_object.metamorphosize), notice: 'Citation was successfully created.' }
format.json { render :show, status: :created, location: @citation }
format.html {redirect_to url_for(@citation.citation_object.metamorphosize), notice: 'Citation was successfully created.'}
format.json {render :show, status: :created, location: @citation}
else
format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Citation was NOT successfully created.')}
format.json { render json: @citation.errors, status: :unprocessable_entity }
format.json {render json: @citation.errors, status: :unprocessable_entity}
end
end
end
Expand All @@ -56,11 +56,11 @@ def create
def update
respond_to do |format|
if @citation.update(citation_params)
format.html { redirect_to url_for(@citation.citation_object.metamorphosize), notice: 'Citation was successfully updated.' }
format.json { render :show, location: @citation }
format.html {redirect_to url_for(@citation.citation_object.metamorphosize), notice: 'Citation was successfully updated.'}
format.json {render :show, location: @citation}
else
format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Citation was NOT successfully updated.')}
format.json { render json: @citation.errors, status: :unprocessable_entity }
format.json {render json: @citation.errors, status: :unprocessable_entity}
end
end
end
Expand All @@ -70,8 +70,13 @@ def update
def destroy
@citation.destroy
respond_to do |format|
format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Citation was successfully destroyed.')}
format.json { head :no_content }
if @citation.destroyed?
format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Citation was successfully destroyed.')}
format.json {head :no_content}
else
format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Citation was not destroyed, ' + errors.messages)}
format.json {render json: @citation.errors, status: :unprocessable_entity}
end
end
end

Expand Down Expand Up @@ -112,8 +117,8 @@ def download

def filter_params
params.permit(
:citation_object_type, :citation_object_id, :source_id,
Citation.related_foreign_keys.map(&:to_sym)
:citation_object_type, :citation_object_id, :source_id,
Citation.related_foreign_keys.map(&:to_sym)
).merge(project_id: sessions_current_project_id)
end

Expand All @@ -123,13 +128,13 @@ def set_citation

def citation_params
params.require(:citation).permit(
:citation_object_type, :citation_object_id, :source_id, :pages, :is_original,
:annotated_global_entity,
citation_topics_attributes: [
:id, :_destroy, :pages, :topic_id,
topic_attributes: [:id, :_destroy, :name, :definition]
],
topics_attributes: [:name, :definition]
:citation_object_type, :citation_object_id, :source_id, :pages, :is_original,
:annotated_global_entity,
citation_topics_attributes: [
:id, :_destroy, :pages, :topic_id,
topic_attributes: [:id, :_destroy, :name, :definition]
],
topics_attributes: [:name, :definition]
)
end
end
12 changes: 10 additions & 2 deletions app/controllers/confidences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ def index
render '/shared/data/all/index'
}
format.json {
@confidences = Queries::Confidence::Filter.new(params).all.limit(500)
.where(project_id: sessions_current_project_id)
@confidences = Queries::Confidence::Filter.new(filter_params).all
.where(project_id: sessions_current_project_id).page(params[:page]).per(500)
}
end
end


# GET /confidences/new
def new
@confidence_object = confidence_object
Expand Down Expand Up @@ -102,6 +103,13 @@ def set_confidence
@confidence = Confidence.find(params[:id])
end

def filter_params
params.permit(
:confidence_level_id, :object_global_id, :confidence_object_type,
Confidence.related_foreign_keys.map(&:to_sym)
)
end

def confidence_params
params.require(:confidence).permit(
:annotated_global_entity,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/data_attributes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def index
}
format.json {
@data_attributes = Queries::DataAttribute::Filter.new(params).all
.where(project_id: sessions_current_project_id).page(params[:page]).per(500)
.where(project_id: sessions_current_project_id).page(params[:page] || 1).per(500)
}
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def index
render '/shared/data/all/index'
}
format.json {
@notes = Queries::Note::Filter.new(params).all.limit(500)
.where(project_id: sessions_current_project_id)
@notes = Queries::Note::Filter.new(params).all
.where(project_id: sessions_current_project_id).page(param[:page]).per(500)
}
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/otus_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ def filter_params
params.permit(
:taxon_name_id, :otu_id,
biological_association_ids: [], taxon_name_ids: [], otu_ids: [],
taxon_name_classification_ids: [], taxon_name_relationship_ids: [], asserted_distribution_ids: []
taxon_name_relationship_ids: [],taxon_name_classification_ids: [],
asserted_distribution_ids: []
)
end

Expand Down
20 changes: 10 additions & 10 deletions app/controllers/sources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,16 @@ def source_params
:abstract, :copyright, :language, :stated_year, :verbatim,
:bibtex_type, :day, :year, :isbn, :issn, :verbatim_contents,
:verbatim_keywords, :language_id, :translator, :year_suffix, :url, :type,
roles_attributes: [
:id,
:_destroy,
:type,
:person_id,
:position,
person_attributes: [
:last_name, :first_name, :suffix, :prefix
]
],
roles_attributes: [
:id,
:_destroy,
:type,
:person_id,
:position,
person_attributes: [
:last_name, :first_name, :suffix, :prefix
]
],
project_sources_attributes: [:project_id]
)
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def index
render '/shared/data/all/index'
}
format.json {
@tags = Queries::Tag::Filter.new(params).all.limit(500)
.where(project_id: sessions_current_project_id)
@tags = Queries::Tag::Filter.new(params).all.where(project_id: sessions_current_project_id).
page(param[:page]).per(500)
}
end
end
Expand Down
10 changes: 2 additions & 8 deletions app/controllers/tasks/nomenclature/by_source_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ class Tasks::Nomenclature::BySourceController < ApplicationController
include TaskControllerConfiguration

def index

if !ProjectSource.where(project_id: sessions_current_project_id).any?
flash[:notice] = 'Create or add a source to your project first.'
redirect_to sources_path and return
end

@source = Source.find(params[:id]) if !params[:id].blank?
@source ||= Project.find(sessions_current_project_id).project_sources.first.source
# @source = Source.find(params[:id]) unless params[:id].blank?
# @source ||= Project.find(sessions_current_project_id).project_sources.first.source
end
end
33 changes: 22 additions & 11 deletions app/helpers/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@



Helper Descriptions
===================

Expand All @@ -9,6 +8,8 @@ See individual headers at https://github.com/SpeciesFileGroup/taxonworks/tree/ma
Code Organization
=================

TODO: Go over patterns, clean up where no longer pertinent.

```Ruby
class <Model>Helper

Expand All @@ -29,30 +30,40 @@ class <Model>Helper
# Exemplar data model helper methods
#

# Return a single line, ideally wrapped in a content_tag(:span, ... ) naming the instance.
def <model_name>_tag(model)
return nil if model.nil
# return some model.attribute of interpolated string of model attributes
# Return a single line, ideally wrapped in a content_tag(:span, ... ) naming the instance.
# Often contains html.
def <model_name>_tag(object)
return nil if object.nil
# return some object.attribute of interpolated string of object attributes
end

# Return a single line, ideally wrapped in a content_tag(:span, ... ) briefly naming the instance.
def <model_name>_short_tag(model)
# May contain html.
def <model_name>_short_tag(object)
end

# Return one or more line, ideally wrapped in a content_tag(:div, ... ) detailing the instance.
def <model_name>_detailed_tag(model)
# Rarely used at present. Often contains html.
def <model_name>_detailed_tag(object)
end

# Return a link_to(model_path) using model_tag
def <model_name>_link(model)
def <model_name>_link(object)
end

# Return a link_to(model_path) using model_short_tag
def model_short_link(model)
def model_short_link(mobject)
end

# Return a content_tag(:li, <model>_tag(object))
def model_select_item(mobject)
end

# Return a content_tag(:li, model_tag(model))
def model_select_item(model)
# Return a String
# An equivalent to object_tag, but never with HTML!
# Same as
# label_for(object)
def label_for_<model>(object)
end

end
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/annotations_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def annotations_summary_tag(object)
data_attribute_list_tag(object),
note_list_tag(object),
tag_list_tag(object),
alternate_values_list_tag(object)
alternate_values_list_tag(object),
confidence_list_tag(object)
].compact.join.html_safe, class: :annotations_summary_list, 'data-annotator-list-object-id' => object.id)

end
Expand Down
17 changes: 16 additions & 1 deletion app/helpers/confidences_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,22 @@ def confidence_tag(confidence)

def confidence_link(confidence)
return nil if confidence.nil?
link_to(confidence_tag(confidence), confidence)
link_to(confidence_tag(confidence), confidence.confidence_object.metamorphosize)
end

# @return [String (html), nil]
# a ul/li of tags for the object
def confidence_list_tag(object)
return nil unless object.has_confidences? && object.confidences.any?
content_tag(:h3, 'Confidences') +
content_tag(:ul, class: 'annotations__confidences_list') do
object.confidences.collect { |a| content_tag(:li, confidence_tag(a)) }.join.html_safe
end
end

def confidence_annotation_confidence(confidence)
return nil if confidence.nil?
content_tag(:span, controlled_vocabulary_term_tag(confidence.confidence_level), class: [:annotation__confidence])
end

def confidences_search_form
Expand Down
7 changes: 7 additions & 0 deletions app/helpers/otus_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ def otu_link(otu)
link_to(otu_tag(otu).html_safe, otu)
end

def label_for_otu(otu)
return nil if otu.nil?
[otu.name,
label_for_taxon_name(otu.taxon_name)
].compact.join(': ')
end

def otus_search_form
render('/otus/quick_search_form')
end
Expand Down
5 changes: 5 additions & 0 deletions app/helpers/taxon_names_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ def taxon_name_tag(taxon_name)
taxon_name.cached_html.try(:html_safe) || taxon_name.name
end

def label_for_taxon_name(taxon_name)
return nil if taxon_name.nil?
[taxon_name.cached, taxon_name.cached_author_year].compact.join(' ')
end

def taxon_name_autocomplete_tag(taxon_name, term)
return nil if taxon_name.nil?
klass = taxon_name.rank_class ? taxon_name.rank_class.nomenclatural_code : nil
Expand Down
32 changes: 32 additions & 0 deletions app/helpers/workbench/display_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Generic wrappers around AR instances, these should not include link generation, but may call out to other helpers that do generate links.
# See /app/helpers/README.md for more.
#
module Workbench::DisplayHelper



# General wrapper around individual <model_name>_tag methods
# object_tag(@otu)
def object_tag(object)
Expand Down Expand Up @@ -31,6 +35,34 @@ def object_tag_method(object)
end
end

# General wrapper around individual <model_name>_tag methods
# label_for(@otu)
def label_for(object)
return nil if object.nil?
method = label_for_method(object)

if self.respond_to?(method)
string = send(method, object)
return string if string
else
nil
end
end

def label_for_method(object)
return nil if object.nil?
klass_name = object.class.name
method = "label_for_#{klass_name.underscore.gsub('/', '_')}"
if ApplicationController.helpers.respond_to?(method)
method
else
klass_name = metamorphosize_if(object).class.name
"label_for_#{klass_name.underscore}"
end
end



def model_name_title
controller_name.humanize
end
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ require('../vue/browse_annotations/main.js')
require('../vue/tasks/descriptor/main.js')
require('../vue/tasks/new_matrix/main.js')
require('../vue/tasks/clipboard/main.js')
require('../vue/tasks/digitize/main.js')
require('../vue/tasks/uniquify/people/main.js')
require('../vue/tasks/uniquify/sources/main.js')
require('../vue/tasks/single_bibtex_source/main.js')
require('../vue/tasks/nomenclature/by_source/main.js')

// Styles
require('../style/application.scss')
Loading

0 comments on commit 71d5c9c

Please sign in to comment.