Skip to content

Commit

Permalink
AR-1630 show classification subgroups tree in search results
Browse files Browse the repository at this point in the history
  • Loading branch information
payten authored and marktriggs committed Jun 19, 2017
1 parent 67d7b36 commit 4f083e3
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 3 deletions.
43 changes: 42 additions & 1 deletion public-new/app/assets/javascripts/search.js
@@ -1,3 +1,6 @@
//= require largetree
//= require tree_renderer

/* search form javascript support */

var $template, $as;
Expand Down Expand Up @@ -68,4 +71,42 @@ function replace_id_ref($row, selector, type, num) {
$row.find(selector).each(function() {
$(this).attr(type, $(this).attr(type).replace('0', num));
});
}
}

// show subgroups within search results on demand
function toggle_subgroups(event) {
var $button = $(this);
var $result = $button.closest('.recordrow');
var $container = $result.find('.classification-subgroups');
var $tree = $result.find('.classification-subgroups-tree');

if ($tree.is(':visible')) {
$tree.hide();
$button.attr('aria-pressed', 'false').removeClass('active');
$button.find('.fa').removeClass('fa-minus').addClass('fa-plus');
} else {
$tree.show();

if ($tree.is(':empty')) {
var root_uri = $result.data('uri');
var should_link_to_record = true;

var tree = new LargeTree(new TreeDataSource(root_uri + '/tree'),
$tree,
root_uri,
true,
new SimpleRenderer(should_link_to_record),
$.noop,
$.noop);
}

$button.attr('aria-pressed', 'true').addClass('active');
$button.find('.fa').removeClass('fa-plus').addClass('fa-minus');
}
};

$(function() {
$('.search-results').on('click',
'.recordrow .classification-subgroups button.subgroup-toggle',
toggle_subgroups);
});
11 changes: 11 additions & 0 deletions public-new/app/assets/stylesheets/archivesspace/aspace.scss
Expand Up @@ -590,6 +590,17 @@ button.subject { /* class subject also turns up in finding aid transfor
color: #999;
font-style: italic;
}
.recordrow {
.classification-subgroups {
margin-top: 5px;

.classification-subgroups-tree.largetree-container {
max-height: 200px;
overflow: auto;
}
}
}

/* / search results */

/* hierarchy tree */
Expand Down
2 changes: 1 addition & 1 deletion public-new/app/views/search/search_results.html.erb
Expand Up @@ -29,7 +29,7 @@
<%= render partial: 'shared/sorter' %>

</div>
<div class="row"><div class="col-sm-12">
<div class="row search-results"><div class="col-sm-12">

<% @results.records.each do |result| %>
<%= render partial: 'shared/result', locals: {:result => result, :props => {:full => false}} %>
Expand Down
12 changes: 11 additions & 1 deletion public-new/app/views/shared/_result.html.erb
@@ -1,7 +1,7 @@
<%# any result that is going to be presented in a list %>
<%# Pry::ColorPrinter.pp(result['json'])%>
<% if !props.fetch(:full,false) %>
<div class="recordrow" style="clear:both">
<div class="recordrow" style="clear:both" data-uri="<%= result.uri %>">
<% end %>
<%= render partial: 'shared/idbadge', locals: {:result => result, :props => props } %>
<div class="recordsummary" style="clear:both">
Expand Down Expand Up @@ -61,6 +61,16 @@
<% if !props.fetch(:full,false) && result['primary_type'] == 'repository' %>
<div><strong><%= t('number_of', { :type => t('resource._plural') }) %></strong> <%= @counts[result.uri]['resource'] %></div>
<% end %>
<% if result['primary_type'] == 'classification' %>
<div class="classification-subgroups">
<button class="btn btn-default btn-sm subgroup-toggle" aria-pressed="false">
<i aria-hidden="true" class="fa fa-plus"></i>
<%= t('classification._public.actions.show_subgroups') %>
</button>
<div class="classification-subgroups-tree largetree-container" style="display: none;"></div>
</div>
<% end %>
</div>

<% if !props.fetch(:full,false) %>
Expand Down
3 changes: 3 additions & 0 deletions public-new/config/locales/en.yml
Expand Up @@ -413,6 +413,9 @@ en:
_plural: Record Groups
creator: Creator
identifier_separator: "."
_public:
actions:
show_subgroups: Show Subgroups

classification_term:
_singular: Record Group Term
Expand Down

0 comments on commit 4f083e3

Please sign in to comment.