Skip to content

Commit

Permalink
Updating modals and fixing facet features #428
Browse files Browse the repository at this point in the history
  • Loading branch information
awead committed Jun 3, 2014
1 parent 93c9f08 commit 3e7bbf2
Show file tree
Hide file tree
Showing 23 changed files with 132 additions and 102 deletions.
6 changes: 1 addition & 5 deletions app/controllers/concerns/sufia/my_controller_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,8 @@ def index
end
end

def search_action_url opts={}
sufia.url_for(opts)
end

protected

# show only files with edit permissions in lib/hydra/access_controls_enforcement.rb apply_gated_discovery
def discovery_permissions
["edit"]
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/my/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@ def index
super
@selected_tab = :collections
end

protected

def search_action_url *args
sufia.dashboard_collections_url *args
end

end
end
7 changes: 7 additions & 0 deletions app/controllers/my/files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@ def index
super
@selected_tab = :files
end

protected

def search_action_url *args
sufia.dashboard_files_url *args
end

end
end

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
<div class="col-xs-4 heading-tile">
<span class="glyphicon glyphicon-folder-open"></span>
<%= link_to t("sufia.dashboard.create_collection"), collections.new_collection_path %>
<%= link_to t("sufia.dashboard.create_collection"), collections.new_collection_path, id: "hydra-collection-add" %>
</div>
<div class="col-xs-4 heading-tile">
<span class="glyphicon glyphicon-eye-open"></span>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/homepage.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
</div><!-- /#page-positioner -->
</div><!-- /.container -->
</div><!-- /#wrapper -->
<div id="ajax-modal" class="modal hide" tabindex="-1"></div>
<%= render 'shared/ajax_modal' %>
</body>
</html>
12 changes: 6 additions & 6 deletions app/views/layouts/sufia-dashboard.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<!DOCTYPE html>
<html>
<head><%= render partial: "layouts/head_tag_content" %></head>
<head><%= render partial: 'layouts/head_tag_content' %></head>
<body>
<div id="wrapper">
<div class="container-fluid">
<div id="page-positioner">

<%= render partial: "/masthead" %>
<%= render partial: "/controls" %>
<%= render partial: "/flash_msg" %>
<%= render partial: '/masthead' %>
<%= render partial: '/controls' %>
<%= render partial: '/flash_msg' %>

<div id="content-wrapper">
<div class="container-fluid">
Expand All @@ -22,11 +22,11 @@
</div>
</div>

<%= render partial: "/footer" %>
<%= render partial: '/footer' %>

</div><!-- /#page-positioner -->
</div><!-- /.container -->
</div><!-- /#wrapper -->
<div id="ajax-modal" class="modal hide" tabindex="-1"></div>
<%= render 'shared/ajax_modal' %>
</body>
</html>
4 changes: 2 additions & 2 deletions app/views/layouts/sufia-one-column.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<%= render partial: "layouts/head_tag_content"%>
<%= render partial: 'layouts/head_tag_content' %>
</head>

<body>
Expand All @@ -22,6 +22,6 @@
</div><!-- /#page-positioner -->
</div><!-- /.container -->
</div><!-- /#wrapper -->
<div id="ajax-modal" class="modal hide" tabindex="-1"></div>
<%= render 'shared/ajax_modal' %>
</body>
</html>
4 changes: 2 additions & 2 deletions app/views/layouts/sufia-two-column.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<%= render partial: "layouts/head_tag_content"%>
<%= render partial: 'layouts/head_tag_content' %>
</head>

<body>
Expand All @@ -25,6 +25,6 @@
</div><!-- /#page-positioner -->
</div><!-- /.container -->
</div><!-- /#wrapper -->
<div id="ajax-modal" class="modal hide" tabindex="-1"></div>
<%= render 'shared/ajax_modal' %>
</body>
</html>
9 changes: 2 additions & 7 deletions app/views/my/_did_you_mean.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<% if @response.response[:numFound] <= spell_check_max and @response.spelling.words.size > 0 %>
<% if should_show_spellcheck_suggestions? @response %>
<div id="spell">
<h4 class="suggest"><i>Did you mean to type
<% @response.spelling.words.each_with_index do |word,index| -%>
<% if index > 0 -%>, or <% end -%>
<%= link_to_query(word) -%>
<% end -%>
?</i></h4>
<h4 class="suggest"><em><%= t('blacklight.did_you_mean', :options => safe_join(@response.spelling.words.map { |word| link_to_query(word) }, " #{t('blacklight.or')} ")).html_safe %></em></h4>
</div>
<% end %>
2 changes: 1 addition & 1 deletion app/views/my/_document_list.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% # container for all documents in index view -%>
<div id="documents" class="clear">
<div id="documents">
<%= render partial: 'my/_index_partials/default_group', locals: {docs: @response.docs.map { |x| SolrDocument.new(x) }, facet_value: nil} %>
</div>
19 changes: 10 additions & 9 deletions app/views/my/_facet_layout.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<li class="expandable_new grey">
<% id = facet_field.label.gsub(" ","_")+"_db" %>

