diff --git a/src/lib/index.js b/src/lib/index.js index 0878562c3..aa4abe598 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -51,3 +51,4 @@ export { SectionInstallation } from '@pages/frontsite/Home/Sections/SectionInsta export { PaymentInformation } from '@components/backoffice/PaymentInformation'; export { OrderLine } from '@pages/backoffice/Acquisition/Order/OrderDetails/OrderLines'; export { formatPrice } from '@api/utils'; +export { DocumentItems } from '@pages/backoffice/Document/DocumentDetails/DocumentItems'; diff --git a/src/lib/pages/backoffice/Document/DocumentDetails/DocumentItems/DocumentItems.js b/src/lib/pages/backoffice/Document/DocumentDetails/DocumentItems/DocumentItems.js index b9a9ccde5..f9cd559df 100644 --- a/src/lib/pages/backoffice/Document/DocumentDetails/DocumentItems/DocumentItems.js +++ b/src/lib/pages/backoffice/Document/DocumentDetails/DocumentItems/DocumentItems.js @@ -8,8 +8,9 @@ import { itemApi } from '@api/items'; import { BackOfficeRoutes } from '@routes/urls'; import { SeeAllButton } from '@components/backoffice/buttons/SeeAllButton'; import _get from 'lodash/get'; +import Overridable from 'react-overridable'; -export default class DocumentItems extends Component { +class DocumentItems extends Component { componentDidMount() { const { fetchDocumentItems, documentDetails } = this.props; fetchDocumentItems(documentDetails.pid); @@ -39,9 +40,8 @@ export default class DocumentItems extends Component { return `${row.metadata.internal_location.name} (${row.metadata.internal_location.location.name})`; }; - renderTable(data) { - const { showMaxItems } = this.props; - const columns = [ + getColumnFormat = () => { + return [ { title: 'Barcode', field: 'metadata.barcode', @@ -75,6 +75,12 @@ export default class DocumentItems extends Component { }, }, ]; + }; + + renderTable(data) { + const { showMaxItems, columnFormat } = this.props; + const columns = + columnFormat !== null ? columnFormat() : this.getColumnFormat(); return ( - - - } - showAllResults={false} - showFooterSummary={true} - showMaxRows={5} - singleLine={true} - subtitle="" - title="" - totalHitsCount={0} - /> - - + showMaxItems={5} +/> `; exports[`DocumentItems tests should render item 1`] = ` - - - - - - + - } - showAllResults={false} - showFooterSummary={true} - showMaxRows={5} - singleLine={true} - subtitle="" - title="" - totalHitsCount={2} - > - + } + showAllResults={false} + showFooterSummary={true} + showMaxRows={5} singleLine={true} - striped={true} subtitle="" title="" - unstackable={true} + totalHitsCount={2} > -
- - - - - - - - - - - - + Barcode + + + + - - - - - + Status + + + + - - - - - + Medium + + + + - - - - - + Location + + + + - - - - - + Shelf + + + + - - - - - + Restrictions + + + + - - - - - - - - - + Loan Status + + + + + + + + + - - - - - - - - - + + - MISSING - - - - + + - NOT_SPECIFIED - - - - + + - undefined (Somewhere) - - - - + + - Shelf 1 - - - - + + - NO_RESTRICTION - - - - + + - - - - - - - - + - + + + + + - - - - - + + - CAN_CIRCULATE - - - - + + - NOT_SPECIFIED - - - - + + - undefined (Somewhere Else) - - - - + + - Shelf 2 - - - - + + - ONE_WEEK - - - - + + - - - - - - - - - - - } - showAllResults={false} - showFooterSummary={true} - showMaxRows={5} - /> -
- Barcode - - Status - - Medium - - Location - - Shelf - - Restrictions - - Loan Status -
- - + + + MISSING + + NOT_SPECIFIED + + undefined (Somewhere) + + Shelf 1 + + NO_RESTRICTION +
- - + + + CAN_CIRCULATE + + NOT_SPECIFIED + + undefined (Somewhere Else) + + Shelf 2 + + ONE_WEEK +
- -
-
-
-
-
-
+ + - + + + + + + + + + } + showAllResults={false} + showFooterSummary={true} + showMaxRows={5} + /> + + +
+ + + + + + `; exports[`DocumentItems tests should render show a message with no items 1`] = ` - - - - - - - } - showAllResults={false} - showFooterSummary={true} - showMaxRows={5} - singleLine={true} - subtitle="" - title="" - totalHitsCount={0} + - + } + showAllResults={false} + showFooterSummary={true} + showMaxRows={5} + singleLine={true} + subtitle="" + title="" + totalHitsCount={0} > -
- -
- -
- No results found -
-
- There are no - attached items - . -
-
-
-
-
-
-
-
-
-
+
+ +
+ +
+ No results found +
+
+ There are no + attached items + . +
+
+
+ + + + + + + + `; exports[`DocumentItems tests should render the see all button when showing only a few items 1`] = ` - - - - - - + - } - showAllResults={false} - showFooterSummary={true} - showMaxRows={1} - singleLine={true} - subtitle="" - title="" - totalHitsCount={2} - > - + } + showAllResults={false} + showFooterSummary={true} + showMaxRows={1} singleLine={true} - striped={true} subtitle="" title="" - unstackable={true} + totalHitsCount={2} > -
- - - - - - - - - - - - + Barcode + + + + - - - - - + Status + + + + - - - - - + Medium + + + + - - - - - + Location + + + + - - - - - + Shelf + + + + - - - - - + Restrictions + + + + - - - - - - - - - + Loan Status + + + + + + + + + - - + - - - - - - - + + - MISSING - - - - + + - NOT_SPECIFIED - - - - + + - undefined (Somewhere) - - - - + + - Shelf 1 - - - - + + - NO_RESTRICTION - - - - + + - - - - - - - - - - - } - showAllResults={false} - showFooterSummary={true} - showMaxRows={1} - > - + - + + + + + + + + + } + showAllResults={false} + showFooterSummary={true} + showMaxRows={1} > - - - - - - - - - - - - - - - -
- Barcode - - Status - - Medium - - Location - - Shelf - - Restrictions - - Loan Status -
- - + + + MISSING + + NOT_SPECIFIED + + undefined (Somewhere) + + Shelf 1 + + NO_RESTRICTION +
- - Showing entries - 1 - - - 1 - of - 2 - - - - - - - - -
- -
-
-
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + `;