Skip to content

Commit 7a4b07e

Browse files
committed
Merge branch 'master' into rails51-with-asset-pipeline-and-jquery-in-gems
2 parents 871ad4c + c7f98a8 commit 7a4b07e

39 files changed

+2601
-251
lines changed

Diff for: .yardopts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
--markup 'markdown'
2+
13
--private
24
--protected
35

@@ -9,7 +11,7 @@
911
--tag postconditions:"Postconditions"
1012
--type-name-tag constant:"Constants this method uses"
1113
--type-name-tag used_instance_variable:"Instance variables this method uses before setting"
12-
--type-name-tag changed_instance_variable:"Instance variables set by this method"
14+
--type-name-tag changed_instance_variable:"Instance variables set (or altered) by this method"
1315
--tag calls:"Calls"
1416
--tag callers:"Called by"
1517
--tag side_effect:"Side effects"

Diff for: .zenodo.json

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"metadata": {
3+
"access_right": "open",
4+
"creators": [{
5+
"affiliation": "University of Illinois",
6+
"name": "Scott Rohde"
7+
},
8+
{
9+
"name": "Carl Crott"
10+
},
11+
{
12+
"affiliation": "University of Illinois",
13+
"name": "David LeBauer"
14+
},
15+
{
16+
"name": "Patrick Mulrooney"
17+
},
18+
{
19+
"affiliation": "National Center for Supercomputing Applications",
20+
"name": "Rob Kooper"
21+
},
22+
{
23+
"name": "Jeremy Kemball"
24+
},
25+
{
26+
"name": "Jimmy Chen"
27+
},
28+
{
29+
"name": "Andrew Shirk"
30+
},
31+
{
32+
"name": "Zhengqi Yang"
33+
},
34+
{
35+
"affiliation": "National Center for Supercomputing Applications",
36+
"name": "Max Burnette"
37+
},
38+
{
39+
"name": "Haotian Jiang"
40+
},
41+
{
42+
"name": "Yilin Dong"
43+
},
44+
{
45+
"name": "Uday Saraf"
46+
},
47+
{
48+
"affiliation": "Boston University",
49+
"name": "Michael Dietze"
50+
},
51+
{
52+
"name": "Chris Black"
53+
}
54+
],
55+
"language": "eng",
56+
"license": {
57+
"id": "NCSA"
58+
},
59+
"references": [
60+
"LeBauer, D., Kooper, R., Mulrooney, P., Rohde, S., Wang, D., Long, S. P., & Dietze, M. C. (2018). BETYdb: a yield, trait, and ecosystem service database applied to second\u2010generation bioenergy feedstock production. GCB Bioenergy, 10(1), 61-71",
61+
"LeBauer, David, Michael Dietze, Rob Kooper, Steven Long, Patrick Mulrooney, Gareth Scott Rohde, Dan Wang (2010). Biofuel Ecophysiological Traits and Yields Database (BETYdb), Energy Biosciences Institute, University of Illinois at Urbana-Champaign. doi:10.13012/J8H41PB9"
62+
],
63+
"notes": "Development of BETYdb is supported by the National Science Foundation (ABI #1062547, ABI #1458021), the Department of Energy (ARPA-E awards #DE-AR0000594 and DE-AR0000598), and the Energy Biosciences Institute.",
64+
"resource_type": {
65+
"title": "Software",
66+
"type": "software"
67+
}
68+
}
69+
}

Diff for: Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ gem "json"
1111
gem "rgeo", "~> 0.5.0"
1212
gem "multi_json"
1313
gem "railroad", "0.5.0"
14-
gem "recaptcha", "0.3.4", :require => "recaptcha/rails"
14+
gem "recaptcha", "4.8.0", :require => "recaptcha/rails"
1515
gem "ruby-graphviz", "1.0.8"
1616
gem "safe_attributes"
1717
gem "seer", "0.10.0"

Diff for: Gemfile.lock

+4-3
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ GEM
170170
rb-fsevent (0.10.3)
171171
rb-inotify (0.9.10)
172172
ffi (>= 0.5.0, < 2)
173-
recaptcha (0.3.4)
174-
rgeo (0.5.0)
173+
recaptcha (4.8.0)
174+
json
175+
rgeo (0.5.3)
175176
rgeo-activerecord (5.1.1)
176177
activerecord (~> 5.0)
177178
rgeo (~> 0.3)
@@ -280,7 +281,7 @@ DEPENDENCIES
280281
rails (= 5.1.5)
281282
rails-controller-testing
282283
rails3-restful-authentication (~> 3.0.1)
283-
recaptcha (= 0.3.4)
284+
recaptcha (= 4.8.0)
284285
rgeo (~> 0.5.0)
285286
rspec-rails (~> 3.0)
286287
rspec_api_documentation

