Skip to content

Commit

Permalink
document: holdings should be grouped by libraries
Browse files Browse the repository at this point in the history
The layout of the book type no longer shows the holdings structure.
The buttons have been aligned on the vertical after the data.

* closes rero#1399

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Dec 9, 2020
1 parent 94e396a commit 0ffb45b
Show file tree
Hide file tree
Showing 9 changed files with 256 additions and 41 deletions.
10 changes: 10 additions & 0 deletions rero_ils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,7 @@ def _(x):
'collections',
'contributions',
'documents',
'holdings',
'items',
'item_types',
'ill_requests',
Expand Down Expand Up @@ -1954,6 +1955,15 @@ def _(x):
RECORDS_REST_DEFAULT_SORT['circ_policies'] = dict(
query='bestmatch', noquery='name')

# ------ HOLDINGS SORT
RECORDS_REST_SORT_OPTIONS['holdings']['library_location'] = dict(
fields=['library.pid', 'location.pid'],
title='Holdings library location sort',
default_order='asc'
)
RECORDS_REST_DEFAULT_SORT['holdings'] = dict(
query='bestmatch', noquery='library_location')

# ------ ITEM TYPES SORT
RECORDS_REST_SORT_OPTIONS['item_types']['name'] = dict(
fields=['item_type_name'], title='Item type name',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{# -*- coding: utf-8 -*-

RERO ILS
Copyright (C) 2020 RERO

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

#}
{%- if current_user.is_anonymous %}
<a
class="btn btn-primary btn-sm"
href="{{ url_for_security('login') + "
?next=" + request.path }}"
>
<i class="fa fa-sign-in"></i> {{ _('Login (to see request options)') }}
</a>
{%- endif %}
63 changes: 29 additions & 34 deletions rero_ils/modules/documents/templates/rero_ils/_documents_get.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#}
{% from 'rero_ils/macros/macro.html' import dl, dl_dict, dl_list, div_json %}


{% set accesses = record|get_accesses %}
{% if accesses|length > 0 or holdings %}
<!-- ACCESS -->
Expand Down Expand Up @@ -68,11 +67,8 @@
<!-- Holdings -->
{%- if holdings %}
<!-- User login -->
{%- if current_user.is_anonymous %}
<a class="btn btn-primary btn-sm" href="{{ url_for_security('login') + "?next=" + request.path }}">
<i class="fa fa-sign-in"></i> {{ _('Login (to see request options)') }}
</a>
{%- endif %}
{% include 'rero_ils/_anonymous_button.html' %}

{%- for holding in holdings %}
{% set items = holding.get_items | sort(attribute='enumerationAndChronology', reverse=True) %}
{% set number_items = holding.get_items_count_by_holding_pid %}
Expand Down Expand Up @@ -174,48 +170,34 @@
<!-- display items -->
{%- if number_items > 0 %}
{%- for item in items %}
<div id="{{ item.barcode }}-detail" class="row item-row">
<dt class="offset-1 col-lg-2 col-sm-3">{{ _('Call number') }}</dt>
<dd class="col-lg-3 col-sm-3">{{ item | format_record_call_number }}</dd>
<dd class="col-lg-6 col-sm-5">
<i class="fa fa-circle text-{{ 'success' if item.available else 'danger' }}"></i>
{{ item|item_availability_text }}
</dd>
{%- set collections = item.pid|in_collection %}
<div id="{{ item.barcode }}-detail" class="row item-row mt-2">
{%- if collections|length > 0 %}
<dt class="offset-1 col-lg-2 col-sm-3">{{ _('Temporary location') }}</dt>
<dd class="col-lg-9 col-sm-8">
{%- for collection in collections %}
{%- if collection.published %}
<a href="{{ url_for('invenio_records_ui.coll', viewcode=viewcode, pid_value=collection.pid) }}">
{{ collection.title }}{{ '' if loop.last else '; ' }}
</a>
{%- endif %}
{%- endfor %}
</dd>
<dt class="offset-1 col-lg-2 col-sm-3">{{ _('Call number') }}</dt>
<dd class="col-lg-9 col-sm-3">{{ item | format_record_call_number }}</dd>
{%- endif %}

{%- if item.get('enumerationAndChronology') %}
<dt class="offset-1 col-lg-2 col-sm-3">{{ _('Unit') }}</dt>
<dd class="col-lg-9 col-sm-8">{{ item.get('enumerationAndChronology') }}</dd>
{%- endif %}

<dt class="offset-1 col-lg-2 col-sm-3">{{ _('Barcode') }}</dt>
<dd class="col-lg-9 col-sm-8">{{ item.barcode }}</dd>

{%- set public_notes = item|get_public_notes %}
{%- for note in public_notes %}
<dt class="offset-1 col-lg-2 col-sm-3">{{ _(note.get('type')) }}</dt>
<dd class="col-lg-9 col-sm-8">{{ note.get('content') | nl2br | safe }}</dd>
{%- endfor %}

<!-- action button : Should be at the end to be render above and be clickabke -->
{%- if item|item_and_patron_in_same_organisation %}
{%- set can_request, reasons = item|can_request %}
{%- set locations = item|item_library_pickup_locations %}
{%- if can_request and locations %}
<div class="action-buttons">
<a href="#" type="button" class="btn btn-primary btn-sm" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false" id="{{ item.barcode }}-dropdownMenu">
{{ _('Request') }}
<i class="fa fa-caret-down fa-fw"></i>
{%- set collections = item.pid|in_collection %}
{%- if collections|length > 0 %}
<dt class="offset-1 col-lg-2 col-sm-3">{{ _('Temporary location') }}</dt>
<dd class="col-lg-9 col-sm-8">
{%- for collection in collections %}
{%- if collection.published %}
<a href="{{ url_for('invenio_records_ui.coll', viewcode=viewcode, pid_value=collection.pid) }}">
{{ collection.title }}{{ '' if loop.last else '; ' }}
</a>
<!-- TODO: Style the dropdown header -->
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenu">
Expand All @@ -239,7 +221,20 @@ <h6 class="dropdown-header">{{ _('Select a Pickup Location') }}</h6>
</span>
</div>
{%- endif %}
{%- endif %}
{%- endfor %}
</dd>
{%- endif %}

<dt class="offset-1 col-lg-2 col-sm-3">{{ _('Status') }}</dt>
<dd class="col-lg-9 col-sm-8">
<i class="fa fa-circle text-{{ 'success' if item.available else 'danger' }}"></i>
{{ item|item_availability_text }}
</dd>

{% with class='offset-1' %}
{% include 'rero_ils/_request_button.html' %}
{% endwith %}
</div>
{%- endfor %}
{%- endif %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{# -*- coding: utf-8 -*-

RERO ILS
Copyright (C) 2020 RERO

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

#}
<!-- Holdings -->
{%- if holdings %}

<!-- User login -->
{% include 'rero_ils/_anonymous_button.html' %}

<div class="container">
{%- for holding in holdings %}
{% set items = holding.get_items | sort(attribute='enumerationAndChronology', reverse=True) %}
{%- for item in items %}
<div id="{{ item.barcode }}-detail" class="row item-row mt-2">
<dt class="col-lg-2 col-sm-3">{{ _('Location') }}</dt>
<dd class="col-lg-10 col-sm-9">
{{ holding|holding_location }}
</dd>

{%- if collections|length > 0 %}
<dt class="col-lg-2 col-sm-3">{{ _('Call number') }}</dt>
<dd class="col-lg-10 col-sm-9">{{ item | format_record_call_number }}</dd>
{%- endif %}

{%- if item.get('enumerationAndChronology') %}
<dt class="col-lg-2 col-sm-3">{{ _('Unit') }}</dt>
<dd class="col-lg-10 col-sm-9">
{{ item.get('enumerationAndChronology') }}
</dd>
{%- endif %}

<dt class="col-lg-2 col-sm-3">{{ _('Barcode') }}</dt>
<dd class="col-lg-10 col-sm-9">{{ item.barcode }}</dd>

{%- set public_notes = item|get_public_notes %} {%- for note in public_notes
%}
<dt class="col-lg-2 col-sm-3">{{ _(note.get('type')) }}</dt>
<dd class="col-lg-10 col-sm-9">{{ note.get('content') | nl2br | safe }}</dd>
{%- endfor %} {%- set collections = item.pid|in_collection %} {%- if
collections|length > 0 %}
<dt class="col-lg-2 col-sm-3">{{ _('Temporary location') }}</dt>
<dd class="col-lg-10 col-sm-9">
{%- for collection in collections %}
{%- if collection.published %}
<a
href="{{ url_for('invenio_records_ui.coll', viewcode=viewcode, pid_value=collection.pid) }}"
>
{{ collection.title }}{{ '' if loop.last else '; ' }}
</a>
{%- endif %}
{%- endfor %}
</dd>
{%- endif %}

<dt class="col-lg-2 col-sm-3">{{ _('Status') }}</dt>
<dd class="col-lg-10 col-sm-9">
<i
class="fa fa-circle text-{{ 'success' if item.available else 'danger' }}"
></i>
{{ item|item_availability_text }}
</dd>

{% include('rero_ils/_request_button.html') %}
</div>
{%- endfor %}
{%- endfor %}
</div>
{%- endif %}
71 changes: 71 additions & 0 deletions rero_ils/modules/documents/templates/rero_ils/_request_button.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{# -*- coding: utf-8 -*-

RERO ILS
Copyright (C) 2020 RERO

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

#}
<!-- action button : Should be at the end to be render above and be clickabke -->
{%- if item|item_and_patron_in_same_organisation %}
{%- set can_request, reasons = item|can_request %}
{%- set locations = item|item_library_pickup_locations %}
{%- if can_request and locations %}
<dd class="{% if class %}{{ class }} {% endif %}col-lg-12 col-sm-12 mt-2">
<a
href="#"
type="button"
class="btn btn-primary btn-mini"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
id="{{ item.barcode }}-dropdownMenu"
>
{{ _('Request') }}
<i class="fa fa-caret-down fa-fw"></i>
</a>
<!-- TODO: Style the dropdown header -->
<div
class="dropdown-menu dropdown-menu-left"
aria-labelledby="dropdownMenu"
>
<h6 class="dropdown-header">{{ _('Select a Pickup Location') }}</h6>
<div class="dropdown-divider"></div>
{% for location in locations %}
<a
class="dropdown-item"
id="{{ location.code }}"
href="{{ url_for('item.patron_request', viewcode=viewcode, item_pid=item.pid, pickup_location_pid=location.pid)}}"
>
{{ location.pickup_name }}
</a>
{% endfor %}
</div>
</dd>
{%- elif reasons %}
<dd class="col-lg-12 col-sm-12 mt-2">
<span
class="d-inline-block"
tabindex="0"
data-toggle="tooltip"
data-html="true"
title="{{ reasons | join('<br/>') }}"
>
<button type="submit" class="btn btn-primary btn-mini" disabled>
{{ _('Request') }}
<i class="fa fa-caret-down fa-fw"></i>
</button>
</span>
</dd>
{%- endif %}
{%- endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ <h3>
</header>
<article class="tab-content">
<section class="tab-pane show active p-4" id="documents-get" role="tabpanel" aria-labelledby="documents-get-tab">
{% include('rero_ils/_documents_get.html') %}
{%- if record.type == 'book' %}
{% include('rero_ils/_documents_get_book.html') %}
{%- else %}
{% include('rero_ils/_documents_get.html') %}
{%- endif %}
</section>
<section class="tab-pane row" id="documents-description" role="tabpanel" aria-labelledby="documents-description-tab">
{% include('rero_ils/_documents_description.html') %}
Expand Down
16 changes: 13 additions & 3 deletions rero_ils/modules/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,24 @@ def doc_item_view_method(pid, record, template=None, **kwargs):
current_app._get_current_object(), pid=pid, record=record)

viewcode = kwargs['viewcode']
organisation = Organisation.get_record_by_viewcode(viewcode)

record['available'] = record.is_available(viewcode)

# TODO: later Refactoring this part
# Use ES to order holdings records
# Pass directly the ES holdings to the template
# and create some pipe to process record
from ..holdings.api import HoldingsSearch
results = HoldingsSearch()\
.filter('term', document__pid=pid.pid_value)\
.filter('term', organisation__pid=organisation.pid)\
.sort({'library_location': {"order": "asc"}})\
.source('pid').scan()

holdings = [
Holding.get_record_by_pid(holding_pid).replace_refs()
for holding_pid in Holding.get_holdings_by_document_by_view_code(
document_pid=pid.pid_value, viewcode=viewcode
)
for holding_pid in [r.pid for r in results]
]

return render_template(
Expand Down
6 changes: 3 additions & 3 deletions rero_ils/theme/assets/scss/rero_ils/documents/detailed.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
content: "";
border-top: 1px solid #CCC;
height: 1px;
width:80%;
left:10%;
top:0;
width: 96%;
left: 2%;
top: 0;
}
}
dd {
Expand Down
15 changes: 15 additions & 0 deletions rero_ils/theme/assets/scss/rero_ils/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,18 @@ div.tooltip div.tooltip-inner{
background-color: $red;
color: white;
}


/*
*********************************
BUTTON
********************************
*/
.btn-mini {
padding: .25rem .35rem .25rem .45rem;
font-size: .875rem;
line-height: 1.3;
border-radius: .2rem;
}

0 comments on commit 0ffb45b

Please sign in to comment.