Skip to content

Commit

Permalink
Development (#129)
Browse files Browse the repository at this point in the history
* fix cannot change ref area (#124)

* fix shift ref cannot be removed (#128)
  • Loading branch information
baolanlequang authored Jul 25, 2023
1 parent b4eece1 commit c90768f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 35 deletions.
38 changes: 21 additions & 17 deletions dist/components/cmd_bar/04_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@ const styles = () => Object.assign({
txtIcon: {}
}, _common.commonStyle);
const iconSize = '16px';
const setFactor = (classes, isDisable, refFactor, setIntegrationFkrAct, curveIdx) => {
const onBlur = e => setIntegrationFkrAct({
factor: e.target.value,
curveIdx
});
const onChange = e => setIntegrationFkrAct({
const setFactor = (classes, isDisable, integrationSt, setIntegrationFkrAct, curveIdx) => {
const onFactorChanged = e => setIntegrationFkrAct({
factor: e.target.value,
curveIdx
});
Expand All @@ -50,30 +46,37 @@ const setFactor = (classes, isDisable, refFactor, setIntegrationFkrAct, curveIdx
});
}
};
let refFactor = 1.00;
const {
integrations
} = integrationSt;
if (integrations && curveIdx < integrations.length) {
const selectedIntegration = integrations[curveIdx];
refFactor = selectedIntegration.refFactor || 1.00;
}
return /*#__PURE__*/_react.default.createElement(_TextField.default, {
className: classes.field,
disabled: isDisable,
id: "intg-factor-name",
type: "number",
value: refFactor || 1.00,
value: refFactor,
margin: "none",
InputProps: {
className: (0, _classnames.default)(classes.txtInput, 'txtfield-sv-bar-input')
},
label: /*#__PURE__*/_react.default.createElement("span", {
className: (0, _classnames.default)(classes.txtLabel, 'txtfield-sv-bar-label')
}, "Ref Area"),
onChange: onChange,
onBlur: onBlur,
onKeyPress: onEnterPress,
onChange: onFactorChanged,
onBlur: onFactorChanged,
onKeyUp: onEnterPress,
variant: "outlined"
});
};
const iconColor = criteria => criteria ? '#fff' : '#000';
const Integration = _ref => {
let {
classes,
refFactorSt,
ignoreRef,
isDisableSt,
isFocusAddIntgSt,
Expand All @@ -82,7 +85,8 @@ const Integration = _ref => {
setUiSweepTypeAct,
setIntegrationFkrAct,
clearIntegrationAllAct,
curveSt
curveSt,
integrationSt
} = _ref;
const onSweepIntegtAdd = () => setUiSweepTypeAct(_list_ui.LIST_UI_SWEEP_TYPE.INTEGRATION_ADD);
const onSweepIntegtRm = () => setUiSweepTypeAct(_list_ui.LIST_UI_SWEEP_TYPE.INTEGRATION_RM);
Expand Down Expand Up @@ -138,7 +142,7 @@ const Integration = _ref => {
size: iconSize,
color: iconColor(isFocusSetRefSt || isDisableSt),
className: (0, _classnames.default)(classes.iconMdi, 'icon-sv-bar-refint')
})))), !ignoreRef ? setFactor(classes, isDisableSt, refFactorSt, setIntegrationFkrAct, curveIdx) : null, /*#__PURE__*/_react.default.createElement(_tri_btn.default, {
})))), !ignoreRef ? setFactor(classes, isDisableSt, integrationSt, setIntegrationFkrAct, curveIdx) : null, /*#__PURE__*/_react.default.createElement(_tri_btn.default, {
content: {
tp: 'Clear All Integration'
},
Expand All @@ -159,9 +163,9 @@ const mapStateToProps = (state, props) => (
isFocusAddIntgSt: state.ui.sweepType === _list_ui.LIST_UI_SWEEP_TYPE.INTEGRATION_ADD,
isFocusRmIntgSt: state.ui.sweepType === _list_ui.LIST_UI_SWEEP_TYPE.INTEGRATION_RM,
isFocusSetRefSt: state.ui.sweepType === _list_ui.LIST_UI_SWEEP_TYPE.INTEGRATION_SET_REF,
refFactorSt: state.integration.present.refFactor,
ignoreRef: _format.default.isHplcUvVisLayout(state.layout),
curveSt: state.curve
curveSt: state.curve,
integrationSt: state.integration.present
});
const mapDispatchToProps = dispatch => (0, _redux.bindActionCreators)({
setUiSweepTypeAct: _ui.setUiSweepType,
Expand All @@ -174,12 +178,12 @@ Integration.propTypes = {
isFocusAddIntgSt: _propTypes.default.bool.isRequired,
isFocusRmIntgSt: _propTypes.default.bool.isRequired,
isFocusSetRefSt: _propTypes.default.bool.isRequired,
refFactorSt: _propTypes.default.number.isRequired,
ignoreRef: _propTypes.default.bool.isRequired,
setUiSweepTypeAct: _propTypes.default.func.isRequired,
setIntegrationFkrAct: _propTypes.default.func.isRequired,
clearIntegrationAllAct: _propTypes.default.func.isRequired,
curveSt: _propTypes.default.object.isRequired
curveSt: _propTypes.default.object.isRequired,
integrationSt: _propTypes.default.object.isRequired
};
var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)((0, _styles.withStyles)(styles)(Integration));
exports.default = _default;
2 changes: 1 addition & 1 deletion dist/reducers/reducer_shift.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const resetShift = (state, action) => {
}
}
}
const newShift = Object.assign({}, selectedShift, {
const newShift = Object.assign({}, defaultEmptyShift, {
ref: resetRef(payload),
enable: resetEnable(payload)
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@complat/react-spectra-editor",
"version": "1.0.0-rc11",
"version": "1.0.0-rc12",
"description": "An editor to View and Edit Chemical Spectra data (NMR, IR and MS, CV, UIVIS, XRD).",
"repository": {
"type": "git",
Expand Down
33 changes: 18 additions & 15 deletions src/components/cmd_bar/04_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,9 @@ const styles = () => (
const iconSize = '16px';

const setFactor = (
classes, isDisable, refFactor, setIntegrationFkrAct, curveIdx,
classes, isDisable, integrationSt, setIntegrationFkrAct, curveIdx,
) => {
const onBlur = (e) => setIntegrationFkrAct({
factor: e.target.value,
curveIdx,
});
const onChange = (e) => setIntegrationFkrAct({
const onFactorChanged = (e) => setIntegrationFkrAct({
factor: e.target.value,
curveIdx,
});
Expand All @@ -61,21 +57,28 @@ const setFactor = (
}
};

let refFactor = 1.00;
const { integrations } = integrationSt;
if (integrations && curveIdx < integrations.length) {
const selectedIntegration = integrations[curveIdx];
refFactor = selectedIntegration.refFactor || 1.00;
}

return (
<TextField
className={classes.field}
disabled={isDisable}
id="intg-factor-name"
type="number"
value={refFactor || 1.00}
value={refFactor}
margin="none"
InputProps={{
className: classNames(classes.txtInput, 'txtfield-sv-bar-input'),
}}
label={<span className={classNames(classes.txtLabel, 'txtfield-sv-bar-label')}>Ref Area</span>}
onChange={onChange}
onBlur={onBlur}
onKeyPress={onEnterPress}
onChange={onFactorChanged}
onBlur={onFactorChanged}
onKeyUp={onEnterPress}
variant="outlined"
/>
);
Expand All @@ -84,10 +87,10 @@ const setFactor = (
const iconColor = (criteria) => (criteria ? '#fff' : '#000');

const Integration = ({
classes, refFactorSt, ignoreRef,
classes, ignoreRef,
isDisableSt, isFocusAddIntgSt, isFocusRmIntgSt, isFocusSetRefSt,
setUiSweepTypeAct, setIntegrationFkrAct, clearIntegrationAllAct,
curveSt,
curveSt, integrationSt,
}) => {
const onSweepIntegtAdd = () => setUiSweepTypeAct(LIST_UI_SWEEP_TYPE.INTEGRATION_ADD);
const onSweepIntegtRm = () => setUiSweepTypeAct(LIST_UI_SWEEP_TYPE.INTEGRATION_RM);
Expand Down Expand Up @@ -162,7 +165,7 @@ const Integration = ({
{
!ignoreRef
? setFactor(
classes, isDisableSt, refFactorSt, setIntegrationFkrAct, curveIdx,
classes, isDisableSt, integrationSt, setIntegrationFkrAct, curveIdx,
)
: null
}
Expand All @@ -188,9 +191,9 @@ const mapStateToProps = (state, props) => ( // eslint-disable-line
isFocusAddIntgSt: state.ui.sweepType === LIST_UI_SWEEP_TYPE.INTEGRATION_ADD,
isFocusRmIntgSt: state.ui.sweepType === LIST_UI_SWEEP_TYPE.INTEGRATION_RM,
isFocusSetRefSt: state.ui.sweepType === LIST_UI_SWEEP_TYPE.INTEGRATION_SET_REF,
refFactorSt: state.integration.present.refFactor,
ignoreRef: Format.isHplcUvVisLayout(state.layout),
curveSt: state.curve,
integrationSt: state.integration.present,
}
);

Expand All @@ -208,12 +211,12 @@ Integration.propTypes = {
isFocusAddIntgSt: PropTypes.bool.isRequired,
isFocusRmIntgSt: PropTypes.bool.isRequired,
isFocusSetRefSt: PropTypes.bool.isRequired,
refFactorSt: PropTypes.number.isRequired,
ignoreRef: PropTypes.bool.isRequired,
setUiSweepTypeAct: PropTypes.func.isRequired,
setIntegrationFkrAct: PropTypes.func.isRequired,
clearIntegrationAllAct: PropTypes.func.isRequired,
curveSt: PropTypes.object.isRequired,
integrationSt: PropTypes.object.isRequired,
};

export default connect(
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/reducer_shift.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const resetShift = (state, action) => {

const newShift = Object.assign(
{},
selectedShift,
defaultEmptyShift,
{
ref: resetRef(payload),
enable: resetEnable(payload),
Expand Down

0 comments on commit c90768f

Please sign in to comment.