Diff for: README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
[![DOI](https://zenodo.org/badge/4469/PecanProject/bety.svg)](https://zenodo.org/badge/latestdoi/4469/PecanProject/bety)
44

5-
[![Build Status](https://travis-ci.org/PecanProject/bety.svg?branch=master)](https://travis-ci.org/PecanProject/bety)[![Join the chat at https://gitter.im/PecanProject/bety](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/PecanProject/bety?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5+
[![Build Status](https://travis-ci.org/PecanProject/bety.svg?branch=master)](https://travis-ci.org/PecanProject/bety)
6+
7+
[![Slack](https://img.shields.io/badge/slack-login-brightgreen.svg)](https://pecanproject.slack.com/)
8+
[![Slack](https://img.shields.io/badge/slack-join_chat-brightgreen.svg)](https://publicslack.com/slacks/pecanproject/invites/new)
69

710
This is the source code for the [Biofuel Ecophysiological Traits and Yields database (BETYdb)](http://www.betydb.org)
811

Diff for: app/assets/javascripts/lazy/bulk_upload.js

+81
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,85 @@ jQuery(function() {
5656
jQuery('#global_values_citation_id').val(ui.item.value);
5757
});
5858

59+
jQuery("form").submit(function(event, ui) {
60+
var allowSubmission = true;
61+
62+
for (autocompletion_widget_id in bu_completion_fields) {
63+
allowSubmission = allowSubmission && bu_completion_fields[autocompletion_widget_id]["valid"];
64+
}
65+
66+
return allowSubmission;
67+
});
68+
69+
for (autocompletion_widget_id in bu_completion_fields) {
70+
jQuery('#' + autocompletion_widget_id).autocomplete({
71+
minLength: 0,
72+
source: ROOT_URL + "/methods/bu_autocomplete.json",
73+
select: create_select_function(autocompletion_widget_id),
74+
focus: function(event, ui) {
75+
// Prevent the value (the id number) of an item selected from
76+
// displaying when using the arrow keys:
77+
event.preventDefault();
78+
},
79+
change: create_change_function(autocompletion_widget_id)
80+
});
81+
jQuery('#' + autocompletion_widget_id).click(create_click_function(autocompletion_widget_id));
82+
83+
}
84+
5985
});
86+
87+
function create_select_function(autocompletion_widget_id) {
88+
return function(event, ui) {
89+
// Prevent the value (the id number) of the item selected from
90+
// displaying after a selection has been made ...
91+
event.preventDefault();
92+
93+
// ... and display the *label* of the item selected instead ...
94+
var display = ui.item.label;
95+
// ... unless it's "[no value]"; then just display the placeholder.
96+
if (ui.item.label == "[no value]") {
97+
display = "";
98+
}
99+
jQuery(this).val(display);
100+
101+
// Clear the error message if present:
102+
jQuery('label[for = "' + autocompletion_widget_id + '"] span.error').hide();
103+
104+
// Save the selected values in the session, both for making
105+
// values "sticky" and for use by subsequent pages of the
106+
// wizard:
107+
jQuery.post(ROOT_URL + "/bulk_upload/store_trait_method_mapping_in_session",
108+
{
109+
"trait_name": event.target.id,
110+
"method_info": {
111+
"label": display,
112+
"value": ui.item.value
113+
}
114+
});
115+
116+
}
117+
}
118+
119+
function create_change_function(autocompletion_widget_id) {
120+
return function(event, ui) {
121+
var validValue = (ui.item != null && ui.item.label != null);
122+
123+
if (validValue) {
124+
jQuery('label[for = "' + autocompletion_widget_id + '"] span.error').hide();
125+
}
126+
else {
127+
jQuery('label[for = "' + autocompletion_widget_id + '"] span.error').show();
128+
129+
jQuery(this).select();
130+
}
131+
bu_completion_fields[autocompletion_widget_id]["valid"] = validValue;
132+
}
133+
}
134+
135+
function create_click_function(autocompletion_widget_id) {
136+
return function(event, ui) {
137+
jQuery('#' + autocompletion_widget_id).select();
138+
jQuery('#' + autocompletion_widget_id).autocomplete("search");
139+
}
140+
}

Diff for: app/controllers/application_controller.rb

+17-7
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,23 @@ def handle_constraint_violations(e)
172172
redirect_back(fallback_location: root_path)
173173
end
174174

175-
# Given a model class, a list of columns (attributes) of the model, and a
176-
# search term, search the database table corresponding to the model and return
177-
# objects for all rows that contain the text of the search term in any of the
178-
# text of any of the given columns.
175+
# Given a model class, a list of columns (attributes) of the model,
176+
# and a search term, search the database table corresponding to the
177+
# model and return objects for all rows that contain the text of the
178+
# search term in the text of at least one of the given columns. If
179+
# the search string has fewer than two characters and no matches are
180+
# found, or if +column_list+ is empty, return objects for _all_
181+
# rows.
182+
#
183+
# @param model_class [#where, #scoped] Typically this will be either a
184+
# subclass of {ActiveRecord::Base} (e.g. {Citation}) or and instance of
185+
# {ActiveRecord::Relation} (e.g. {Citation.order('author')}).
186+
# @param column_list [Array<String>] An array of names of columns in the table
187+
# corresponding to `model_class`.
188+
# @param search_term [String]
189+
#
190+
# @return [ActiveRecord::Relation] This acts like an Array whose members are
191+
# instances of the model associated with `model_class`.
179192
def search_model(model_class, column_list, search_term)
180193
clauses = column_list.collect {|column_name| "LOWER(#{column_name}) LIKE LOWER(:match_string)"}
181194
where_clause = clauses.join(" OR ")
@@ -187,9 +200,6 @@ def search_model(model_class, column_list, search_term)
187200
# If the user has only typed one letter, just return everything so the
188201
# user can at least see some possible options.
189202
result_set = model_class.scoped
190-
else
191-
# Otherwise, let the user know there were no matches.
192-
result_set = [ { label: "No matches", value: "" }]
193203
end
194204
end
195205
return result_set

0 commit comments

Comments
 (0)