Skip to content

Commit

Permalink
documents: group holdings 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 14, 2020
1 parent a22543e commit 0287cc3
Show file tree
Hide file tree
Showing 11 changed files with 309 additions and 98 deletions.
10 changes: 10 additions & 0 deletions rero_ils/config.py
Expand Up @@ -1897,6 +1897,7 @@ def _(x):
'collections',
'contributions',
'documents',
'holdings',
'items',
'item_types',
'ill_requests',
Expand Down Expand Up @@ -1961,6 +1962,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
@@ -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> {{ _('Log in (to see request options)') }}
</a>
{%- endif %}
@@ -0,0 +1,60 @@
{# -*- coding: utf-8 -*-

RERO ILS
Copyright (C) 2019 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 accesses|length > 0 %}
<div class="card mb-2">
<!-- Card header -->
<div id="online_access" class="card-header p-2">
<div class="row">
<div class="col-1">
<a class="collapse-link" data-toggle="collapse" href="#collapse-access" aria-expanded="false">
<i class="fa fa-caret-down fa-lg"></i>
</a>
</div>
<div class="col-10">
{{ _("Online") }}
</div>
</div>
</div>
<!-- Card body -->
<div id="collapse-access" class="collapse show" role="tabpanel">
<div class="card-body p-2">
{% for access in accesses %}
<div class="row my-2">
<div class="col-12">
<div class="row">
<div class="col-sm-1">
&nbsp;
</div>
<div class="col-sm-2">
{{ access.type }}
</div>
<div class="col-sm-9">
<a class="rero-ils-external-link" href={{ access.url }}>{{ access.content }}</a>
{% if access.public_note %}
({{ access.public_note }})
{% endif %}
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endif %}
100 changes: 17 additions & 83 deletions rero_ils/modules/documents/templates/rero_ils/_documents_get.html
Expand Up @@ -21,49 +21,8 @@

{% set accesses = record|get_accesses %}
{% if accesses|length > 0 or holdings %}
<!-- ACCESS -->
{% if accesses|length > 0 %}
<div class="card mb-2">
<!-- Card header -->
<div id="online_access" class="card-header p-2">
<div class="row">
<div class="col-1">
<a class="collapse-link" data-toggle="collapse" href="#collapse-access" aria-expanded="false">
<i class="fa fa-caret-down fa-lg"></i>
</a>
</div>
<div class="col-10">
{{ _("Online") }}
</div>
</div>
</div>
<!-- Card body -->
<div id="collapse-access" class="collapse show" role="tabpanel">
<div class="card-body p-2">
{% for access in accesses %}
<div class="row my-2">
<div class="col-12">
<div class="row">
<div class="col-sm-1">
&nbsp;
</div>
<div class="col-sm-2">
{{ access.type }}
</div>
<div class="col-sm-9">
<a class="rero-ils-external-link" href={{ access.url }}>{{ access.content }}</a>
{% if access.public_note %}
({{ access.public_note }})
{% endif %}
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endif %}
<!-- ONLINE -->
{% include('rero_ils/_document_online.html') %}

<!-- Holdings -->
{%- if holdings %}
Expand Down Expand Up @@ -174,13 +133,12 @@
<!-- display items -->
{%- if number_items > 0 %}
{%- for item in items %}
<div id="{{ item.barcode }}-detail" class="row item-row">
<div id="{{ item.barcode }}-detail" class="row item-row mt-2">
{%- set call_number = item | format_record_call_number -%}
{%- if call_number %}
<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>
<dd class="col-lg-10 col-sm-9">{{ item | format_record_call_number }}</dd>
{%- endif %}
{%- set collections = item.pid|in_collection %}
{%- if collections|length > 0 %}
<dt class="offset-1 col-lg-2 col-sm-3">{{ _('Temporary location') }}</dt>
Expand All @@ -206,40 +164,16 @@
<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>
</a>
<!-- TODO: Style the dropdown header -->
<div class="dropdown-menu dropdown-menu-right" 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>
</div>
{%- elif reasons %}
<div class="action-buttons">
<span class="d-inline-block mt-1" tabindex="0" data-toggle="tooltip" data-html="true" title="{{ reasons | join('<br/>') }}">
<button type="submit" class="btn btn-primary" disabled>
{{ _('Request') }}
</button>
</span>
</div>
{%- endif %}
{%- 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
@@ -0,0 +1,84 @@
{# -*- 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 %}
70 changes: 70 additions & 0 deletions rero_ils/modules/documents/templates/rero_ils/_request_button.html
@@ -0,0 +1,70 @@
{# -*- 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 rendered above and be clickable -->
{%- 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>
<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 %}

0 comments on commit 0287cc3

Please sign in to comment.