<a class="accordion-toggle grey" data-toggle="collapse" data-parent="#facet_group" data-target="#collapse_<%= id%>">
<%= facet_field.label %> <i class="glyphicon glyphicon-chevron-right grey"></i>
</a>

<div id="collapse_<%= id%>" class="accordion-body collapse">
<div class="panel panel-default facet_limit blacklight-<%= facet_field.field.parameterize %> <%= 'facet_limit-active' if facet_field_in_params?(facet_field.field) %>">
<div class="<%= "collapsed" if should_collapse_facet?(facet_field) %> collapse-toggle panel-heading" data-toggle="collapse" data-target="#<%= facet_field_id(facet_field) %>">
<h5 class="panel-title">
<%= link_to facet_field_label(facet_field.field), "#", :"data-no-turbolink" => true %>

This comment has been minimized.

Copy link
@awead

awead Jun 3, 2014

Author Contributor

@mjgiarlo I think this one has to stay, though.

This comment has been minimized.

Copy link
@mjgiarlo

mjgiarlo Jun 3, 2014

Member

Indeed, it does. (We still have a bunch of hashrockets like this lying around, but there's nothing much to be done about them, eh?) Heh!

</h5>
</div>
<div id="<%= facet_field_id(facet_field) %>" class="panel-collapse facet-content <%= should_collapse_facet?(facet_field) ? 'collapse' : 'in' %>">
<div class="panel-body">
<%= yield %>
</div>
</div>
</li>
</div>
18 changes: 9 additions & 9 deletions app/views/my/_facet_limit.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<% paginator = Blacklight::Solr::FacetPaginator.new(display_facet.items,
limit: facet_limit_for(solr_field)) %>
<ul class="slide-list">
<ul class="facet-values list-unstyled">
<% paginator = facet_paginator(facet_field, display_facet) %>
<% paginator.items.each do |item| -%>
<li>
<% if facet_in_params?( solr_field, item.value ) %>
<%= render_selected_facet_value(solr_field, item) %>
<% else %>
<%= render_facet_value(solr_field, item) %>
<li>
<% if facet_in_params?(solr_field, item.value) %>
<%= render_selected_facet_value(solr_field, item) %>
<% else %>
<%= render_facet_value(solr_field, item) %>
<% end -%>
</li>
<% end %>
<% if(paginator.has_next?) %>
<li class="more_facets_link"><%= link_to 'more ' + facet_field.label.pluralize + '»', sufia.url_for(params.merge(id: solr_field, action: "facet", path_only: true)), class: "more_facets_link" %></li>
<% end %>
</ul> <!-- /slide-list -->

</ul>
31 changes: 14 additions & 17 deletions app/views/my/_facet_pagination.html.erb
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
<!-- This was copied from https://github.com/projectblacklight/blacklight/blob/master/app/views/catalog/_facet_pagination.html.erb
It implements the facets in the same manner as blacklight does for the main catalog for the individual's dashbord
-->
<div class="prev_next_links btn-group pull-left">
<%= link_to_previous_page @pagination, raw(t('views.pagination.previous')), route_set: sufia, params: params, param_name: Blacklight::Solr::FacetPaginator.request_keys[:page], class: 'btn' do %>
<span class="disabled btn"><%= raw(t('views.pagination.previous')) %></span>
<%= link_to_previous_page @pagination, raw(t('views.pagination.previous')), route_set: sufia, params: params, param_name: Blacklight::Solr::FacetPaginator.request_keys[:page], class: 'btn btn-link', data: {ajax_modal: "preserve"} do %>
<span class="disabled btn btn-disabled"><%= raw(t('views.pagination.previous')) %></span>
<% end %>
<%= link_to_next_page @pagination, raw(t('views.pagination.next')), route_set: sufia, params: params, param_name: Blacklight::Solr::FacetPaginator.request_keys[:page], class: 'btn' do %>

<span class="disabled btn"><%= raw(t('views.pagination.next')) %></span>
<%= link_to_next_page @pagination, raw(t('views.pagination.next')), route_set: sufia, params: params, param_name: Blacklight::Solr::FacetPaginator.request_keys[:page], class: 'btn btn-link', data: {ajax_modal: "preserve"} do %>
<span class="disabled btn btn-disabled"><%= raw(t('views.pagination.next')) %></span>
<% end %>

</div>

<div class="sort_options btn-group pull-right">
<% if @pagination.sort == 'index' -%>
<span class="active az btn"><%= t('blacklight.search.facets.sort.index') %></span><%= link_to_unless(@pagination.sort == 'count', t('blacklight.search.facets.sort.count'),
Sufia::Engine.routes.url_for(@pagination.params_for_resort_url('count', params).symbolize_keys.merge(only_path: true)),
class: "sort_change numeric btn") %>
<span class="active az btn btn-default"><%= t('blacklight.search.facets.sort.index') %></span><%= link_to_unless(@pagination.sort == 'count', t('blacklight.search.facets.sort.count'),
Sufia::Engine.routes.url_for(@pagination.params_for_resort_url('count', params).symbolize_keys.merge(only_path: true)),
class: "sort_change numeric btn btn-default",
data: {ajax_modal: "preserve"}) %>
<% elsif @pagination.sort == 'count' -%>
<%= link_to(t('blacklight.search.facets.sort.index'),
Sufia::Engine.routes.url_for(@pagination.params_for_resort_url('index', params).symbolize_keys.merge(only_path: true)),
class: "sort_change az btn") %><span class="active numeric btn"><%= t('blacklight.search.facets.sort.count') %></span>
<% end -%>
<%= link_to(t('blacklight.search.facets.sort.index'), Sufia::Engine.routes.url_for(@pagination.params_for_resort_url('index', params).symbolize_keys.merge(only_path: true)),
class: "sort_change az btn btn-default", data: {ajax_modal: "preserve"}) %><span class="active numeric btn btn-default"><%= t('blacklight.search.facets.sort.count') %></span>
<% end -%>
</div>
2 changes: 1 addition & 1 deletion app/views/my/_facet_selected.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<% v.each do |selected_facet| %>
<% link_options = remove_facet_params(k, selected_facet, params).merge(action: :index) %>
<div class="alert alert-warning">
<%= link_to 'X', sufia.url_for(link_options), {class: 'close', :'data-dismiss' => "alert" } %>
<%= link_to "X", sufia.url_for(link_options), { class: "close", data: { dismiss: "alert" } } %>
<i class="glyphicon glyphicon-ok"></i> <strong><%= selected_facet %></strong>
</div>
<% end %>
Expand Down
27 changes: 20 additions & 7 deletions app/views/my/_facets.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
<% # main container for facets/limits menu -%>
<div>
<%= render partial: 'collections/button_for_creating_empty_collection', locals: {label: 'Create Collection'} %>
<div class="row">&nbsp;</div>
<h2>Browse By</h2>
<ul class="nav nav-list" id="facets">
<%= render_facet_partials %>
</ul>
<% if has_facet_values? %>
<div id="facets" class="facets sidenav">
<div class="top-panel-heading panel-heading">
<button type="button" class="facets-toggle" data-toggle="collapse" data-target="#facet-panel-collapse">
<span class="sr-only">Toggle facets</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<h4>
<%= t('blacklight.search.facets.title') %>
</h4>
</div>
<div id="facet-panel-collapse" class="collapse panel-group">
<%= render_facet_partials %>
</div>
</div>
<% end %>
11 changes: 7 additions & 4 deletions app/views/my/_results_pagination.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<% if @response.total_pages > 1 %>
<div class="pager">
<%= paginate @response, outer_window: 2, theme: 'blacklight', route_set: sufia %>
<div class="clearfix"></div>
</div><!-- /pager -->
<div class="row record-padding">
<div class="col-md-9">
<div class="pagination">
<%= paginate @response, outer_window: 2, theme: 'blacklight', route_set: sufia %>
</div>
</div>
</div>
<% end %>
7 changes: 2 additions & 5 deletions app/views/my/facet.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<!-- This was copied from https://github.com/projectblacklight/blacklight/blob/master/app/views/catalog/facet.html.erb
It implements the facets in the same manner as blacklight does for the main catalog for the individual's dashbord
-->
<div class="facet_pagination top">
<%= render partial: 'facet_pagination' %>
</div>
Expand All @@ -11,10 +8,10 @@
</div>
<div class="modal-body">
<div class="facet_extended_list">
<%= render_facet_limit(@display_facet, layout: false) %>
<%= render_facet_limit(@display_facet, layout: false) %>
</div>
</div>

<div class="modal-footer">

<div class="facet_pagination bottom">
Expand Down
8 changes: 4 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@
scope :dashboard do
get '/files', controller: 'my/files', action: :index, as: 'dashboard_files'
get '/files/page/:page', controller: 'my/files', action: :index
get '/files/facet/:id', controller: 'my/files', action: :facet, as: 'dashboard_facet_dashboard_files'
get '/files/facet/:id', controller: 'my/files', action: :facet, as: 'dashboard_files_facet'

get '/collections', controller: 'my/collections', action: :index, as: 'dashboard_collections'
get '/collections/page/:page', controller: 'my/collections', action: :index
get '/collections/facet/:id', controller: 'my/collections', action: :facet, as: 'dashboard_facet_dashboard_collections'
get '/collections/facet/:id', controller: 'my/collections', action: :facet, as: 'dashboard_collections_facet'

get '/highlights', controller: 'my/highlights', action: :index, as: 'dashboard_highlights'
get '/highlights/page/:page', controller: 'my/highlights', action: :index
get '/highlights/facet/:id', controller: 'my/highlights', action: :facet, as: 'dashboard_facet_dashboard_highlights'
get '/highlights/facet/:id', controller: 'my/highlights', action: :facet, as: 'dashboard_highlights_facet'

get '/shares', controller: 'my/shares', action: :index, as: 'dashboard_shares'
get '/shares/page/:page', controller: 'my/shares', action: :index
get '/shares/facet/:id', controller: 'my/shares', action: :facet, as: 'dashboard_facet_dashboard_shares'
get '/shares/facet/:id', controller: 'my/shares', action: :facet, as: 'dashboard_shares_facet'
end

# advanced routes for advanced search
Expand Down
2 changes: 0 additions & 2 deletions spec/features/browse_dashboard_files_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@
end

it "should allow you to browse facets" do
pending "Issue #428 is causing this"
click_link "more Subjects"
click_link "consectetur"
save_and_open_page
within("#document_#{@fixtures[1].noid}") do
click_link "Test Document MP3.mp3"
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe 'collection' do
def create_collection(title, description)
visit '/dashboard'
first('#hydra-collection-add').click
expect(page).to have_content 'Create New Collection'
fill_in('Title', with: title)
Expand Down Expand Up @@ -50,7 +51,6 @@ def create_collection(title, description)
end
it "should create collection from the dashboard and include files", js: true do
create_collection(title2, description2)

visit '/dashboard/files'
first('input#check_all').click
click_button "Add to Collection" # opens the modal
Expand Down
34 changes: 34 additions & 0 deletions spec/views/my/facet.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require 'spec_helper'

# Note: this is a direct copy of the corresponding test in Blacklight
# with changes for "views/my" instead of "views/catalog"

describe "my/facet.html.erb" do
let(:display_facet) { double }
let(:blacklight_config) { Blacklight::Configuration.new }
before do
blacklight_config.add_facet_field "xyz", label: "Facet title"
view.stub(:blacklight_config).and_return(blacklight_config)
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
stub_template "my/_facet_pagination.html.erb" => "pagination"
assign :facet, blacklight_config.facet_fields["xyz"]
assign :display_facet, display_facet
end

it "should have the facet title" do
allow(view).to receive(:render_facet_limit)
render
expect(rendered).to have_selector "h3", text: "Facet title"
end

it "should render facet pagination" do
allow(view).to receive(:render_facet_limit)
render
expect(rendered).to have_content "pagination"
end

it "should render the facet limit" do
expect(view).to receive(:render_facet_limit).with(display_facet, layout: false)
render
end
end
Loading

0 comments on commit 3e7bbf2

Please sign in to comment.