Skip to content

Commit

Permalink
Merge staging for release
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorf committed Oct 13, 2020
2 parents 9f90233 + 03f98c4 commit f50cc27
Show file tree
Hide file tree
Showing 18 changed files with 2,791 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ gem 'rack-mini-profiler'
gem 'rails_autolink'
gem 'rdoc'
gem 'recaptcha', '~> 5.2'
gem 'rest-client', '~> 1.8.0'
gem 'rest-client'
gem 'stackprof', require: false
gem 'thin'
gem 'will_paginate', '~> 3.0'
Expand Down
50 changes: 27 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ GEM
sshkit (>= 1.6.1, != 1.7.0)
arel (9.0.0)
ast (2.4.1)
autoprefixer-rails (9.8.6.3)
autoprefixer-rails (10.0.1.0)
execjs
bootstrap (4.1.3)
autoprefixer-rails (>= 6.0.3)
popper_js (>= 1.12.9, < 2)
sass (>= 3.5.2)
brakeman (4.9.0)
brakeman (4.10.0)
builder (3.2.4)
capistrano (3.14.1)
airbrussh (>= 1.0.0)
Expand Down Expand Up @@ -101,7 +101,7 @@ GEM
crass (1.0.6)
cube-ruby (0.0.3)
daemons (1.3.1)
dalli (2.7.10)
dalli (2.7.11)
diff-lcs (1.4.4)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
Expand All @@ -116,14 +116,15 @@ GEM
flamegraph (0.9.5)
globalid (0.4.2)
activesupport (>= 4.2.0)
haml (5.1.2)
haml (5.2.0)
temple (>= 0.8.0)
tilt
html2haml (2.2.0)
erubis (~> 2.7.0)
haml (>= 4.0, < 6)
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
http-accept (1.7.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.8.5)
Expand All @@ -148,7 +149,9 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (1.0.0)
mime-types (2.99.3)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0512)
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
Expand All @@ -160,22 +163,22 @@ GEM
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (6.1.0)
netrc (0.11.0)
newrelic_rpm (6.12.0.367)
nio4r (2.5.2)
newrelic_rpm (6.13.1)
nio4r (2.5.4)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
oj (3.10.13)
oj (3.10.14)
open_uri_redirections (0.2.1)
parallel (1.19.2)
parser (2.7.1.4)
parser (2.7.2.0)
ast (~> 2.4.1)
popper_js (1.16.0)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.6)
rack (2.2.3)
rack-mini-profiler (2.0.4)
rack-mini-profiler (2.1.0)
rack (>= 1.2.0)
rack-test (1.1.0)
rack (>= 1.0, < 3)
Expand Down Expand Up @@ -213,13 +216,14 @@ GEM
rdoc (6.2.1)
recaptcha (5.5.0)
json
regexp_parser (1.7.1)
rest-client (1.8.0)
regexp_parser (1.8.2)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.4)
rspec-core (3.9.2)
rspec-core (3.9.3)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
Expand All @@ -236,17 +240,17 @@ GEM
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.3)
rubocop (0.90.0)
rubocop (0.93.1)
parallel (~> 1.10)
parser (>= 2.7.1.1)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
regexp_parser (>= 1.8)
rexml
rubocop-ast (>= 0.3.0, < 1.0)
rubocop-ast (>= 0.6.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.3.0)
parser (>= 2.7.1.4)
rubocop-ast (0.8.0)
parser (>= 2.7.1.5)
ruby-progressbar (1.10.1)
ruby_parser (3.15.0)
sexp_processor (~> 4.9)
Expand All @@ -267,7 +271,7 @@ GEM
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
Expand Down Expand Up @@ -335,7 +339,7 @@ DEPENDENCIES
rails_autolink
rdoc
recaptcha (~> 5.2)
rest-client (~> 1.8.0)
rest-client
rspec-rails
rubocop
sass-rails (~> 5.0)
Expand Down
120 changes: 112 additions & 8 deletions app/assets/javascripts/bp_ontolobridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,109 @@ function bindCancelRequestTermClick() {
});
}

