Skip to content

Commit

Permalink
Display collections button only for my files
Browse files Browse the repository at this point in the history
  • Loading branch information
awead committed Jul 16, 2014
1 parent 50bdce7 commit 9411a12
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/helpers/sufia/dashboard_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def on_the_dashboard?
params[:controller].match(/^dashboard|my/)
end

def on_my_files?
params[:controller].match(/^my\/files/)
end

def number_of_files user=current_user
::GenericFile.where(Solrizer.solr_name('depositor', :stored_searchable) => user.user_key).count
end
Expand Down
16 changes: 9 additions & 7 deletions app/views/my/_sort_and_per_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
<%= render partial: 'collections/form_for_select_collection', locals: {user_collections: @user_collections} %>
</div>

<div class="batch-toggle">
<% session[:batch_edit_state] = "on" %>
<%= batch_edit_continue "Edit Selected" %>
<%= batch_delete %>
<%= button_tag "Add to Collection", class: 'btn btn-primary submits-batches submits-batches-add',
data: { toggle: "modal", target: "#collection-list-container" } %>
</div>
<% if on_my_files? %>
<div class="batch-toggle">
<% session[:batch_edit_state] = "on" %>
<%= batch_edit_continue "Edit Selected" %>
<%= batch_delete %>
<%= button_tag "Add to Collection", class: 'btn btn-primary submits-batches submits-batches-add',
data: { toggle: "modal", target: "#collection-list-container" } %>
</div>
<% end %>

<div class="sort-toggle">
<% unless @response.response['numFound'] < 2 %>
Expand Down
11 changes: 11 additions & 0 deletions spec/helpers/dashboard_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,15 @@
end
end

describe "#on_my_files" do
it "should return false when the controller isn't my files" do
allow(helper).to receive(:params).and_return({ controller: "my/collections" })
expect(helper).to_not be_on_my_files
end
it "should return true when the controller is my files" do
allow(helper).to receive(:params).and_return({ controller: "my/files" })
expect(helper).to be_on_my_files
end
end

end

0 comments on commit 9411a12

Please sign in to comment.