Skip to content

Commit

Permalink
backoffice: Item: Add identifier to Item schema
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshamarora1 committed Apr 17, 2024
1 parent 164742a commit a7984ed
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/lib/config/defaultConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,9 @@ export const RECORDS_CONFIG = {
eitem: { source: 'eitem_sources' },
item: {
mediums: 'item_medium',
identifier: {
scheme: 'identifier_scheme',
},
},
series: {
identifier: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { BackOfficeRoutes } from '@routes/urls';
import _get from 'lodash/get';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import Overridable from 'react-overridable';
import { Link } from 'react-router-dom';
import {
Divider,
Expand Down Expand Up @@ -180,15 +181,20 @@ export default class ItemCirculation extends Component {
</Header>
<Segment attached className="bo-metadata-segment" id="circulation">
<Grid columns={5} verticalAlign="middle">
<Grid.Column width={5}>
<Header size="small">
<Icon name="map pin" />
<Header.Content>
{metadata.shelf}
<Header.Subheader>shelf</Header.Subheader>
</Header.Content>
</Header>
</Grid.Column>
<Overridable
id="ItemCirculation.backoffice.shelf"
metadata={metadata}
>
<Grid.Column width={5}>
<Header size="small">
<Icon name="map pin" />
<Header.Content>
{metadata.shelf}
<Header.Subheader>shelf</Header.Subheader>
</Header.Content>
</Header>
</Grid.Column>
</Overridable>
<Grid.Column width={1}>
<Icon size="large" name="long arrow alternate right" />
</Grid.Column>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import _isEmpty from 'lodash/isEmpty';
import capitalize from 'lodash/capitalize';
import { formatPrice } from '@api/utils';
import { MetadataTable } from '@components/backoffice/MetadataTable';
import { getDisplayVal } from '@config';
Expand Down Expand Up @@ -99,17 +101,38 @@ export default class ItemMetadata extends Component {
];

itemDetails.metadata.legacy_id &&
rightMetadata.push({
leftMetadata.push({
name: 'Legacy ID',
value: itemDetails.metadata.legacy_id,
});

itemDetails.metadata.legacy_library_id &&
rightMetadata.push({
leftMetadata.push({
name: 'Legacy Library ID',
value: itemDetails.metadata.legacy_library_id,
});

const itemIdentifiers = itemDetails.metadata.identifiers;
if (!_isEmpty(itemIdentifiers)) {
rightMetadata.push({
name: 'Identifiers',
value: (
<List bulleted>
{itemIdentifiers.map((entry) => (
<List.Item key={entry.value}>
<List.Content>
{entry.value +
' (' +
capitalize(entry.scheme).replace('_', ' ') +
')'}
</List.Content>
</List.Item>
))}
</List>
),
});
}

return (
<>
<Header as="h3" attached="top">
Expand Down
19 changes: 19 additions & 0 deletions src/lib/pages/backoffice/Item/ItemEditor/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
34 changes: 34 additions & 0 deletions src/lib/pages/backoffice/Item/ItemEditor/uiSchema.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
import { invenioConfig } from '@config';
import _merge from 'lodash/merge';

const arrayUiOptions = {
'ui:options': {
orderable: false,
// no wrapItem to keep everything more compact
},
};

const identifierUiSchema = (schemeVocabulary) => ({
...arrayUiOptions,
items: {
scheme: {
'ui:widget': 'vocabulary',
'ui:options': {
vocabularyType: schemeVocabulary,
},
},
'custom:grid': [
{
scheme: 8,
value: 8,
},
],
},
});

export const uiSchema = (title) => {
const _uiSchema = {
acquisition_pid: {
Expand Down Expand Up @@ -34,6 +59,9 @@ export const uiSchema = (title) => {
],
},
},
identifiers: identifierUiSchema(
invenioConfig.VOCABULARIES.item.identifier.scheme
),
price: {
currency: {
'ui:widget': 'vocabulary',
Expand Down Expand Up @@ -81,6 +109,12 @@ export const uiSchema = (title) => {
acquisition_pid: 6,
price: 10,
},
{
'custom:divider': 16,
},
{
identifiers: 10,
},
],
'custom:root': {
'custom:formTitle': title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class DocumentCirculation extends Component {
showTab={showTab}
documentDetails={documentDetails}
/>
<Header as="h3" content="Request loan" />
<Header as="h3" className="mt-10" content="Request loan" />
{hasNeither
? this.renderRequestable()
: userHasPendingRequest
Expand Down

0 comments on commit a7984ed

Please sign in to comment.