From 132e7f78124c9ab490a7bc4a88a793f0350a54da Mon Sep 17 00:00:00 2001 From: Saksham Arora Date: Thu, 4 Apr 2024 14:09:04 +0200 Subject: [PATCH] pages: Display idnetifiers of Item in frontsite and backoffice --- .../ItemDetails/ItemMetadata/ItemMetadata.js | 15 +++++++++++++ .../backoffice/Item/ItemEditor/schema.js | 19 ++++++++++++++++ .../backoffice/Item/ItemEditor/uiSchema.js | 22 +++++++++++++++++++ .../DocumentItems/DocumentItem.js | 1 + .../DocumentItems/DocumentItemBody.js | 19 ++++++++++++---- 5 files changed, 72 insertions(+), 4 deletions(-) diff --git a/src/lib/pages/backoffice/Item/ItemDetails/ItemMetadata/ItemMetadata.js b/src/lib/pages/backoffice/Item/ItemDetails/ItemMetadata/ItemMetadata.js index 53b57a164..225fee099 100644 --- a/src/lib/pages/backoffice/Item/ItemDetails/ItemMetadata/ItemMetadata.js +++ b/src/lib/pages/backoffice/Item/ItemDetails/ItemMetadata/ItemMetadata.js @@ -56,6 +56,21 @@ export default class ItemMetadata extends Component { ), }, + { + name: 'Identifiers', + value: ( + + {itemDetails.metadata.identifiers + ? itemDetails.metadata.identifiers.map((identifier) => ( + + {identifier.value} + {` (${identifier.scheme})`} + + )) + : '-'} + + ), + }, ]; const rightMetadata = [ diff --git a/src/lib/pages/backoffice/Item/ItemEditor/schema.js b/src/lib/pages/backoffice/Item/ItemEditor/schema.js index e13bf5448..7a6fc5bc1 100644 --- a/src/lib/pages/backoffice/Item/ItemEditor/schema.js +++ b/src/lib/pages/backoffice/Item/ItemEditor/schema.js @@ -94,6 +94,25 @@ export const schema = () => { type: 'string', title: 'Shelf', }, + identifiers: { + items: { + properties: { + scheme: { + title: 'Scheme name', + type: 'string', + }, + value: { + title: 'Value', + type: 'string', + }, + }, + required: ['scheme', 'value'], + title: 'Identifier', + type: 'object', + }, + title: 'Identifiers', + type: 'array', + }, status: { enum: invenioConfig.ITEMS.statuses.map((status) => status.value), enumNames: invenioConfig.ITEMS.statuses.map((status) => status.text), diff --git a/src/lib/pages/backoffice/Item/ItemEditor/uiSchema.js b/src/lib/pages/backoffice/Item/ItemEditor/uiSchema.js index f16012a45..9aa32cb46 100644 --- a/src/lib/pages/backoffice/Item/ItemEditor/uiSchema.js +++ b/src/lib/pages/backoffice/Item/ItemEditor/uiSchema.js @@ -34,6 +34,22 @@ export const uiSchema = (title) => { ], }, }, + identifiers: { + 'ui:options': { + orderable: false, + semantic: { + wrapItem: true, + }, + }, + items: { + 'custom:grid': [ + { + scheme: 10, + value: 6, + }, + ], + }, + }, price: { currency: { 'ui:widget': 'vocabulary', @@ -81,6 +97,12 @@ export const uiSchema = (title) => { acquisition_pid: 6, price: 10, }, + { + 'custom:divider': 16, + }, + { + identifiers: 10, + }, ], 'custom:root': { 'custom:formTitle': title, diff --git a/src/lib/pages/frontsite/Documents/DocumentDetails/DocumentItems/DocumentItem.js b/src/lib/pages/frontsite/Documents/DocumentDetails/DocumentItems/DocumentItem.js index e7ed0fc60..a18eb1909 100644 --- a/src/lib/pages/frontsite/Documents/DocumentDetails/DocumentItems/DocumentItem.js +++ b/src/lib/pages/frontsite/Documents/DocumentDetails/DocumentItems/DocumentItem.js @@ -54,6 +54,7 @@ class DocumentItem extends Component { Barcode Shelf + Call Number Status Medium Loan restriction diff --git a/src/lib/pages/frontsite/Documents/DocumentDetails/DocumentItems/DocumentItemBody.js b/src/lib/pages/frontsite/Documents/DocumentDetails/DocumentItems/DocumentItemBody.js index 28fa59b52..00d3c3eaf 100644 --- a/src/lib/pages/frontsite/Documents/DocumentDetails/DocumentItems/DocumentItemBody.js +++ b/src/lib/pages/frontsite/Documents/DocumentDetails/DocumentItems/DocumentItemBody.js @@ -1,14 +1,11 @@ import React, { Component } from 'react'; +import _get from 'lodash/get'; import { PropTypes } from 'prop-types'; import { Table } from 'semantic-ui-react'; import { Media } from '@components/Media'; import { getDisplayVal, invenioConfig } from '@config'; export default class DocumentItemBody extends Component { - constructor(props) { - super(props); - } - itemStatus = (item) => ({ canCirculate: () => invenioConfig.ITEMS.canCirculateStatuses.includes(item.status), @@ -30,6 +27,17 @@ export default class DocumentItemBody extends Component { return getDisplayVal('ITEMS.statuses', item.status); }; + callNumber = (items) => { + const identifiers = _get(items, 'identifiers', []); + if (identifiers === null) { + return '-'; + } + const callNumber = identifiers.find( + (identifier) => identifier.scheme.toLowerCase() === 'call number' + ); + return callNumber ? callNumber.value : '-'; + }; + render() { const { items } = this.props; @@ -60,6 +68,9 @@ export default class DocumentItemBody extends Component { + + {this.callNumber(item)} + {this.statusLabel(item)} {getDisplayVal('ITEMS.mediums', item.medium)}