Skip to content

Commit

Permalink
Merge branch 'dev' into fix/favicon
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	lib/generators/orchid_setup_generator.rb
#	lib/generators/setup_generator.rb
  • Loading branch information
jduss4 committed Feb 11, 2021
2 parents e51fd3b + 86ab376 commit b7713ba
Show file tree
Hide file tree
Showing 19 changed files with 151 additions and 67 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,23 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/CDRH/orchid/compare/v3.1.1...dev) - unreleased

### Fixed
- displays flash message if API is down, instead of pages throwing errors

### Added
- keyboard navigation for collapsible filter panels

### Changed
- updates jquery 1.x to 3.x
- rails g setup is now rails g orchid_setup
- check_response method added to items_controller

### Migration
- modify existing app's `application.js`
- change `//= require jquery` to `//= require jquery3`
- apps will continue to function with older jquery if not modified
- add `errors.api` and `search.results.error` to locale files
- check items_overrides and views/items for changes related to display items when API is unavailable

## [v3.1.1](https://github.com/CDRH/orchid/compare/v3.1.0...v3.1.1) - splitting templates, fixing languages

Expand Down
86 changes: 43 additions & 43 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,57 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.4.3)
actionpack (= 5.2.4.3)
actioncable (5.2.4.4)
actionpack (= 5.2.4.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.4.3)
actionpack (= 5.2.4.3)
actionview (= 5.2.4.3)
activejob (= 5.2.4.3)
actionmailer (5.2.4.4)
actionpack (= 5.2.4.4)
actionview (= 5.2.4.4)
activejob (= 5.2.4.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.4.3)
actionview (= 5.2.4.3)
activesupport (= 5.2.4.3)
actionpack (5.2.4.4)
actionview (= 5.2.4.4)
activesupport (= 5.2.4.4)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.4.3)
activesupport (= 5.2.4.3)
actionview (5.2.4.4)
activesupport (= 5.2.4.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.4.3)
activesupport (= 5.2.4.3)
activejob (5.2.4.4)
activesupport (= 5.2.4.4)
globalid (>= 0.3.6)
activemodel (5.2.4.3)
activesupport (= 5.2.4.3)
activerecord (5.2.4.3)
activemodel (= 5.2.4.3)
activesupport (= 5.2.4.3)
activemodel (5.2.4.4)
activesupport (= 5.2.4.4)
activerecord (5.2.4.4)
activemodel (= 5.2.4.4)
activesupport (= 5.2.4.4)
arel (>= 9.0)
activestorage (5.2.4.3)
actionpack (= 5.2.4.3)
activerecord (= 5.2.4.3)
activestorage (5.2.4.4)
actionpack (= 5.2.4.4)
activerecord (= 5.2.4.4)
marcel (~> 0.3.1)
activesupport (5.2.4.3)
activesupport (5.2.4.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (9.0.0)
builder (3.2.4)
concurrent-ruby (1.1.6)
concurrent-ruby (1.1.7)
crass (1.0.6)
erubi (1.9.0)
erubi (1.10.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
loofah (2.6.0)
loofah (2.7.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
Expand All @@ -68,49 +68,49 @@ GEM
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.1)
nio4r (2.5.2)
minitest (5.14.2)
nio4r (2.5.4)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.4.3)
actioncable (= 5.2.4.3)
actionmailer (= 5.2.4.3)
actionpack (= 5.2.4.3)
actionview (= 5.2.4.3)
activejob (= 5.2.4.3)
activemodel (= 5.2.4.3)
activerecord (= 5.2.4.3)
activestorage (= 5.2.4.3)
activesupport (= 5.2.4.3)
rails (5.2.4.4)
actioncable (= 5.2.4.4)
actionmailer (= 5.2.4.4)
actionpack (= 5.2.4.4)
actionview (= 5.2.4.4)
activejob (= 5.2.4.4)
activemodel (= 5.2.4.4)
activerecord (= 5.2.4.4)
activestorage (= 5.2.4.4)
activesupport (= 5.2.4.4)
bundler (>= 1.3.0)
railties (= 5.2.4.3)
railties (= 5.2.4.4)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.2.4.3)
actionpack (= 5.2.4.3)
activesupport (= 5.2.4.3)
railties (5.2.4.4)
actionpack (= 5.2.4.4)
activesupport (= 5.2.4.4)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rake (13.0.1)
sprockets (4.0.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)
sqlite3 (1.4.2)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.7)
tzinfo (1.2.8)
thread_safe (~> 0.1)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery3
//= require jquery_ujs
//= require bootstrap-sprockets

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/orchid/search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$(function() {
// Filter collapse/expand indicators
$('.search_form .panel-heading').click(function() {
$('.search_form .panel-heading-link').click(function() {
$this = $(this)
if ( $this.find('.glyphicon-chevron-right').length > 0 ) {
$this.find('.glyphicon-chevron-right')
Expand Down
6 changes: 6 additions & 0 deletions app/assets/stylesheets/orchid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
}
}

.panel-heading-link > .panel-heading {
color: $gray-dark;
background-color: $panel-default-heading-bg;
border-color: $panel-inner-border;
}

// Index Pages
.index_num {
font-size: 1.2em;
Expand Down
13 changes: 11 additions & 2 deletions app/controllers/items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def browse_facet
@res = @items_api.query(options).facets

# Warn when approaching facet result limit
result_size = @res.length
result_size = @res ? @res.length : 0
if result_size == 10000
raise {"Facet results list has hit the limit of 10000. Revisit facet
result handling NOW"}
Expand All @@ -55,6 +55,7 @@ def browse_facet
end

@title = "#{t "browse.browse_type"} #{@browse_facet_info["label"]}"
check_response
render_overridable("items", "browse_facet", locals: { sort_by: sort_by })
end

Expand All @@ -70,16 +71,24 @@ def index

@title = t "search.title"
@res = @items_api.query(options)

check_response
render_overridable("items", "index")
end

def show
item_retrieve(params["id"])
check_response
end

private

# display a flash message if the API response has an error
def check_response
if !@res || @res.error
flash[:error] = t "errors.api"
end
end

def item_retrieve(id)
@res = @items_api.get_item_by_id(id).first
if @res
Expand Down
5 changes: 4 additions & 1 deletion app/services/api_bridge/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ def send_request(url)
res = Net::HTTP.get_response(URI(url))
JSON.parse(res.body)
rescue => e
raise "Something went wrong with request to #{url}: #{e.inspect}"
Rails.logger.error("Something wrong with API request to #{url}: #{e.inspect}")
{
"error" => e.inspect
}
end
end

Expand Down
4 changes: 4 additions & 0 deletions app/services/api_bridge/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def count
@res.dig("res", "count")
end

def error
@res.dig("error")
end

def facets
@res.dig("res", "facets")
end
Expand Down
18 changes: 12 additions & 6 deletions app/views/items/_date_limit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
<% class_glyphicon = date_selected ? "glyphicon-chevron-down" : "glyphicon-chevron-right" %>

<div class="panel panel-default panel-filter panel-filter-date">
<div class="clearfix panel-heading" data-toggle="collapse"
data-target="#dates" role="Option"
aria-label="<%= t "search.dates.show_filters", default: "Show Date Filters" %>">
<h3 class="pull-left panel-title"><%= t "search.dates.date", default: "Date" %></h3>
<span class="pull-right glyphicon <%= class_glyphicon %>" aria-hidden="true"></span>
</div>
<a aria-label="<%= t "search.dates.show_filters", default: "Show Date Filters" %>"
class="panel-heading-link"
data-toggle="collapse"
href="#dates"
role="button">
<div class="clearfix panel-heading">
<h3 class="pull-left panel-title">
<%= t "search.dates.date", default: "Date" %>
</h3>
<span class="pull-right glyphicon <%= class_glyphicon %>" aria-hidden="true"></span>
</div>
</a>
<div class="panel-body collapse <%= class_in %>" id="dates">
<%= form_tag prefix_path(route_path), method: "get" do %>
<%# date from %>
Expand Down
19 changes: 13 additions & 6 deletions app/views/items/_facets.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@
<div class="panel panel-default panel-filter panel-filter-<%= info['label'].parameterize %>">

<!-- panel heading -->
<div class="clearfix panel-heading" data-toggle="collapse"
data-target="#fc-<%= data_safe_name %>" role="Option"
aria-label="<%= t("search.filters.show", label: info['label'], default: "Show #{info['label']} Filters") %>">
<h3 class="pull-left panel-title"><%= info["label"] %></h3>
<span class="pull-right glyphicon <%= class_glyphicon %>" aria-hidden="true"></span>
</div>
<a
aria-label="<%= t("search.filters.show", label: info['label'], default: "Show #{info['label']} Filters") %>"
class="panel-heading-link"
data-toggle="collapse"
href="#fc-<%= data_safe_name %>"
role="button">
<div class="clearfix panel-heading">
<h3 class="pull-left panel-title">
<%= info["label"] %>
</h3>
<span class="pull-right glyphicon <%= class_glyphicon %>" aria-hidden="true"></span>
</div>
</a>

<!-- panel body -->
<%# if requested parameter, then do not collapse facet %>
Expand Down
4 changes: 3 additions & 1 deletion app/views/items/_search_res_count.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<% if params["q"].blank? && params["f"].blank? %>
<% if @res.count.blank? %>
<h2><%= t "search.results.error" %></h2>
<% elsif params["q"].blank? && params["f"].blank? %>
<h2><%= t "search.results.query", count: @res.count %></h2>
<% else %>
<h2><%= t "search.results.general", count: @res.count %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/items/_search_res_items.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if @res.count > 0 %>
<% if @res.present? && @res.count > 0 %>
<% @res.items.each do |item| %>
<div class="searchResults buffer-bottom-sm">
<h3><%= search_item_link(item) %></h3>
Expand Down
2 changes: 1 addition & 1 deletion app/views/items/_sort_and_page_ui.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="row search_controls">
<div class="col-md-4 search_limit">
<% if (@res.count > 1) %>
<% if (@res.count && @res.count > 1) %>
<%= sorter %>
<% end %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/items/browse_facet.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<% id = facet_name.parameterize(separator: ".") %>
<div role="tabpanel"
class="tab-pane <%= active?(facet_name, @browse_facet) %>" id="<%= id %>">
<% if @res.key?(facet_name) %>
<% if @res && @res.key?(facet_name) %>
<table class="index_table">
<tbody>
<% @res[facet_name].each do |list| %>
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ en:
# ERRORS #
##########
errors:
# unable to contact the API
api: Some contents of the site are unavailable at this time, please check back later.
# general consolation message to the user on an error
apology: We're sorry for the inconvenience.
# browse page specific message when selected facet cannot be viewed
Expand Down Expand Up @@ -219,6 +221,8 @@ en:
# placeholder for the text search field
placeholder: Search for...
results:
# display for number of results when API response is error
error: Unable to display results
# how to display number of results when no search / filters have been applied
# and therefore user is browsing all items
general:
Expand Down
4 changes: 4 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ es:
# ERRORS #
##########
errors:
# unable to contact API
api: Algunos contenidos del sitio no están disponibles. Por favor, vuelva más tarde.
# general consolation message to the user on an error
apology: Le pedimos disculpas por la inconveniencia, ocurrió un error.
# browse page specific message when selected facet cannot be viewed
Expand Down Expand Up @@ -218,6 +220,8 @@ es:
# placeholder for the text search field
placeholder: Buscar...
results:
# display for number of results when API response is error
error: Los resultados no se pueden visualizar
# how to display number of results when no search / filters have been applied
# and therefore user is browsing all items
general:
Expand Down
Loading

0 comments on commit b7713ba

Please sign in to comment.