Skip to content

Commit

Permalink
lintfix + permissions sql script
Browse files Browse the repository at this point in the history
  • Loading branch information
ridz1208 committed Nov 18, 2024
1 parent 88c3a52 commit 1e64ea5
Show file tree
Hide file tree
Showing 40 changed files with 2,279 additions and 2,103 deletions.
242 changes: 124 additions & 118 deletions modules/biobank/jsx/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,84 +11,90 @@ import ContainerDisplay from './containerDisplay';
* Fetches data corresponding to a given Container from Loris backend and
* displays a page allowing viewing of meta information of the container
*
* @author Henri Rabalais
* @author Henri Rabalais
* @version 1.0.0
*
* */
class BiobankContainer extends Component {
/**
* Constructor
*/
constructor() {
super();
this.drag = this.drag.bind(this);
}
/**
* Constructor
*/
constructor()
{
super();
this.drag = this.drag.bind(this);
}

/**
* Handle dragging of a container
*
* @param {Event} e - the drag event
*/
drag(e) {
const container = JSON.stringify(this.props.data.containers[e.target.id]);
e.dataTransfer.setData('text/plain', container);
}
/**
* Handle dragging of a container
*
* @param {Event} e - the drag event
*/
drag(e)
{
const container = JSON.stringify(this.props.data.containers[e.target.id]);
e.dataTransfer.setData('text/plain', container);
}

/**
* Render React component
*
* @return {JSX}
*/
render() {
const {current, data, editable, options, container} = this.props;
/**
* Render React component
*
* @return {JSX}
*/
render()
{
const {current, data, editable, options, container} = this.props;

const checkoutButton = () => {
if (!(loris.userHasPermission('biobank_container_update')) ||
(data.containers[container.id].childContainerIds.length == 0)) {
return;
}
const checkoutButton = () => {
if (!(loris.userHasPermission('biobank_container_update'))
|| (data.containers[container.id].childContainerIds.length == 0)
) {
return;
}

return (
<div style = {{marginLeft: 'auto', height: '10%', marginRight: '10%'}}>
<div
return (
<div style = {{marginLeft: 'auto', height: '10%', marginRight: '10%'}}>
<div
className={!editable.containerCheckout && !editable.loadContainer ?
'action-button update open' : 'action-button update closed'}
'action-button update open' : 'action-button update closed'}
title='Checkout Child Containers'
onClick={()=>{
this.props.edit('containerCheckout');
}}
>
this.props.edit('containerCheckout');
}}
>
<span className='glyphicon glyphicon-share'/>
</div>
</div>
);
};
</div>
</div>
);
};

const parentBarcodes = this.props.getParentContainerBarcodes(container);
const barcodes = mapFormOptions(data.containers, 'barcode');
// delete values that are parents of the container
Object.keys(parentBarcodes)
.forEach((key) => Object.keys(barcodes)
const parentBarcodes = this.props.getParentContainerBarcodes(container);
const barcodes = mapFormOptions(data.containers, 'barcode');
// delete values that are parents of the container
Object.keys(parentBarcodes)
.forEach(
(i) => (parentBarcodes[key] == barcodes[i])
(key) => Object.keys(barcodes)
.forEach(
(i) => (parentBarcodes[key] == barcodes[i])
&& delete barcodes[i]
)
);
)
);

const barcodePathDisplay = this.props.getBarcodePathDisplay(parentBarcodes);
const coordinates = data.containers[container.id].childContainerIds
.reduce((result, id) => {
const container = data.containers[id];
if (container.coordinate) {
result[container.coordinate] = id;
}
return result;
}, {});
const barcodePathDisplay = this.props.getBarcodePathDisplay(parentBarcodes);
const coordinates = data.containers[container.id].childContainerIds
.reduce(
(result, id) => {
const container = data.containers[id];
if (container.coordinate) {
result[container.coordinate] = id;
}
return result;
}, {}
);

const containerDisplay = (
<div className='display-container'>
{checkoutButton()}
<ContainerDisplay
const containerDisplay = (
<div className='display-container'>
{checkoutButton()}
<ContainerDisplay
history={this.props.history}
data={data}
container={container}
Expand All @@ -104,59 +110,59 @@ class BiobankContainer extends Component {
setCheckoutList={this.props.setCheckoutList}
editContainer={this.props.editContainer}
updateContainer={this.props.updateContainer}
/>
<div style={{display: 'inline'}}>
/>
<div style={{display: 'inline'}}>
{barcodePathDisplay}
</div>
</div>
</div>
);

const containerList = () => {
if (!container.childContainerIds) {
return <div className='title'>This Container is Empty!</div>;
}
const childIds = container.childContainerIds;
let listAssigned = [];
let coordinateList = [];
let listUnassigned = [];
childIds.forEach((childId) => {
if (!loris.userHasPermission('biobank_specimen_view')) {
return;
}
);

const child = data.containers[childId];

if (child.coordinate) {
listAssigned.push(
<div>
<Link
key={childId}
to={`/barcode=${child.barcode}`}>
const containerList = () => {
if (!container.childContainerIds) {
return <div className='title'>This Container is Empty!</div>;
}
const childIds = container.childContainerIds;
let listAssigned = [];
let coordinateList = [];
let listUnassigned = [];
childIds.forEach(
(childId) => {
if (!loris.userHasPermission('biobank_specimen_view')) {
return;
}
const child = data.containers[childId];
if (child.coordinate) {
listAssigned.push(
<div>
<Link
key={childId}
to={`/barcode=${child.barcode}`}>
{child.barcode}
</Link>
</div>
);
const coordinate = this.props.getCoordinateLabel(child);
coordinateList.push(<div>at {coordinate}</div>);
} else {
listUnassigned.push(
<div>
<Link
key={childId}
to={`/barcode=${child.barcode}`}
id={child.id}
draggable={true}
onDragStart={this.drag}
>
{child.barcode}
</Link>
<br/>
</div>
);
}
});
</Link>
</div>
);
const coordinate = this.props.getCoordinateLabel(child);
coordinateList.push(<div>at {coordinate}</div>);
} else {
listUnassigned.push(
<div>
<Link
key={childId}
to={`/barcode=${child.barcode}`}
id={child.id}
draggable={true}
onDragStart={this.drag}
>
{child.barcode}
</Link>
<br/>
</div>
);
}
}
);

return (
return (
<div>
<div className='title'>
{listAssigned.length !== 0 ? 'Assigned Containers' : null}
Expand All @@ -171,22 +177,22 @@ class BiobankContainer extends Component {
</div>
{listUnassigned}
</div>
);
};
);
};

return (
<div className="container-display">
return (
<div className="container-display">
{containerDisplay}
<div className='container-list'>
{containerList()}
</div>
</div>
);
}
</div>
);
}
}

BiobankContainer.propTypes = {
containerPageDataURL: PropTypes.string.isRequired,
containerPageDataURL: PropTypes.string.isRequired,
};

export default BiobankContainer;
Loading

0 comments on commit 1e64ea5

Please sign in to comment.