From 0befef80ddfb3284516256d3340777de54836960 Mon Sep 17 00:00:00 2001 From: Saksham Arora Date: Fri, 14 Jun 2024 11:50:50 +0200 Subject: [PATCH 1/3] backoffice: DocumentItems: Update DocumentItems to be overridable --- src/lib/index.js | 3 +++ .../DocumentDetails/DocumentItems/DocumentItems.js | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/index.js b/src/lib/index.js index 0878562c3..6fb29d557 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -51,3 +51,6 @@ 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 { Loader } from '@components/Loader'; +export { Error } from '@components/Error'; +export { SeeAllButton } from '@components/backoffice/buttons/SeeAllButton'; diff --git a/src/lib/pages/backoffice/Document/DocumentDetails/DocumentItems/DocumentItems.js b/src/lib/pages/backoffice/Document/DocumentDetails/DocumentItems/DocumentItems.js index b9a9ccde5..cc4b84e42 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); @@ -111,3 +112,8 @@ DocumentItems.defaultProps = { isLoading: false, error: null, }; + +export default Overridable.component( + 'DocumentDetails.DocumentItems', + DocumentItems +); From 5d334d4ed6db5bcfecab56a8ef05597a6d2bfb11 Mon Sep 17 00:00:00 2001 From: Saksham Arora Date: Fri, 14 Jun 2024 13:10:15 +0200 Subject: [PATCH 2/3] backoffice: DocumentItems: Update test snapshot --- .../__snapshots__/DocumentItems.test.js.snap | 3478 +++++++++-------- 1 file changed, 1787 insertions(+), 1691 deletions(-) diff --git a/src/lib/pages/backoffice/Document/DocumentDetails/DocumentItems/__snapshots__/DocumentItems.test.js.snap b/src/lib/pages/backoffice/Document/DocumentDetails/DocumentItems/__snapshots__/DocumentItems.test.js.snap index d66dc3925..58ee3f44c 100644 --- a/src/lib/pages/backoffice/Document/DocumentDetails/DocumentItems/__snapshots__/DocumentItems.test.js.snap +++ b/src/lib/pages/backoffice/Document/DocumentDetails/DocumentItems/__snapshots__/DocumentItems.test.js.snap @@ -1,79 +1,30 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`DocumentItems tests should load the DocumentItems component 1`] = ` - - - - } - 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 - - - - - - - - -
- -
-
-
-
-
-
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + `; From 11e468a5b5e1638814c9f80da4094cbec9016804 Mon Sep 17 00:00:00 2001 From: Saksham Arora Date: Fri, 14 Jun 2024 14:25:33 +0200 Subject: [PATCH 3/3] backoffice: DocumentItems: Add columnFormat parameter --- src/lib/index.js | 4 +--- .../DocumentDetails/DocumentItems/DocumentItems.js | 13 ++++++++++--- .../__snapshots__/DocumentItems.test.js.snap | 4 ++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/lib/index.js b/src/lib/index.js index 6fb29d557..aa4abe598 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -51,6 +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 { Loader } from '@components/Loader'; -export { Error } from '@components/Error'; -export { SeeAllButton } from '@components/backoffice/buttons/SeeAllButton'; +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 cc4b84e42..f9cd559df 100644 --- a/src/lib/pages/backoffice/Document/DocumentDetails/DocumentItems/DocumentItems.js +++ b/src/lib/pages/backoffice/Document/DocumentDetails/DocumentItems/DocumentItems.js @@ -40,9 +40,8 @@ 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', @@ -76,6 +75,12 @@ class DocumentItems extends Component { }, }, ]; + }; + + renderTable(data) { + const { showMaxItems, columnFormat } = this.props; + const columns = + columnFormat !== null ? columnFormat() : this.getColumnFormat(); return (