Skip to content

Commit

Permalink
Hide queue button when there is an available kursbok (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
xlpero authored and xljoha committed Jun 19, 2019
1 parent 8571e61 commit 4c35002
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
7 changes: 6 additions & 1 deletion app/models/biblio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def can_be_queued
return has_items_available_for_queue && !has_item_level_queue
end

def has_available_kursbok
return @items.any? {|item| item.is_availible && item.item_type_kursbok?}
end


def has_item_level_queue
# Biblios wrongly cataloged as monographs should be considered as serials if subscriptions exist
return true if !@subscriptiongroups.empty?
Expand All @@ -48,7 +53,7 @@ def self.queue_level record_type
end

def as_json options = {}
super.merge(can_be_queued: can_be_queued, has_item_level_queue: has_item_level_queue)
super.merge(can_be_queued: can_be_queued, has_item_level_queue: has_item_level_queue, has_available_kursbok: has_available_kursbok)
end

def initialize id, bib_xml, items_data, reserves_data, subscriptions
Expand Down
1 change: 1 addition & 0 deletions frontend/app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default {
"header": "Your request",
"items": {
"items-are-available": "There are available items for you to request",
"kursbok-is-available": "There are available items that you can collect from the shelf",
"next-button": "Continue",
"select-button": "Select",
"order-subscription-button": "Request",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/locales/sv/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default {
"header": "Din beställning",
"items": {
"items-are-available": "Det finns tillgängliga exemplar som du kan beställa",
"kursbok-is-available": "Det finns tillgängliga exemplar som du kan hämta själv från hyllan",
"next-button": "Fortsätt",
"select-button": "Välj",
"order-subscription-button": "Beställ",
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/models/biblio.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export default DS.Model.extend({
items: DS.hasMany('item'),
subscriptiongroups: DS.hasMany('subscriptiongroup'),
hasEnum: DS.attr('boolean'),
biblioCallNumber: DS.attr('string')
biblioCallNumber: DS.attr('string'),
hasAvailableKursbok: DS.attr('boolean')
});
14 changes: 10 additions & 4 deletions frontend/app/templates/request/order/items.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,20 @@
{{#if hasItemAvailableForOrder}}
<div class="panel-body center">
<span>{{t "request.order.items.items-are-available"}}</span>
</div>
{{else }}
</div>
{{else}}
{{#if request.model.biblio.hasAvailableKursbok}}
<div class="panel-body center">
<span>{{t "request.order.items.kursbok-is-available"}}</span>
</div>
{{else}}
<div class="panel panel-default">
<div class="panel-body center">
<strong>{{request.model.biblio.noInQueue}} {{t "request.order.items.number-of-people-in-queue"}}</strong>
<button class="btn btn-primary btn-space-left" {{action 'setItemToOrder' null true}}>{{t "request.order.items.queue-up"}}</button>
</div>
</div>
</div>
</div>
{{/if}}
{{/if}}
</div>
</div>
Expand Down

0 comments on commit 4c35002

Please sign in to comment.