Skip to content

Commit

Permalink
feat: display sample inventory label tag in sample header and list (C…
Browse files Browse the repository at this point in the history
  • Loading branch information
adambasha0 authored Nov 14, 2024
1 parent d5621b2 commit 8907b90
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/components/ElementsTable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}

.sample-entries > tbody > tr > td {
border-top: 0
border-top: 0;
}

@media only screen and (max-width: 1500px) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export default class SampleDetails extends React.Component {
const { currentCollection } = UIStore.getState();
LoadingActions.start.defer();
const { sample, validCas } = this.state;
if (this.matchSelectedCollection(currentCollection) && sample.xref.inventory_label !== undefined) {
if (this.matchSelectedCollection(currentCollection) && sample.inventory_label !== undefined) {
sample.collection_id = currentCollection.id;
}
this.checkMolfileChange();
Expand Down Expand Up @@ -953,13 +953,15 @@ export default class SampleDetails extends React.Component {
/>
) : null;

const inventoryLabel = sample.inventory_sample && sample.inventory_label ? sample.inventory_label : null;

return (
<div className="d-flex align-items-center justify-content-between">
<div className="d-flex align-items-center gap-2">
<OverlayTrigger placement="bottom" overlay={<Tooltip id="sampleDates">{titleTooltip}</Tooltip>}>
<span className="flex-shrink-0">
<i className="icon-sample me-1" />
{sample.title()}
{inventoryLabel || sample.title()}
</span>
</OverlayTrigger>
<ShowUserLabels element={sample} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import {
Table, Button, Tooltip, OverlayTrigger
Table, Button, Tooltip, OverlayTrigger, Badge,
} from 'react-bootstrap';
import classnames from 'classnames';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -107,6 +107,20 @@ const showDecoupledIcon = (sample) => (sample.decoupled ? (
</OverlayTrigger>
) : null);

const showInventoryLabelIcon = (sample) => (sample.inventory_sample && sample.inventory_label ? (
<OverlayTrigger
placement="top"
overlay={<Tooltip id="sample_inventory_label">Inventory Label</Tooltip>}
>
<Badge
className="bg-info text-light p-1 mt-0 rounded"
key={`inventory_label_${sample.inventory_label}`}
>
{sample.inventory_label}
</Badge>
</OverlayTrigger>
) : null);

const overlayToggle = <Tooltip id="toggle_molecule">Toggle Molecule</Tooltip>;

const svgPreview = (sample) => (
Expand Down Expand Up @@ -366,6 +380,7 @@ export default class ElementsTableSampleEntries extends Component {
{sample.title(selected)}

<div className="d-flex align-items-center gap-1">
{showInventoryLabelIcon(sample)}
<CommentIcon commentCount={sample.comment_count} />
<ShowUserLabels element={sample} />
<XvialIcon label={sample.external_label} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const SearchResultTabContent = ({ list, tabResult, openDetail }) => {
} else if (object.type == 'sample') {
let infos = [];
if (object.external_label) { infos.push(object.external_label) }
if (object.xref && object.xref.inventory_label) { infos.push(object.xref.inventory_label) }
if (object.xref && object.inventory_label) { infos.push(object.inventory_label) }
if (object.xref && object.xref.cas) { infos.push(object.xref.cas) }
names = [object.short_label, object.name].concat(infos).join(" | ");
} else {
Expand Down
8 changes: 8 additions & 0 deletions app/packs/src/models/Sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,14 @@ export default class Sample extends Element {
return this._gas_phase_data;
}

get inventory_label() {
return this.xref.inventory_label;
}

set inventory_label(inventory_label) {
this.xref.inventory_label = inventory_label;
}

addSolvent(newSolvent) {
const { molecule } = newSolvent;
if (molecule) {
Expand Down

0 comments on commit 8907b90

Please sign in to comment.