function bindNewTermInstructionsClick() {
jQuery("#new_term_instructions").live("click", function() {
jQuery(this).trumbowyg({
btns: [
['viewHTML'],
['undo', 'redo'], // Only supported in Blink browsers
['formatting'],
['strong', 'em', 'del'],
['superscript', 'subscript'],
['link'],
['insertImage'],
['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
['unorderedList', 'orderedList'],
['horizontalRule'],
['removeformat'],
['fullscreen']
]
});
jQuery("#new_term_instructions_submit").show();
jQuery("#new_term_instructions_cancel").show();
});
}

function bindNewTermInstructionsSubmit() {
jQuery("#new_term_instructions_submit").live("click", function() {
saveNewTermInstructions();
});
}

function bindNewTermInstructionsCancel() {
jQuery("#new_term_instructions_cancel").live("click", function() {
var oldVal = jQuery("#new_term_instructions_old").val().trim();
var curVal = jQuery('#new_term_instructions').html().trim();

if (oldVal != curVal) {
if (confirm('Are you sure you want to discard your changes?')) {
jQuery('#new_term_instructions').trumbowyg('destroy');
jQuery('#new_term_instructions').html(oldVal);
hideButtons();
}
} else {
jQuery('#new_term_instructions').trumbowyg('destroy');
hideButtons();
}
});
}

function preventNewTermInstructionsFormSubmit() {
jQuery("#new_term_instructions_form").submit(function(e) {
e.preventDefault(e);
});
}

function clearProgressMessage() {
jQuery("#progress_message").hide();
jQuery("#progress_message").html("");
};

function showProgressMessage() {
clearProgressMessage();
var msg = "Saving...";
jQuery("#progress_message").text(msg).html();
jQuery("#progress_message").show();
}

function saveNewTermInstructions() {
var params = jQuery('#new_term_instructions_form').serialize();
var newInstructions = jQuery('#new_term_instructions').html().trim();
params += '&new_term_instructions=' + newInstructions;
showProgressMessage();

jQuery.ajax({
type: "POST",
url: "/ontolobridge/save_new_term_instructions",
dataType: "json",
data: params,
success: function(data) {
var status = data[1];

if (status && status >= 400 || data[0]['error'].length) {
showStatusMessages('', data[0]['error']);
} else {
jQuery('#new_term_instructions').trumbowyg('destroy');
jQuery("#new_term_instructions_old").val(newInstructions);
showStatusMessages(data[0]["success"], '');
setTimeout(function() { clearStatusMessages(); }, 5000);
}
},
error: function(request, textStatus, errorThrown) {
showStatusMessages('', errorThrown);
},
complete: function(request, textStatus) {
clearProgressMessage();
hideButtons();
}
});
}

function hideButtons() {
jQuery("#new_term_instructions_submit").hide();
jQuery("#new_term_instructions_cancel").hide();
}

function bindRequestTermSaveClick() {
var success = "";
var error = "";
Expand All @@ -33,7 +136,7 @@ function bindRequestTermSaveClick() {
var status = data[1];

if (status && status >= 400) {
showStatusMessages(null, data[0]["error"]);
showStatusMessages('', data[0]["error"]);
} else {
var msg = "<strong>A new term request has been submitted successfully:</strong><br/><br/>";
var button = jQuery(".request_term_form_div .save");
Expand All @@ -42,7 +145,6 @@ function bindRequestTermSaveClick() {
for (var i in data[0]) {
msg += i + ": " + data[0][i] + "<br/>";
}

showStatusMessages(msg, error);
}
},
Expand All @@ -59,7 +161,6 @@ function removeRequestTermBox(button) {

function addRequestTermBox(id, type, button) {
clearStatusMessages();

var formContainer = jQuery(button).parents(".notes_list_container").children(".request_term_form_div");
requestTermFields(id, formContainer);
formContainer.show();
Expand All @@ -86,17 +187,17 @@ function showStatusMessages(success, error) {

function requestTermButtons() {
var button_submit = jQuery("<button>")
.attr("class", "btn")
.attr("type", "submit")
.attr("onclick", "")
.addClass("save")
.css("margin-right", "20px")
.css("padding", "2px 8px")
.css("margin-right", "5px")
.html("Submit");
var button_cancel = jQuery("<button>")
.attr("class", "btn")
.attr("type", "button")
.attr("onclick", "")
.addClass("cancel")
.css("padding", "2px 8px")
.html("Cancel");
return button_submit.add(button_cancel);
}
Expand Down Expand Up @@ -128,7 +229,6 @@ function appendTextArea(id, placeholder, div, isRequired, invalidMessage) {
txtArea.prop('required', true);
txtArea.attr("class", "req");
}

div.append(txtArea);
div.append("<br/>");
}
Expand Down Expand Up @@ -159,7 +259,6 @@ function appendField(id, text, div, isRequired, invalidMessage) {
ipt.prop('required', true);
ipt.attr("class", "req");
}

div.append(ipt);
div.append("<br/>");
}
Expand Down Expand Up @@ -195,4 +294,9 @@ jQuery(document).ready(function() {
clearStatusMessages();
bindAddRequestTermClick();
bindCancelRequestTermClick();

preventNewTermInstructionsFormSubmit();
bindNewTermInstructionsSubmit();
bindNewTermInstructionsCancel();
bindNewTermInstructionsClick();
});
1 change: 1 addition & 0 deletions app/assets/javascripts/vendor.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@
//= require Chart.min
//= require select2
//= require jquery.readyselector
//= require trumbowyg

1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*= require jquery.tooltip
*= require thickbox
*= require select2
*= require trumbowyg
*
*/

Expand Down
6 changes: 6 additions & 0 deletions app/assets/stylesheets/ontolobridge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ input.req,
textarea.req {
border-color: darksalmon !important;
}

blockquote {
padding: 0 1em;
color: #6a737d;
border-left: .25em solid #dfe2e5;
}
2 changes: 2 additions & 0 deletions app/controllers/concepts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def show

# Note that find_by_acronym includes views by default
@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology]).first
@ob_instructions = helpers.ontolobridge_instructions_template(@ontology)

if request.xhr?
display = params[:callback].eql?('load') ? {full: true} : {display: "prefLabel"}
@concept = @ontology.explore.single_class(display, params[:id])
Expand Down
19 changes: 19 additions & 0 deletions app/controllers/ontolobridge_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,23 @@ def request_term
render json: [response, code], status: code
end

def save_new_term_instructions
code = 200
response = {error: '', success: ''}
response[:success] = "New term request instructions for #{params['acronym']} saved"
ont_data = Ontology.find_by(acronym: params['acronym'])
ont_data ||= Ontology.new
ont_data.acronym = params['acronym']
ont_data.new_term_instructions = params['new_term_instructions']

begin
ont_data.save
rescue Exception => e
code = 500
response[:error] = "Unable to save new term instructions for #{params['acronym']} due to a server error"
end
sleep(1)
render json: [response, code], status: code
end

end
2 changes: 2 additions & 0 deletions app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ def show
end
end

@ob_instructions = helpers.ontolobridge_instructions_template(@ontology)

# Retrieve submissions in descending submissionId order (should be reverse chronological order)
@submissions = @ontology.explore.submissions.sort {|a,b| b.submissionId.to_i <=> a.submissionId.to_i } || []
LOG.add :error, "No submissions for ontology: #{@ontology.id}" if @submissions.empty?
Expand Down
Loading

0 comments on commit f50cc27

Please sign in to comment.