chem-generic-ui 0.1.42 → 0.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +1 -1
- package/package.json +14 -6
- package/src/app.js +2 -0
- package/.babelrc +0 -11
- package/.eslintrc +0 -23
- package/.tool-versions +0 -3
- package/chem-generic-ui-v0.1.41.tgz +0 -0
- package/dist/bundle.js.LICENSE.txt +0 -79
- package/public/ds_details.json +0 -57
- package/public/ds_klass.json +0 -102
- package/public/ds_props.json +0 -54
- package/public/favicon.ico +0 -0
- package/public/images/not_available.svg +0 -1
- package/public/index.html +0 -47
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/public/sg_details.json +0 -2036
- package/public/sg_klass.json +0 -850
- package/public/test/ds_props.json +0 -54
- package/public/units_system.json +0 -430
- package/src/asserts/main.css +0 -458
- package/src/asserts/main.scss +0 -490
- package/src/components/admin/ElementManager.js +0 -28
- package/src/components/details/GenDSDetails.js +0 -164
- package/src/components/details/GenSgDetails.js +0 -396
- package/src/components/dnd/DragDropItemTypes.js +0 -13
- package/src/components/dnd/GenericElDropTarget.js +0 -160
- package/src/components/dnd/GridDnD.js +0 -42
- package/src/components/dnd/PanelDnD.js +0 -85
- package/src/components/fields/ButtonConfirm.js +0 -45
- package/src/components/fields/ButtonTooltip.js +0 -46
- package/src/components/fields/FieldLabel.js +0 -18
- package/src/components/fields/GenDSMisType.js +0 -20
- package/src/components/fields/GenFormGroupCb.js +0 -17
- package/src/components/fields/GenProperties.js +0 -56
- package/src/components/fields/GenPropertiesFields.js +0 -318
- package/src/components/layers/GenPropertiesLayer.js +0 -176
- package/src/components/layers/LayerModal.js +0 -52
- package/src/components/layers/LayersLayout.js +0 -68
- package/src/components/models/Attachment.js +0 -37
- package/src/components/models/GenericSubField.js +0 -10
- package/src/components/table/DropLinkRenderer.js +0 -35
- package/src/components/table/DropRenderer.js +0 -31
- package/src/components/table/DropTextRenderer.js +0 -25
- package/src/components/table/GenericElTableDropTarget.js +0 -131
- package/src/components/table/GridBtn.js +0 -41
- package/src/components/table/GridEntry.js +0 -75
- package/src/components/table/SamOption.js +0 -53
- package/src/components/table/SelectRenderer.js +0 -34
- package/src/components/table/TableRecord.js +0 -254
- package/src/components/table/UConverterRenderer.js +0 -24
- package/src/components/tools/collate.js +0 -65
- package/src/components/tools/orten.js +0 -171
- package/src/components/tools/utils.js +0 -414
- package/src/data/SystemUnits.js +0 -434
- package/src/data/systemUnits.json +0 -430
- package/src/index.css +0 -13
- package/src/index.html +0 -1
- package/src/index.js +0 -45
- package/src/logo.svg +0 -1
- package/src/simulations/SimuDS.js +0 -52
- package/src/simulations/SimuSG.js +0 -54
- package/webpack.config.js +0 -45
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { DragSource, DropTarget } from 'react-dnd';
|
|
4
|
-
import { compose } from 'redux';
|
|
5
|
-
import { Card, ButtonGroup, OverlayTrigger, Tooltip, Button } from 'react-bootstrap';
|
|
6
|
-
import { v4 as uuid } from 'uuid';
|
|
7
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
8
|
-
|
|
9
|
-
const orderSource = {
|
|
10
|
-
canDrag(props) {
|
|
11
|
-
return !props.layer.wf;
|
|
12
|
-
},
|
|
13
|
-
beginDrag(props) {
|
|
14
|
-
const { layer, field, rowValue } = props;
|
|
15
|
-
return { wf: layer.wf, fid: field, rId: rowValue.id };
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const orderTarget = {
|
|
20
|
-
canDrop(props, monitor) {
|
|
21
|
-
const src = monitor.getItem();
|
|
22
|
-
return !props.layer.wf || !src.wf;
|
|
23
|
-
},
|
|
24
|
-
drop(props, monitor) {
|
|
25
|
-
const {
|
|
26
|
-
layer, field, rowValue, handleMove
|
|
27
|
-
} = props;
|
|
28
|
-
const tar = { wf: layer.wf, fid: field, rId: rowValue.id };
|
|
29
|
-
const src = monitor.getItem();
|
|
30
|
-
if (tar.fid === src.fid && tar.rId !== src.rId) handleMove(src.rId, tar.rId);
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const orderDragCollect = (connect, monitor) => ({
|
|
35
|
-
connectDragSource: connect.dragSource(),
|
|
36
|
-
isDragging: monitor.isDragging(),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const orderDropCollect = (connect, monitor) => ({
|
|
40
|
-
connectDropTarget: connect.dropTarget(),
|
|
41
|
-
isOver: monitor.isOver(),
|
|
42
|
-
canDrop: monitor.canDrop(),
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const PanelDnD = ({
|
|
46
|
-
connectDragSource, connectDropTarget, isDragging, isOver, canDrop,
|
|
47
|
-
layer, id, handleChange, bs
|
|
48
|
-
}) => {
|
|
49
|
-
const className = `generic_grid_dnd${isOver ? ' is-over' : ''}${canDrop ? ' can-drop' : ''}${isDragging ? ' is-dragging' : ''}`;
|
|
50
|
-
const {
|
|
51
|
-
style, label, wf, key
|
|
52
|
-
} = layer;
|
|
53
|
-
const klz = (style || 'panel_generic_heading').replace('panel_generic_heading', 'panel_generic_heading_slim');
|
|
54
|
-
const btnAdd = (
|
|
55
|
-
<OverlayTrigger delayShow={1000} placement="top" overlay={<Tooltip id="_tooltip_add_layer">add layer</Tooltip>}>
|
|
56
|
-
<Button size="sm" onClick={event => handleChange(event, id, layer, 'layer-modal')}><FontAwesomeIcon icon="fas fa-plus" /></Button>
|
|
57
|
-
</OverlayTrigger>
|
|
58
|
-
);
|
|
59
|
-
const btnRemove = (
|
|
60
|
-
<OverlayTrigger delayShow={1000} placement="top" overlay={<Tooltip id="_tooltip_remove_layer">remove layer</Tooltip>}>
|
|
61
|
-
<Button size="sm" onClick={event => handleChange(event, id, layer, 'layer-remove')}><FontAwesomeIcon icon="fas fa-minus" /></Button>
|
|
62
|
-
</OverlayTrigger>
|
|
63
|
-
);
|
|
64
|
-
const wfIcon = wf ? (<span> <FontAwesomeIcon icon="fas fa-sitemap" /></span>) : null;
|
|
65
|
-
const moveIcon = (
|
|
66
|
-
<OverlayTrigger delayShow={1000} placement="top" overlay={<Tooltip id={uuid()}>drag and drop to move position</Tooltip>}>
|
|
67
|
-
<Button onClick={() => {}} size="sm"><FontAwesomeIcon icon="fas fa-arrows-alt" /></Button>
|
|
68
|
-
</OverlayTrigger>);
|
|
69
|
-
const btnLayer = wf ? (<ButtonGroup className="pull-right" >{btnAdd}</ButtonGroup>) : (<ButtonGroup className="pull-right" >{btnAdd}{btnRemove}{moveIcon}</ButtonGroup>);
|
|
70
|
-
const extHead = (/\./g.test(key)) ? <>({key}{wfIcon})</> : null;
|
|
71
|
-
const panelHeader = (
|
|
72
|
-
<Card.Heading className={klz}>
|
|
73
|
-
<Card.Title toggle style={{ float: 'left', lineHeight: 'normal' }}>{label} {extHead}</Card.Title>{btnLayer}
|
|
74
|
-
<div className="clearfix" />
|
|
75
|
-
</Card.Heading>
|
|
76
|
-
);
|
|
77
|
-
const panelHColor = bs !== 'none' ? `panel-${bs}` : '';
|
|
78
|
-
const dndKlz = wf ? `dnd-none ${panelHColor}` : `dnd ${panelHColor}`;
|
|
79
|
-
return compose(connectDragSource, connectDropTarget)(<div className={className}><div className={dndKlz}>{panelHeader}</div></div>);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export default compose(
|
|
83
|
-
DragSource(s => s.type, orderSource, orderDragCollect),
|
|
84
|
-
DropTarget(s => s.type, orderTarget, orderDropCollect)
|
|
85
|
-
)(PanelDnD);
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { Button, OverlayTrigger, Popover } from 'react-bootstrap';
|
|
4
|
-
|
|
5
|
-
const ButtonConfirm = (props) => {
|
|
6
|
-
const {
|
|
7
|
-
msg, size, bs, fnClick, fnParams, place, fa, disabled
|
|
8
|
-
} = props;
|
|
9
|
-
const popover = (
|
|
10
|
-
<Popover id="popover-button-confirm">
|
|
11
|
-
{msg} <br />
|
|
12
|
-
<div className="btn-toolbar">
|
|
13
|
-
<Button size="sm" variant="danger" aria-hidden="true" onClick={() => fnClick(fnParams)}>
|
|
14
|
-
Yes
|
|
15
|
-
</Button><span> </span>
|
|
16
|
-
<Button size="sm" variant="warning">No</Button>
|
|
17
|
-
</div>
|
|
18
|
-
</Popover>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<OverlayTrigger animation placement={place} root trigger="focus" overlay={popover}>
|
|
23
|
-
<Button size={size} variant={bs} disabled={disabled}>
|
|
24
|
-
<i className={`fa ${fa}`} aria-hidden="true" />
|
|
25
|
-
</Button>
|
|
26
|
-
</OverlayTrigger>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
ButtonConfirm.propTypes = {
|
|
31
|
-
msg: PropTypes.string.isRequired,
|
|
32
|
-
fnParams: PropTypes.object.isRequired,
|
|
33
|
-
fnClick: PropTypes.func.isRequired,
|
|
34
|
-
bs: PropTypes.string,
|
|
35
|
-
size: PropTypes.string,
|
|
36
|
-
place: PropTypes.string,
|
|
37
|
-
fa: PropTypes.string,
|
|
38
|
-
disabled: PropTypes.bool,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
ButtonConfirm.defaultProps = {
|
|
42
|
-
bs: 'danger', size: 'xs', place: 'right', fa: 'fa-trash-o', disabled: false
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export default ButtonConfirm;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { Button, OverlayTrigger, Tooltip } from 'react-bootstrap';
|
|
4
|
-
import { v4 as uuid } from 'uuid';
|
|
5
|
-
|
|
6
|
-
const ButtonTooltip = (props) => {
|
|
7
|
-
const tip = <Tooltip id={uuid()}>{props.tip}</Tooltip>;
|
|
8
|
-
const {
|
|
9
|
-
size, bs, fnClick, element, place, fa, disabled, txt
|
|
10
|
-
} = props;
|
|
11
|
-
const content = txt ? (<span>{txt} </span>) : '';
|
|
12
|
-
if (bs === '') {
|
|
13
|
-
return (
|
|
14
|
-
<OverlayTrigger delayShow={1000} placement={place} overlay={tip} >
|
|
15
|
-
<Button size={size} onClick={() => fnClick(element)} disabled={disabled}>
|
|
16
|
-
{content}<i className={`fa ${fa}`} aria-hidden="true" />
|
|
17
|
-
</Button>
|
|
18
|
-
</OverlayTrigger>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
return (
|
|
22
|
-
<OverlayTrigger delayShow={1000} placement={place} overlay={tip} >
|
|
23
|
-
<Button size={size} variant={bs} onClick={() => fnClick(element)} disabled={disabled}>
|
|
24
|
-
{content}<i className={`fa ${fa}`} aria-hidden="true" />
|
|
25
|
-
</Button>
|
|
26
|
-
</OverlayTrigger>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
ButtonTooltip.propTypes = {
|
|
31
|
-
tip: PropTypes.string.isRequired,
|
|
32
|
-
element: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
|
|
33
|
-
fnClick: PropTypes.func.isRequired,
|
|
34
|
-
bs: PropTypes.string,
|
|
35
|
-
size: PropTypes.string,
|
|
36
|
-
place: PropTypes.string,
|
|
37
|
-
fa: PropTypes.string,
|
|
38
|
-
disabled: PropTypes.bool,
|
|
39
|
-
txt: PropTypes.string,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
ButtonTooltip.defaultProps = {
|
|
43
|
-
bs: '', size: 'xs', place: 'right', fa: 'fa-pencil-square-o', disabled: false, txt: null, element: {}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default ButtonTooltip;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { OverlayTrigger, Tooltip } from 'react-bootstrap';
|
|
4
|
-
import { v4 as uuid } from 'uuid';
|
|
5
|
-
|
|
6
|
-
const FieldLabel = (props) => {
|
|
7
|
-
const { label, desc } = props;
|
|
8
|
-
return (desc && desc !== '') ? (
|
|
9
|
-
<OverlayTrigger placement="top" delayShow={1000} overlay={<Tooltip id={uuid()}>{desc}</Tooltip>}>
|
|
10
|
-
<span>{label}</span>
|
|
11
|
-
</OverlayTrigger>
|
|
12
|
-
) : <span>{label}</span>;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
FieldLabel.propTypes = { label: PropTypes.string.isRequired, desc: PropTypes.string };
|
|
16
|
-
FieldLabel.defaultProps = { desc: '' };
|
|
17
|
-
|
|
18
|
-
export default FieldLabel;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { OverlayTrigger, Tooltip } from 'react-bootstrap';
|
|
4
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
-
|
|
6
|
-
const GenDSMisType = (props) => {
|
|
7
|
-
const { uiCtrl } = props;
|
|
8
|
-
if (uiCtrl) {
|
|
9
|
-
return (
|
|
10
|
-
<OverlayTrigger placement="top" delay={300} overlay={<Tooltip id="tooltip">Type (Chemical Methods Ontology) has been changed. <br />Please review this Dataset content.</Tooltip>}>
|
|
11
|
-
<span style={{ color: 'red' }}><FontAwesomeIcon icon="fas fa-exclamation-circle" /> </span>
|
|
12
|
-
</OverlayTrigger>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
GenDSMisType.propTypes = { uiCtrl: PropTypes.bool.isRequired };
|
|
19
|
-
|
|
20
|
-
export default GenDSMisType;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/prop-types */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { InputGroup, FormGroup } from 'react-bootstrap';
|
|
4
|
-
|
|
5
|
-
const GenFormGroupCb = (props) => {
|
|
6
|
-
const {
|
|
7
|
-
label, value, name, onChange
|
|
8
|
-
} = props;
|
|
9
|
-
return (
|
|
10
|
-
<FormGroup className="text_generic_properties">
|
|
11
|
-
{label || '' }
|
|
12
|
-
<InputGroup.Checkbox checked={value} onChange={e => onChange(e, name)} />
|
|
13
|
-
</FormGroup>
|
|
14
|
-
);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default GenFormGroupCb;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GenPropertiesCheckbox,
|
|
3
|
-
GenPropertiesCalculate,
|
|
4
|
-
GenPropertiesSelect,
|
|
5
|
-
GenPropertiesDrop,
|
|
6
|
-
GenPropertiesNumber,
|
|
7
|
-
GenPropertiesSystemDefined,
|
|
8
|
-
GenPropertiesInputGroup,
|
|
9
|
-
GenPropertiesTextArea,
|
|
10
|
-
GenPropertiesUpload,
|
|
11
|
-
GenDummy,
|
|
12
|
-
GenPropertiesTable,
|
|
13
|
-
GenTextFormula,
|
|
14
|
-
GenWFNext,
|
|
15
|
-
GenPropertiesText
|
|
16
|
-
} from './GenPropertiesFields';
|
|
17
|
-
|
|
18
|
-
const GenProperties = (opt) => {
|
|
19
|
-
const fieldProps = { ...opt, dndItems: [] };
|
|
20
|
-
const type = fieldProps.type.split('_');
|
|
21
|
-
if (opt.isSearchCriteria && type[0] === 'drag') type[0] = 'text';
|
|
22
|
-
// if (opt.isPreview && (type[0] === 'drag' || type[0] === 'upload')) type[0] = 'text';
|
|
23
|
-
switch (type[0]) {
|
|
24
|
-
case 'checkbox':
|
|
25
|
-
return GenPropertiesCheckbox(fieldProps);
|
|
26
|
-
case 'formula-field':
|
|
27
|
-
return GenPropertiesCalculate(fieldProps);
|
|
28
|
-
case 'select':
|
|
29
|
-
return GenPropertiesSelect(fieldProps);
|
|
30
|
-
case 'drag':
|
|
31
|
-
fieldProps.dndItems = [...fieldProps.dndItems, type[1]];
|
|
32
|
-
return GenPropertiesDrop(fieldProps);
|
|
33
|
-
case 'integer':
|
|
34
|
-
return GenPropertiesNumber(fieldProps);
|
|
35
|
-
case 'system-defined':
|
|
36
|
-
return GenPropertiesSystemDefined(fieldProps);
|
|
37
|
-
case 'input-group':
|
|
38
|
-
return GenPropertiesInputGroup(fieldProps);
|
|
39
|
-
case 'textarea':
|
|
40
|
-
return GenPropertiesTextArea(fieldProps);
|
|
41
|
-
case 'upload':
|
|
42
|
-
return GenPropertiesUpload(fieldProps);
|
|
43
|
-
case 'dummy':
|
|
44
|
-
return GenDummy();
|
|
45
|
-
case 'table':
|
|
46
|
-
return GenPropertiesTable(fieldProps);
|
|
47
|
-
case 'text-formula':
|
|
48
|
-
return GenTextFormula(fieldProps);
|
|
49
|
-
case 'wf-next':
|
|
50
|
-
return GenWFNext(fieldProps);
|
|
51
|
-
default:
|
|
52
|
-
return GenPropertiesText(fieldProps);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export default GenProperties;
|
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
|
-
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
3
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
4
|
-
/* eslint-disable no-eval */
|
|
5
|
-
/* eslint-disable no-restricted-globals */
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { Button, FormGroup, FormControl,
|
|
9
|
-
InputGroup, ListGroup, ListGroupItem, OverlayTrigger, Tooltip } from 'react-bootstrap';
|
|
10
|
-
import Select from 'react-select';
|
|
11
|
-
import Dropzone from 'react-dropzone';
|
|
12
|
-
import { v4 as uuid } from 'uuid';
|
|
13
|
-
import { filter } from 'lodash';
|
|
14
|
-
import FieldLabel from './FieldLabel';
|
|
15
|
-
import { downloadFile, genUnit, genUnitSup, unitConvToBase } from '../tools/utils';
|
|
16
|
-
import GenericElDropTarget from '../dnd/GenericElDropTarget';
|
|
17
|
-
import TableRecord from '../table/TableRecord';
|
|
18
|
-
|
|
19
|
-
const GenPropertiesCalculate = (opt) => {
|
|
20
|
-
const fields = (opt.layer && opt.layer.fields) || [];
|
|
21
|
-
let showVal = 0;
|
|
22
|
-
let showTxt = null;
|
|
23
|
-
let newFormula = opt.formula;
|
|
24
|
-
|
|
25
|
-
const calFields = filter(fields, o => (o.type === 'integer' || o.type === 'system-defined'));
|
|
26
|
-
const regF = /[a-zA-Z0-9]+/gm;
|
|
27
|
-
// eslint-disable-next-line max-len
|
|
28
|
-
const varFields = (opt.formula && opt.formula.match(regF)) ? opt.formula.match(regF).sort((a, b) => b.length - a.length) : [];
|
|
29
|
-
|
|
30
|
-
varFields.forEach((fi) => {
|
|
31
|
-
if (!isNaN(fi)) return;
|
|
32
|
-
|
|
33
|
-
const tmpField = calFields.find(e => e.field === fi);
|
|
34
|
-
if (typeof tmpField === 'undefined' || tmpField == null) {
|
|
35
|
-
newFormula = newFormula.replace(fi, 0);
|
|
36
|
-
} else {
|
|
37
|
-
newFormula = (tmpField.type === 'system-defined') ? newFormula.replace(fi, parseFloat(unitConvToBase(tmpField) || 0)) : newFormula.replace(fi, parseFloat(tmpField.value || 0));
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
if (opt.type === 'formula-field') {
|
|
42
|
-
try {
|
|
43
|
-
showVal = eval(newFormula);
|
|
44
|
-
showTxt = !isNaN(showVal) ? parseFloat(showVal.toFixed(5)) : 0;
|
|
45
|
-
} catch (e) {
|
|
46
|
-
if (e instanceof SyntaxError) {
|
|
47
|
-
showTxt = e.message;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const fieldHeader = opt.label === '' ? null : (<FieldLabel label={opt.label} desc={opt.description} />);
|
|
53
|
-
return (
|
|
54
|
-
<div>GenPropertiesCalculate</div>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const GenPropertiesCheckbox = opt => (
|
|
59
|
-
<div>GenPropertiesCheckbox</div>
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
const GenPropertiesDrop = (opt) => {
|
|
63
|
-
const className = opt.isRequired ? 'drop_generic_properties field_required' : 'drop_generic_properties';
|
|
64
|
-
|
|
65
|
-
let createOpt = null;
|
|
66
|
-
if (opt.value.is_new === true) {
|
|
67
|
-
createOpt = (
|
|
68
|
-
<div className="sample_radios">
|
|
69
|
-
<OverlayTrigger placement="top" overlay={<Tooltip id={uuid()}>associate with this sample</Tooltip>}>
|
|
70
|
-
<InputGroup.Radio name={`dropS_${opt.value.el_id}`} disabled={opt.value.isAssoc === true} checked={opt.value.cr_opt === 0} onChange={() => opt.onChange({ ...opt.value, cr_opt: 0 })} inline>Current</InputGroup.Radio>
|
|
71
|
-
</OverlayTrigger>
|
|
72
|
-
<OverlayTrigger placement="top" overlay={<Tooltip id={uuid()}>split from the sample first and then associate with it</Tooltip>}>
|
|
73
|
-
<InputGroup.Radio name={`dropS_${opt.value.el_id}`} checked={opt.value.cr_opt === 1} onChange={() => opt.onChange({ ...opt.value, cr_opt: 1 })} inline>Split</InputGroup.Radio>
|
|
74
|
-
</OverlayTrigger>
|
|
75
|
-
<OverlayTrigger placement="top" overlay={<Tooltip id={uuid()}>duplicate the sample first and then associate with it</Tooltip>}>
|
|
76
|
-
<InputGroup.Radio name={`dropS_${opt.value.el_id}`} checked={opt.value.cr_opt === 2} onChange={() => opt.onChange({ ...opt.value, cr_opt: 2 })} inline>Copy</InputGroup.Radio>
|
|
77
|
-
</OverlayTrigger>
|
|
78
|
-
</div>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
|
|
82
|
-
const defaultIcon = opt.type === 'drag_element' ? <span className="fa fa-link icon_generic_nav indicator" /> : <span className="icon-sample indicator" />;
|
|
83
|
-
const dragTarget = opt.isPreview === true ? <div className="target">{defaultIcon}</div> : <GenericElDropTarget opt={opt} onDrop={opt.onChange} />;
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<div>GenPropertiesDrop</div>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const GenDummy = () => (
|
|
91
|
-
<FormGroup className="text_generic_properties">
|
|
92
|
-
<FormControl type="text" className="dummy" readOnly />
|
|
93
|
-
</FormGroup>
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const GenPropertiesInputGroup = (opt) => {
|
|
97
|
-
const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
|
|
98
|
-
const fLab = e => <div key={uuid()} className="form-control g_input_group_label">{e.value}</div>;
|
|
99
|
-
const fTxt = e => <FormControl className="g_input_group" key={e.id} type={e.type} name={e.id} value={e.value} onChange={o => opt.onSubChange(o, e.id, opt.f_obj)} />;
|
|
100
|
-
const fUnit = e => (
|
|
101
|
-
<span key={`${e.id}_GenPropertiesInputGroup`} className="input-group" style={{ width: '100%' }}>
|
|
102
|
-
<FormControl key={e.id} type="number" name={e.id} value={e.value} onChange={o => opt.onSubChange(o, e.id, opt.f_obj)} min={1} />
|
|
103
|
-
<InputGroup.Button>
|
|
104
|
-
<Button active onClick={() => opt.onSubChange(e, e.id, opt.f_obj)} variant="success">
|
|
105
|
-
{genUnitSup(genUnit(e.option_layers, e.value_system).label) || ''}
|
|
106
|
-
</Button>
|
|
107
|
-
</InputGroup.Button>
|
|
108
|
-
</span>
|
|
109
|
-
);
|
|
110
|
-
const subs = opt.f_obj && opt.f_obj.sub_fields && opt.f_obj.sub_fields.map((e) => {
|
|
111
|
-
if (e.type === 'label') { return fLab(e); } if (e.type === 'system-defined') { return fUnit(e); } return fTxt(e);
|
|
112
|
-
});
|
|
113
|
-
return (
|
|
114
|
-
<div>GenPropertiesInputGroup</div>
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const GenPropertiesNumber = (opt) => {
|
|
119
|
-
let className = opt.isEditable ? 'editable' : 'readonly';
|
|
120
|
-
className = opt.isRequired && opt.isEditable ? 'required' : className;
|
|
121
|
-
const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
|
|
122
|
-
return (
|
|
123
|
-
<FormGroup>
|
|
124
|
-
{fieldHeader}
|
|
125
|
-
<FormControl
|
|
126
|
-
type="number"
|
|
127
|
-
value={opt.value}
|
|
128
|
-
onChange={opt.onChange}
|
|
129
|
-
className={className}
|
|
130
|
-
readOnly={opt.readOnly}
|
|
131
|
-
required={opt.isRequired}
|
|
132
|
-
placeholder={opt.placeholder}
|
|
133
|
-
min={1}
|
|
134
|
-
/>
|
|
135
|
-
</FormGroup>
|
|
136
|
-
);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const GenPropertiesSelect = (opt) => {
|
|
140
|
-
const options = opt.options.map(op => ({ value: op.key, name: op.key, label: op.label }));
|
|
141
|
-
let className = opt.isEditable ? 'select_generic_properties_editable' : 'select_generic_properties_readonly';
|
|
142
|
-
className = opt.isRequired && opt.isEditable ? 'select_generic_properties_required' : className;
|
|
143
|
-
className = `${className} status-select`;
|
|
144
|
-
const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
|
|
145
|
-
const val = options.find(o => o.value === opt.value) || null;
|
|
146
|
-
return (
|
|
147
|
-
<FormGroup>
|
|
148
|
-
{fieldHeader}
|
|
149
|
-
<Select
|
|
150
|
-
isClearable
|
|
151
|
-
menuContainerStyle={{ position: 'absolute' }}
|
|
152
|
-
name={opt.field}
|
|
153
|
-
multi={false}
|
|
154
|
-
options={options}
|
|
155
|
-
value={val}
|
|
156
|
-
onChange={opt.onChange}
|
|
157
|
-
className={className}
|
|
158
|
-
disabled={opt.readOnly}
|
|
159
|
-
/>
|
|
160
|
-
</FormGroup>
|
|
161
|
-
);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const GenPropertiesSystemDefined = (opt) => {
|
|
165
|
-
let className = opt.isEditable ? 'editable' : 'readonly';
|
|
166
|
-
className = opt.isRequired && opt.isEditable ? 'required' : className;
|
|
167
|
-
const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
|
|
168
|
-
return (
|
|
169
|
-
<FormGroup>
|
|
170
|
-
{fieldHeader}
|
|
171
|
-
<InputGroup>
|
|
172
|
-
<FormControl
|
|
173
|
-
type="number"
|
|
174
|
-
value={opt.value}
|
|
175
|
-
onChange={opt.onChange}
|
|
176
|
-
className={className}
|
|
177
|
-
readOnly={opt.readOnly}
|
|
178
|
-
required={opt.isRequired}
|
|
179
|
-
placeholder={opt.placeholder}
|
|
180
|
-
min={1}
|
|
181
|
-
/>
|
|
182
|
-
<Button disabled={opt.readOnly} active onClick={opt.onClick} variant="success">
|
|
183
|
-
{genUnitSup(genUnit(opt.option_layers, opt.value_system).label) || ''}
|
|
184
|
-
</Button>
|
|
185
|
-
</InputGroup>
|
|
186
|
-
</FormGroup>
|
|
187
|
-
);
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
const GenPropertiesTable = (opt) => {
|
|
191
|
-
const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
|
|
192
|
-
return (
|
|
193
|
-
<div>GenPropertiesTable</div>
|
|
194
|
-
);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const GenPropertiesText = (opt) => {
|
|
198
|
-
let className = opt.isEditable ? 'editable' : 'readonly';
|
|
199
|
-
className = opt.isRequired && opt.isEditable ? 'required' : className;
|
|
200
|
-
const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
|
|
201
|
-
return (
|
|
202
|
-
<FormGroup className="text_generic_properties">
|
|
203
|
-
{fieldHeader}
|
|
204
|
-
<FormControl
|
|
205
|
-
type="text"
|
|
206
|
-
value={opt.value}
|
|
207
|
-
onChange={opt.onChange}
|
|
208
|
-
className={className}
|
|
209
|
-
readOnly={opt.readOnly}
|
|
210
|
-
required={opt.isRequired}
|
|
211
|
-
placeholder={opt.placeholder}
|
|
212
|
-
/>
|
|
213
|
-
</FormGroup>
|
|
214
|
-
);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const GenPropertiesTextArea = (opt) => {
|
|
218
|
-
let className = opt.isEditable ? 'editable' : 'readonly';
|
|
219
|
-
className = opt.isRequired && opt.isEditable ? 'required' : className;
|
|
220
|
-
const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
|
|
221
|
-
return (
|
|
222
|
-
<div>GenPropertiesTextArea</div>
|
|
223
|
-
);
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
const GenTextFormula = (opt) => {
|
|
227
|
-
const { layers } = opt;
|
|
228
|
-
const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
|
|
229
|
-
const subs = [];
|
|
230
|
-
(opt.f_obj && opt.f_obj.text_sub_fields).map((e) => {
|
|
231
|
-
const { layer, field, separator } = e;
|
|
232
|
-
if (field && field !== '') {
|
|
233
|
-
if (field.includes('[@@]')) {
|
|
234
|
-
const fds = field.split('[@@]');
|
|
235
|
-
if (fds && fds.length === 2) {
|
|
236
|
-
const fdt = ((layers[layer] || {}).fields || []).find(f => f.field === fds[0] && f.type === 'table');
|
|
237
|
-
((fdt && fdt.sub_values) || []).forEach((svv) => {
|
|
238
|
-
if (svv && svv[fds[1]] && svv[fds[1]] !== '') { subs.push(svv[fds[1]]); subs.push(separator); }
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
} else {
|
|
242
|
-
const fd = ((layers[layer] || {}).fields || []).find(f => f.field === field);
|
|
243
|
-
if (fd && fd.value && fd.value !== '') { subs.push(fd.value); subs.push(separator); }
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return true;
|
|
247
|
-
});
|
|
248
|
-
return (
|
|
249
|
-
<div>GenTextFormula</div>
|
|
250
|
-
);
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
const renderListGroupItem = (opt, attachment) => {
|
|
254
|
-
const delBtn = (
|
|
255
|
-
<Button size="xsmall" id={attachment.uid} className="button-right" onClick={() => opt.onChange({ ...opt.value, action: 'd', uid: attachment.uid })}>
|
|
256
|
-
<i className="fa fa-times" aria-hidden="true" />
|
|
257
|
-
</Button>
|
|
258
|
-
);
|
|
259
|
-
const filename = attachment.aid ?
|
|
260
|
-
(<a onClick={() => downloadFile({ contents: `/api/v1/attachments/${attachment.aid}`, name: attachment.filename })} style={{ cursor: 'pointer' }}>{attachment.filename}</a>) : attachment.filename;
|
|
261
|
-
return (
|
|
262
|
-
<div>renderListGroupItem</div>
|
|
263
|
-
);
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const GenPropertiesUpload = (opt) => {
|
|
267
|
-
const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
|
|
268
|
-
const attachments = (opt.value && opt.value.files) || [];
|
|
269
|
-
if (opt.isSearchCriteria) return (<div>(This is an upload)</div>);
|
|
270
|
-
|
|
271
|
-
return (
|
|
272
|
-
<div>GenPropertiesUpload</div>
|
|
273
|
-
);
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
const GenWFNext = (opt) => {
|
|
277
|
-
const options = (opt.f_obj.wf_options || []).map((op) => {
|
|
278
|
-
const label = op.label.match(/(.*)\(.*\)/);
|
|
279
|
-
return ({ value: op.key, name: op.key, label: label[1] === '' ? label[0] : label[1] });
|
|
280
|
-
});
|
|
281
|
-
let className = opt.isEditable ? 'select_generic_properties_editable' : 'select_generic_properties_readonly';
|
|
282
|
-
className = opt.isRequired && opt.isEditable ? 'select_generic_properties_required' : className;
|
|
283
|
-
className = `${className} status-select`;
|
|
284
|
-
const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
|
|
285
|
-
const val = options.find(o => o.value === opt.value) || null;
|
|
286
|
-
return (
|
|
287
|
-
<FormGroup>
|
|
288
|
-
{fieldHeader}
|
|
289
|
-
<Select
|
|
290
|
-
menuContainerStyle={{ position: 'absolute' }}
|
|
291
|
-
name={opt.field}
|
|
292
|
-
multi={false}
|
|
293
|
-
options={options}
|
|
294
|
-
value={val}
|
|
295
|
-
onChange={opt.onChange}
|
|
296
|
-
className={className}
|
|
297
|
-
disabled={opt.readOnly}
|
|
298
|
-
/>
|
|
299
|
-
</FormGroup>
|
|
300
|
-
);
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
export {
|
|
304
|
-
GenPropertiesCalculate,
|
|
305
|
-
GenPropertiesCheckbox,
|
|
306
|
-
GenPropertiesDrop,
|
|
307
|
-
GenDummy,
|
|
308
|
-
GenTextFormula,
|
|
309
|
-
GenPropertiesInputGroup,
|
|
310
|
-
GenPropertiesNumber,
|
|
311
|
-
GenPropertiesSelect,
|
|
312
|
-
GenPropertiesSystemDefined,
|
|
313
|
-
GenPropertiesTable,
|
|
314
|
-
GenPropertiesText,
|
|
315
|
-
GenPropertiesTextArea,
|
|
316
|
-
GenPropertiesUpload,
|
|
317
|
-
GenWFNext
|
|
318
|
-
};
|