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

Add batch actions to all/managed works page. #2434

Merged
merged 1 commit into from
Jan 13, 2018
Merged

Add batch actions to all/managed works page. #2434

merged 1 commit into from
Jan 13, 2018

Conversation

jonathandixon
Copy link
Contributor

Adds ability to batch select works on the All/Managed page (dashboard/works) and perform batch operations: delete, add to a collection, and edit.

@samvera/hyrax-code-reviewers

@elrayle
Copy link
Contributor

elrayle commented Dec 22, 2017

This addresses issue #2280 - Make read access works available to add to collections

@jonathandixon
Copy link
Contributor Author

Added suggested tests: batch edit/delete that includes read-only works updates/deletes the edit access works and not the read access works.

@jcoyne jcoyne added the Collection impacts the Collection part of PCDM Model label Jan 8, 2018
Copy link
Member

@jcoyne jcoyne left a comment

Choose a reason for hiding this comment

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

Can you remove DashboardHelperBehavior#on_my_works? now? It doesn't appear to be used anymore.

@@ -12,6 +12,7 @@

context "on my works page" do
before do
view.lookup_context.prefixes.push "hyrax/my/works"
allow(view).to receive(:on_my_works?).and_return(true)
Copy link
Member

Choose a reason for hiding this comment

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

Remove

before do
view.lookup_context.prefixes.push "hyrax/my/collections"
allow(view).to receive(:on_my_works?).and_return(false)
Copy link
Member

Choose a reason for hiding this comment

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

remove?

@jonathandixon
Copy link
Contributor Author

@jcoyne I'm fine with removing DashboardHelperBehavior#on_my_works?. Should this be done in a separate issue? I worry that removing it here will get lost and that downstream applications that use it in their templates will have problems on upgrade.

@jcoyne
Copy link
Member

jcoyne commented Jan 9, 2018

@jonathandixon I think you should just remove it here because we have no other uses of it in hyrax. If you don't want to remove it here out of an abundance of caution, you should at least deprecate it.

jcoyne
jcoyne previously requested changes Jan 9, 2018
@@ -1,7 +1,7 @@
<ul class="nav nav-tabs" id="my_nav" role="navigation">
<span class="sr-only">You are currently listing your works. You have <%= @response.docs.count %> <%= 'work'.pluralize(@response.docs.count)%> </span>
<li<%= ' class="active"'.html_safe if current_page?(hyrax.dashboard_works_path(locale: nil)) %>>
<%= link_to t("hyrax.dashboard.#{current_ability.admin? ? 'all' : 'managed'}.works"), hyrax.dashboard_works_path %>
<%= link_to t("hyrax.dashboard.#{current_ability.admin? ? 'all' : 'managed'}.works"), hyrax.dashboard_works_path, data: { turbolinks: false } %>
Copy link
Member

Choose a reason for hiding this comment

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

Why are you doing turbolinks: false here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This relates to issue #1191. Without it, you end up with an ActionController::InvalidAuthenticityToken error.

<div class="batch-toggle">
<% session[:batch_edit_state] = "on" %>
<div class="button_to-inline">
<%= button_to "Edit Selected", hyrax.edit_batch_edits_path, method: :get, class: "btn btn-update btn-primary hidden submits-batches", data: { behavior: 'batch-edit' }, id: 'batch-edit' %>
Copy link
Member

Choose a reason for hiding this comment

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

Can you add this string to i18n? and on line 10?

end

it "is successful" do
put :update, params: { update_type: "delete_all" }
expect(response).to redirect_to(dashboard_path(locale: 'en'))
expect { GenericWork.find(one.id) }.to raise_error(Ldp::Gone)
expect { GenericWork.find(two.id) }.to raise_error(Ldp::Gone)
expect(GenericWork.find(three.id).id).to eq(three.id)
Copy link
Member

Choose a reason for hiding this comment

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

This should be expect(GenericWork).to exist(three.id) (or alternately expect(GenericWork.exists?(three.id).to be true)

@@ -61,13 +70,15 @@
expect(response).to be_redirect
expect(GenericWork.find(one.id).subject).to eq ["zzz"]
expect(GenericWork.find(two.id).subject).to eq ["zzz"]
expect(GenericWork.find(three.id).subject).not_to eq ["zzz"]
Copy link
Member

Choose a reason for hiding this comment

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

Negative assertions are not nearly as specific as positive assertions. Is there a reason you can't do expect(GenericWork.find(three.id).subject).to eq ["whavever value it initially had"]?

end

it "updates permissions" do
put :update, params: { update_type: "update", visibility: "authenticated" }
expect(response).to be_redirect
expect(GenericWork.find(one.id).visibility).to eq "authenticated"
expect(GenericWork.find(two.id).visibility).to eq "authenticated"
expect(GenericWork.find(three.id).visibility).not_to eq "authenticated"
Copy link
Member

Choose a reason for hiding this comment

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

Can we assert what we expect it to be? restricted?

@@ -74,7 +74,7 @@

it "adds docs to the collection and adds the collection id to the documents in the collection" do
post :create, params: {
batch_document_ids: [asset1.id],
batch_document_ids: [asset1.id, unowned_asset.id],
Copy link
Member

Choose a reason for hiding this comment

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

Why are you doing this change? It seems odd that no assertions are changing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to verify that only works the user has access to are added to the collection. This passes an ID of an unowned work with the request but that shouldn't change the original expectation that only asset1 is added to the collection.

@@ -35,20 +37,27 @@
let!(:two) do
create(:generic_work, creator: ["Fred"], title: ["abc"], language: ['en'], user: user)
end

let!(:three) do
create(:generic_work, creator: ["Fred"], title: ["abc"], language: ['en'])
Copy link
Member

Choose a reason for hiding this comment

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

On line 13 above you are using create(:work,...) can we stick with that for consistency?

@@ -1,4 +1,8 @@
<tr id="document_<%= document.id %>">
<td>
<label for="batch_document_<%= document.id %>" class="sr-only"><%=t("hyrax.dashboard.my.sr.batch_checkbox")%></label>
<%= render 'hyrax/batch_select/add_button', document: document %>&nbsp;
Copy link
Member

Choose a reason for hiding this comment

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

What's the point of the &nbsp here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a copy and paste. It appears the &nbsp; is used to manipulate the vertical position of the checkbox inside the table cell (without it the checkbox renders below verticle center).

elrayle
elrayle previously approved these changes Jan 11, 2018
Copy link
Contributor

@elrayle elrayle left a comment

Choose a reason for hiding this comment

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

This looks good to me. @jcoyne Are you questions answered? This looks ready to merge to me.

@elrayle elrayle dismissed stale reviews from jcoyne and themself January 11, 2018 01:34

Basic changes look good, but there are test failures.

elrayle
elrayle previously approved these changes Jan 12, 2018
@elrayle elrayle merged commit e5618c0 into samvera:collections-sprint Jan 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Collection impacts the Collection part of PCDM Model
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants