Skip to content

Commit

Permalink
Merge pull request #1468 from pulibrary/i1328_add_restriction_note
Browse files Browse the repository at this point in the history
notifies user of restricted items in request cart
  • Loading branch information
tpendragon authored Dec 11, 2024
2 parents fd96dc0 + 4adfaae commit 7114447
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
8 changes: 7 additions & 1 deletion app/javascript/components/AddToCartButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export default {
type: Object,
default: () => { {} },
required: false,
},
restricted: {
type: Boolean,
default: false,
required: false,
}
},
methods: {
Expand All @@ -47,7 +52,8 @@ export default {
title: this.title,
containers: this.containers,
location: this.location,
formParams: this.formParams
formParams: this.formParams,
restricted: this.restricted
}
},
items: {
Expand Down
8 changes: 7 additions & 1 deletion app/javascript/components/RequestCart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@
</td>
</tr>

<tr v-if="item.location && item.location.label" class="request__location">
<tr v-if="item.restricted" class="request__location">
<td colspan="4">
Item may need to be reviewed by staff for access.
</td>
</tr>

<tr v-else-if="item.location && item.location.label" class="request__location">
<td colspan="4">
<geo-icon></geo-icon>
View this item at the <template v-if="item.location.url"><a
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/test/addToCartButton.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ describe('AddToCartButton.vue', () => {
})
const button = getByRole('button')
await fireEvent.click(button)
expect(addItemToCart).toHaveBeenCalledWith(expect.anything(), { callnumber: 'AC101', containers: '', formParams: undefined, title: 'Title' })
expect(addItemToCart).toHaveBeenCalledWith(expect.anything(), { restricted: false, callnumber: 'AC101', containers: '', formParams: undefined, title: 'Title' })
})
})
4 changes: 4 additions & 0 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ def member_of
]
end

def open?
fetch("access_ssi", nil) == "open"
end

def restricted?
fetch("access_ssi", nil) == "restricted"
end
Expand Down
1 change: 1 addition & 0 deletions app/views/catalog/_show_tab_panes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<% end %>
:location="<%= JSON.generate(@document.aeon_request.location_attributes) %>"
:form-params="<%= JSON.generate(@document.aeon_request.form_attributes) %>"
:restricted="<%= !@document.open? %>"
>
<lux-icon-base icon-name="add-to-cart" width="20" height="20">
<add-to-cart-icon></add-to-cart-icon>
Expand Down
7 changes: 7 additions & 0 deletions spec/features/catalog_view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
expect(page).to have_selector "td", text: /MC148_c00002/
expect(page).to have_selector "td", text: /Box 1/
expect(page).to have_selector "button[type='submit']", text: /Request 1 Item/
expect(page).to have_selector ".request__location", text: /View this item at the/

# Click the remove item button
find("#item-MC148_c00002 > td > button").click
Expand All @@ -84,6 +85,12 @@
# Check that it can be closed
expect(page).to have_selector "button.denied-button"
end
visit "/catalog/AC136_c2889"
find("button.denied-button").click
find(".add-to-cart-block").click
within(".request-cart") do
expect(page).to have_selector ".request__location", text: /Item may need to be reviewed by staff for access/
end
end
end
context "with a component show page" do
Expand Down

0 comments on commit 7114447

Please sign in to comment.