Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My table layout and collection info #567

Merged
merged 1 commit into from
Jul 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions app/assets/javascripts/sufia.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,6 @@ Blacklight.onLoad(function() {
});
};

// show/hide more information on the dashboard when clicking
// plus/minus
$('.glyphicon-plus').on('click', function() {
var button = $(this);
//this.id format: "expand_NNNNNNNNNN"
var array = this.id.split("expand_");
if (array.length > 1) {
var docId = array[1];
$("#detail_" + docId + " .expanded-details").slideToggle();
button.toggleClass('glyphicon-plus glyphicon-minus');
}
return false;
});

$('#add_descriptions').click(function() {
$('#more_descriptions').show();
$('#add_descriptions').hide();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really like this moved out of sufia.js into it's own file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

Expand Down
33 changes: 23 additions & 10 deletions app/assets/javascripts/sufia/dashboard_actions.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
Blacklight.onLoad(function() {
// toggle button on or off based on boxes being clicked
$(".batch_document_selector, .batch_document_selector_all").bind('click', function(e) {
var n = $(".batch_document_selector:checked").length;
if (n>0 || $('input#check_all')[0].checked) {
$('.sort-toggle').hide();
} else {
$('.sort-toggle').show();
}
// toggle button on or off based on boxes being clicked
$(".batch_document_selector, .batch_document_selector_all").bind('click', function(e) {
var n = $(".batch_document_selector:checked").length;
if (n>0 || $('input#check_all')[0].checked) {
$('.sort-toggle').hide();
} else {
$('.sort-toggle').show();
}
});

});
});
// show/hide more information on the dashboard when clicking
// plus/minus
$('.glyphicon-chevron-right').on('click', function() {
var button = $(this);
//this.id format: "expand_NNNNNNNNNN"
var array = this.id.split("expand_");
if (array.length > 1) {
var docId = array[1];
$("#detail_" + docId + " .expanded-details").slideToggle();
button.toggleClass('glyphicon-chevron-right glyphicon-chevron-down');
}
return false;
});

});
37 changes: 23 additions & 14 deletions app/assets/stylesheets/file-listing.css.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
$gray-lightish: #bbb;
$gray-lighter: #eee;
h4 .small {
color: $navbar-default-toggle-icon-bar-bg;
}

.table thead th {
text-align: center;
}

th div.dropdown {
top: 1.25em;
}

.table {
> tbody {
> tr[id*='detail_'] {
Expand Down Expand Up @@ -44,7 +41,8 @@ th div.dropdown {
}

.file_listing_thumbnail {
width: 20%;
@extend .media-object;
width: 64px;
}

.nav > li > a.accordion-toggle {
Expand Down Expand Up @@ -78,12 +76,6 @@ th div.dropdown {

}

.cog {
position: relative;
top: -1.20em;
left: 1.25em;
}

.batch-info {
margin-bottom: 0.8em;
}
Expand Down Expand Up @@ -131,7 +123,16 @@ th div.dropdown {

.heading-row {
border-bottom: 1px solid $gray-lightish;
//margin-left: 10px;
}

input.batch_document_selector {
margin: 10px 10px 2px 10px;
padding: 0px;
}

input#check_all {
padding: 0;
margin: 3px 3px 3px 10px;
}

#collection-list-container {
Expand All @@ -147,3 +148,11 @@ th div.dropdown {
}
}

#documents {
.media-body {
padding-top: 12px;
}
td {
vertical-align: middle;
}
}
3 changes: 0 additions & 3 deletions app/assets/stylesheets/header.css.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
$gray-lightish: #bbb;
$gray-lighter: #eee;

#masthead {
background: #0071BC; /* Old browsers */
background-image: -webkit-gradient(
Expand Down
6 changes: 6 additions & 0 deletions app/assets/stylesheets/settings.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Settings
//
// Variables, colors, etc. that are used in Sufia.
// Some are unique or override other variables from Bootstrap.
$gray-lightish: #bbb;
$gray-lighter: #eee;
3 changes: 0 additions & 3 deletions app/assets/stylesheets/styles.css.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
$gray-lightish: #bbb;
$gray-lighter: #eee;

body {
margin: 0;
padding: 0;
Expand Down
11 changes: 7 additions & 4 deletions app/assets/stylesheets/sufia.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@
*= require video-js
*= require jquery-ui
*= require sufia-audio-overrides
*= require styles
*= require header
*= require home-page
*= require tagcloud
*= require featured
*= require file-listing
*= require usage-stats
*= require nestable
*/

@import 'bootstrap';

@import 'blacklight/blacklight';
@import "browse_everything";

// Use import here instead of require so we can use the Sass variables defined in Bootstrap and Blacklight
// TODO: Probably should use import throughout and move all of Sufia's stylesheets into a single named directory.
@import 'settings';
@import 'header';
@import 'styles';
@import 'file-listing';

#browse-everything {
top:10%;
background-color: initial;
Expand Down
6 changes: 6 additions & 0 deletions app/helpers/batch_edits_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ module BatchEditsHelper
def batch_delete
render partial: '/batch_edits/delete_selected'
end

def render_check_all
unless @disable_select_all || params[:controller].match("my/collections")
render partial: 'batch_edits/check_all'
end
end
end
6 changes: 6 additions & 0 deletions app/helpers/generic_file_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def render_download_link text = nil
link_to (text || "Download"), sufia.download_path(@generic_file.noid), { id: "file_download", target: "_new", data: { label: @generic_file.id } }
end

def render_collection_list gf
unless gf.collections.empty?
("Is part of: " + gf.collections.map { |c| link_to(c.title, collections.collection_path(c.id)) }.join(", ")).html_safe
end
end

private

def render_edit_field_partial_with_action(action, key, locals)
Expand Down
16 changes: 7 additions & 9 deletions app/views/batch_edits/_check_all.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<% if !@disable_select_all %>
<div class="dropdown" >
<%= check_box_tag 'check_all', 'yes', @all_checked, class: 'pull-left', disabled: ((@batch_size_on_other_page + @document_list.count) > @max_batch_size) %>
<a class="dropdown-toggle cog" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-cog" title="click for selection options"></span></a>
<ul class="dropdown-menu">
<%= render partial: "#{controller_name}/batch_edits_actions" %>
</ul>
</div>
<% end %>
<div class="dropdown" >
<%= check_box_tag 'check_all', 'yes', @all_checked, class: 'pull-left', disabled: ((@batch_size_on_other_page + @document_list.count) > @max_batch_size) %>
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-cog" title="click for selection options"></span></a>
<ul class="dropdown-menu">
<%= render partial: "#{controller_name}/batch_edits_actions" %>
</ul>
</div>
6 changes: 3 additions & 3 deletions app/views/my/_collection_action_menu.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="btn-group">
<button class="btn btn-sm" href="#"><i class="glyphicon glyphicon-wrench"></i> Select an action</button>
<button class="btn btn-sm dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-chevron-down"></span></button>
<ul class="dropdown-menu">
<button class="btn btn-sm dropdown-toggle" data-toggle="dropdown">Select an action <span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li>
<%= link_to raw('<i class="glyphicon glyphicon-pencil"></i> Edit Collection'), collections.edit_collection_path(noid),
class: 'itemicon itemedit', title: 'Edit Collection' %>
Expand Down
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">
<div class="table-responsive" id="documents">
<%= render partial: 'my/_index_partials/default_group', locals: {docs: @response.docs.map { |x| SolrDocument.new(x) }, facet_value: nil} %>
</div>
2 changes: 1 addition & 1 deletion app/views/my/_index_partials/_default_group.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% unless params[:display_type] == 'list' %>
<thead>
<tr>
<th><%= render partial: 'batch_edits/check_all' %></th>
<th><%= render_check_all %></th>
<th>Title</th>
<th class="sorts-dash"><i id="desc_metadata__date_uploaded_dtsi" class="<%=params[:sort]== "desc_metadata__date_uploaded_dtsi desc" ? 'caret' : params[:sort]== "desc_metadata__date_uploaded_dtsi asc" ? 'caret up' : ''%>"></i>Date Uploaded</th>
<th>Visibility</th>
Expand Down
20 changes: 13 additions & 7 deletions app/views/my/_index_partials/_list_collections.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
on element ids -->
<% noid = document.noid %>
<tr id="document_<%= noid %>" class="<%= cycle("","zebra") %>">
<td width="6%"></td>
<td width="38%">
<a href="" title="Click for more details"><i id="expand_<%= noid.gsub(":", "_") %>" class="glyphicon glyphicon-plus"></i></a>&nbsp;
<%= link_to image_tag("/assets/folder.png", width: 36), collections.collection_path(noid) %>
<span class=center><%= link_to document.title_or_label, collections.collection_path(noid), id: "src_copy_link#{noid}" %> <br /></span>
<td width="3%"></td>
<td width="41%">
<div class="media">
<%= link_to image_tag("/assets/folder.png", class: "hidden-xs file_listing_thumbnail"), collections.collection_path(noid), class: "pull-left" %>
<div class="media-body">
<h4 class="media-heading">
<%= link_to document.title_or_label, collections.collection_path(noid), id: "src_copy_link#{noid}" %>
<a href="#" class="small" title="Click for more details"><i id="expand_<%= noid %>" class="glyphicon glyphicon-chevron-right"></i></a>
</h4>
</div>
</div>
</td>
<td width="17%"><%= document.date_uploaded %> </td>
<td width="5%" class="center">
<td width="5%" class="text-center">
<% if document.registered? %>
<span class="label label-info" title="<%=t('sufia.institution_name') %>"><%=t('sufia.institution_name') %></span></a>
<% elsif document.public? %>
Expand All @@ -21,7 +27,7 @@ on element ids -->
<% end %>

</td>
<td class="center">
<td class="text-center">
<%= render partial:'collection_action_menu', locals:{noid:noid} %>
</td>
</tr>
Expand Down
29 changes: 17 additions & 12 deletions app/views/my/_index_partials/_list_files.html.erb
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
<% noid = document.noid %>
<tr id="document_<%= noid %>" class="<%= cycle("", "zebra") %>">
<% gf = GenericFile.load_instance_from_solr(document.id) %>
<td width="3%"><%= batch_edit_select(document) %>&nbsp;
<td><%= batch_edit_select(document) %>&nbsp;
<%# This block is for adding/removing the magic wand while batch updates are processing %>
<% if gf.processing? %>
<i class="glyphicon glyphicon-time <%= 'ss-'+gf.batch.noid %>"/>
<% elsif gf.depositor != @user.user_key %>
<i class="glyphicon glyphicon-share-alt"/>
<% end %>
</td>
<td width="41%">
<a href="#" title="Click for more details"><i id="expand_<%= noid %>" class="glyphicon glyphicon-plus"></i></a>&nbsp;
<%= link_to sufia.generic_file_path(document) do %>
<%= render_thumbnail_tag document, class:"hidden-xs file_listing_thumbnail" %>
<% end %>
<span>
<%= link_to document.title_or_label, sufia.generic_file_path(noid), id: "src_copy_link#{noid}", class: "#{'document-title' if document.title_or_label == document.label}" %><br/>
</span>
<td>
<div class="media">
<%= link_to sufia.generic_file_path(document), class: "pull-left" do %>
<%= render_thumbnail_tag document, { class: "hidden-xs file_listing_thumbnail" }, { suppress_link: true } %>
<% end %>
<div class="media-body">
<h4 class="media-heading">
<%= link_to document.title_or_label, sufia.generic_file_path(noid), id: "src_copy_link#{noid}", class: "#{'document-title' if document.title_or_label == document.label}" %>
<a href="#" class="small" title="Click for more details"><i id="expand_<%= noid %>" class="glyphicon glyphicon-chevron-right"></i></a>
</h4>
<%= render_collection_list(gf) %>
</div>
</div>
</td>
<td width="17%" class="text-center"><%= document.date_uploaded %> </td>
<td width="5%" class="text-center">
<td class="text-center"><%= document.date_uploaded %> </td>
<td class="text-center">
<a href="<%= sufia.generic_file_path(noid) %>/edit/?tab=permissions" id="permission_<%= noid %>" class="visibility-link">
<% if document.registered? %>
<span class="label label-info" title="<%= t('sufia.institution_name') %>"><%= t('sufia.institution_name') %></span>
Expand All @@ -30,7 +35,7 @@
<% end %>
</a>
</td>
<td width="23%" class="text-center">
<td class="text-center">
<%= render partial: 'action_menu', locals: { noid: noid, gf: gf } %>
</td>
</tr>
Expand Down
3 changes: 2 additions & 1 deletion spec/features/browse_dashboard_files_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
visit "dashboard/files"
end

it "should show me some files" do
it "should show me files that are not part of any collection" do
expect(page).to have_content("Edit File")
expect(page).to have_content("Download File")
expect(page).to_not have_content("Is part of:")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while this is the "correct" way to write a feature test. It's going to do a whole request/response cycle just for this. That's making our test suite slow. Can this be combined into another test that tests a whole "Feature", or can this be moved to a view test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've combined the two feature tests into one which reduces the request/response cycle back to its original state.

Regarding feature vs. view tests, I took the path of least resistance which was to simply expand the current feature tests by a few lines to cover the new bit. It seems to me there's a larger problem of feature tests that should be view tests overall, and is perhaps beyond the scope of this PR.

end

it "should allow you to search your own files" do
Expand Down
38 changes: 38 additions & 0 deletions spec/helpers/batch_edits_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'spec_helper'

describe BatchEditsHelper do

describe "#render_check_all" do

before do
@document_list = ["doc1", "doc2"]
@batch_size_on_other_page = 1
@max_batch_size = 10
end

context "with my files" do
it "should show the check all dropdown" do
allow(helper).to receive(:params).and_return({ controller: "my/files" })
allow(helper).to receive(:controller_name).and_return("batch_edits")
expect(helper.render_check_all).to have_css("span.glyphicon-cog")
end
end

context "with my collections" do
it "should not show the check all dropdown" do
allow(helper).to receive(:params).and_return({ controller: "my/collections" })
expect(helper.render_check_all).to be_nil
end
end

context "with select all disabled" do
it "should not show the check all dropdown" do
allow(helper).to receive(:params).and_return({ controller: "foo" })
assign(:disable_select_all, true)
expect(helper.render_check_all).to be_nil
end
end

end

end
Loading