-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UIU-2966 - display item title and barcode as text for dcb virtual item. #2597
Changes from 2 commits
5017b23
cc1731d
d326659
3de4fed
72165e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ import { | |
accountsMatchStatus, | ||
checkUserActive, | ||
isDcbUser, | ||
isDCBItem, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to decide between functions like |
||
} from '../../components/util'; | ||
import { itemStatuses, loanActions, refundClaimReturned } from '../../constants'; | ||
import { | ||
|
@@ -298,23 +299,56 @@ class LoanDetails extends React.Component { | |
|
||
showTitle(loan) { | ||
this.loan = loan; | ||
const title = `${get(this.loan, ['item', 'title'], '')}`; | ||
const title = get(this.loan, ['item', 'title'], ''); | ||
const instanceId = get(this.loan, ['item', 'instanceId'], ''); | ||
const holdingsRecordId = get(this.loan, ['item', 'holdingsRecordId'], ''); | ||
const isVirtualItem = isDCBItem({ instanceId, holdingsRecordId }); | ||
|
||
if (title) { | ||
const titleTodisplay = (title.length >= 77) ? `${title.substring(0, 77)}...` : title; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know you didn't add this, but while you're here, can you move this magic number to a constant? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. implemented it. I hope this is the way you would suggest it to be. |
||
return <KeyValue | ||
const formattedValue = `${titleTodisplay} (${get(this.loan, ['item', 'materialType', 'name'])})`; | ||
return ( | ||
<KeyValue | ||
data-testId="item-title" | ||
label={<FormattedMessage id="ui-users.loans.columns.title" />} | ||
value={ | ||
isVirtualItem ? | ||
`${formattedValue}` : | ||
<Link to={`/inventory/view/${instanceId}`}> | ||
{formattedValue} | ||
</Link> | ||
zburke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<KeyValue | ||
label={<FormattedMessage id="ui-users.loans.columns.title" />} | ||
value={( | ||
<Link to={`/inventory/view/${get(this.loan, ['item', 'instanceId'], '')}`}> | ||
{`${titleTodisplay} (${get(this.loan, ['item', 'materialType', 'name'])})`} | ||
</Link> | ||
)} | ||
/>; | ||
value="-" | ||
zburke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/> | ||
); | ||
} | ||
|
||
showBarcode(loan) { | ||
this.loan = loan; | ||
const instanceId = get(this.loan, ['item', 'instanceId'], ''); | ||
const holdingsRecordId = get(this.loan, ['item', 'holdingsRecordId'], ''); | ||
const itemId = get(this.loan, ['itemId'], ''); | ||
const itemBarcode = get(loan, ['item', 'barcode'], ''); | ||
const isVirtualItem = isDCBItem({ instanceId, holdingsRecordId }); | ||
|
||
if (isVirtualItem) { | ||
return itemBarcode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The diff makes it hard to assess, but do you need to handle items without barcodes? If so, set the default value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not the code that I have written now. It has been restructured by me.
|
||
} | ||
|
||
return <KeyValue | ||
label={<FormattedMessage id="ui-users.loans.columns.title" />} | ||
value="-" | ||
/>; | ||
return ( | ||
<Link | ||
to={`/inventory/view/${instanceId}/${holdingsRecordId}/${itemId}`} | ||
> | ||
{itemBarcode} | ||
</Link> | ||
); | ||
} | ||
|
||
renderChangeDueDateDialog() { | ||
|
@@ -627,8 +661,9 @@ class LoanDetails extends React.Component { | |
</Col> | ||
<Col xs={2}> | ||
<KeyValue | ||
data-testId="item-barcode" | ||
label={<FormattedMessage id="ui-users.loans.columns.barcode" />} | ||
value={<Link to={`/inventory/view/${get(loan, ['item', 'instanceId'], '')}/${get(loan, ['item', 'holdingsRecordId'], '')}/${get(loan, ['itemId'], '')}`}>{get(loan, ['item', 'barcode'], '')}</Link>} | ||
value={this.showBarcode(loan)} | ||
/> | ||
</Col> | ||
<Col xs={2}> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad to see these values as constants, but to me they feel like the kind of thing that should be provided in an API request like
/inventory/dcb-instance-id
. I realize that's not on you, but it seems like bad policy to have a bunch of UUIDs copied around inside a bunch of different back-end and front-end modules.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, implementing such an API was not a part of architecture.