diff --git a/dist/components/cmd_bar/05_multiplicity.js b/dist/components/cmd_bar/05_multiplicity.js index 55f94a13..7c8ef28d 100644 --- a/dist/components/cmd_bar/05_multiplicity.js +++ b/dist/components/cmd_bar/05_multiplicity.js @@ -110,7 +110,7 @@ const mapStateToProps = (state, props) => ( disableRmMpySt: _cfg.default.btnCmdMpy(state.layout), isFocusAddPeakSt: state.ui.sweepType === _list_ui.LIST_UI_SWEEP_TYPE.MULTIPLICITY_PEAK_ADD, isFocusRmPeakSt: state.ui.sweepType === _list_ui.LIST_UI_SWEEP_TYPE.MULTIPLICITY_PEAK_RM, - disableMpyPeakSt: _cfg.default.btnCmdMpyPeak(state.layout, state.multiplicity.present), + disableMpyPeakSt: _cfg.default.btnCmdMpyPeak(state.layout, state.multiplicity.present, state.curve.curveIdx), curveSt: state.curve }); const mapDispatchToProps = dispatch => (0, _redux.bindActionCreators)({ diff --git a/dist/helpers/cfg.js b/dist/helpers/cfg.js index cacd5484..2d6bacb0 100644 --- a/dist/helpers/cfg.js +++ b/dist/helpers/cfg.js @@ -14,11 +14,20 @@ const btnCmdSetRef = layoutSt => !_format.default.isNmrLayout(layoutSt); const btnCmdIntg = layoutSt => !(_format.default.isNmrLayout(layoutSt) || _format.default.isHplcUvVisLayout(layoutSt)); // eslint-disable-line const btnCmdMpy = layoutSt => !_format.default.isNmrLayout(layoutSt); -const btnCmdMpyPeak = (layoutSt, mpySt) => { +const btnCmdMpyPeak = function (layoutSt, mpySt) { + let curveIdx = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; const { - smExtext + multiplicities } = mpySt; - return btnCmdMpy(layoutSt) || !smExtext; + let smExtextVal = false; + if (multiplicities) { + const selectedMultiplicity = multiplicities[curveIdx]; + const { + smExtext + } = selectedMultiplicity; + smExtextVal = smExtext; + } + return btnCmdMpy(layoutSt) || !smExtextVal; }; const hideCmdThres = layoutSt => _format.default.isMsLayout(layoutSt); const btnCmdThres = thresVal => !thresVal; diff --git a/dist/sagas/saga_multiplicity.js b/dist/sagas/saga_multiplicity.js index 6c1ef7c1..f3ff04fe 100644 --- a/dist/sagas/saga_multiplicity.js +++ b/dist/sagas/saga_multiplicity.js @@ -142,7 +142,7 @@ function* addUiPeakToStack(action) { const newMultiplicities = [...multiplicities]; newMultiplicities[curveIdx] = newSelectedMulti; const payload = Object.assign({}, mpySt, { - multiplicities: newSelectedMulti + multiplicities: newMultiplicities }); // eslint-disable-line yield (0, _effects.put)({ diff --git a/package.json b/package.json index 29207c15..ffaed4f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@complat/react-spectra-editor", - "version": "1.0.0-rc19", + "version": "1.0.0-rc20", "description": "An editor to View and Edit Chemical Spectra data (NMR, IR and MS, CV, UIVIS, XRD).", "repository": { "type": "git", diff --git a/src/__tests__/units/helpers/cfg.test.tsx b/src/__tests__/units/helpers/cfg.test.tsx index 299cb4b9..c328f62d 100644 --- a/src/__tests__/units/helpers/cfg.test.tsx +++ b/src/__tests__/units/helpers/cfg.test.tsx @@ -143,7 +143,7 @@ describe('Test Config helper', () => { }) describe('Add and remove multiplicity peak button', () => { - const mpySt = {smExtext: true} + const mpySt = {"selectedIdx":0,"multiplicities":[{"stack":[{"js":[1.7728561010112571],"mpyType":"quint","xExtent":{"xL":6.18942577177587,"xU":6.559753568068116},"yExtent":{"yL":20286604,"yU":61276677},"peaks":[{"x":6.422977415781519,"y":20286604},{"x":6.418393960239213,"y":44041878},{"x":6.4138105046969045,"y":61276677},{"x":6.409227049154596,"y":44393311},{"x":6.404949157315109,"y":21143741}]},{"js":[0.6724626590039406,2.0173879770127314,37.41337702824512],"mpyType":"ddd","xExtent":{"xL":7.788569415813955,"xU":8.31039593286588},"yExtent":{"yL":3675585,"yU":4004335},"peaks":[{"x":8.101133271671815,"y":3689696},{"x":8.099605453157713,"y":3869072},{"x":8.095938688723866,"y":3880744},{"x":8.094410870209764,"y":3675585},{"x":8.007630778608736,"y":3706408},{"x":8.005797396391813,"y":4004335},{"x":8.002741759363607,"y":3915159},{"x":8.000908377146684,"y":3706677}]},{"js":[],"mpyType":"s","xExtent":{"xL":14.706972135774421,"xU":15.195132390935767},"yExtent":{"yL":16276328,"yU":16276328},"peaks":[{"x":14.948510288176845,"y":16276328}]},{"peaks":[{"x":11.440944543500096,"y":26450300},{"x":11.420777339113942,"y":28797799},{"x":11.298857421688554,"y":34032080},{"x":11.280523599519324,"y":24725861},{"x":11.27838465359958,"y":40013064},{"x":11.190687870890091,"y":37931375},{"x":11.184576596833681,"y":38611682},{"x":11.028739108395214,"y":14764010},{"x":11.02568347136701,"y":15806310},{"x":11.011016413631625,"y":22918651},{"x":11.00826634030624,"y":31715857},{"x":11.005821830683676,"y":16826172},{"x":10.990849209245471,"y":19172963},{"x":10.988099135920086,"y":18223303},{"x":10.904069117644443,"y":35864429}],"xExtent":{"xL":8.630543435939886,"xU":12.328690131870278},"yExtent":{"yL":-16852818.03512673,"yU":72852232.91555789},"mpyType":"m","js":[]}],"shift":0,"smExtext":{"xL":8.630543435939886,"xU":12.328690131870278}}]} beforeEach(()=> { layoutShouldView = [LIST_LAYOUT.C13, LIST_LAYOUT.H1, LIST_LAYOUT.F19, LIST_LAYOUT.P31, LIST_LAYOUT.N15, LIST_LAYOUT.Si29] @@ -162,14 +162,14 @@ describe('Test Config helper', () => { it('Show add and remove multiplicity peak button when wrong layout but has smsExtent value', () => { layoutShouldHide.forEach(layout => { - const isShow = Config.btnCmdMpyPeak(layout, mpySt) + const isShow = Config.btnCmdMpyPeak(layout, mpySt, 0) expect(isShow).toEqual(true) }) }) it('Hide add and remove multiplicity peak button', () => { layoutShouldView.forEach(layout => { - const isShow = Config.btnCmdMpyPeak(layout, mpySt) + const isShow = Config.btnCmdMpyPeak(layout, mpySt, 0) expect(isShow).toEqual(false) }) }) diff --git a/src/components/cmd_bar/05_multiplicity.js b/src/components/cmd_bar/05_multiplicity.js index 3e60745d..adadf7b0 100644 --- a/src/components/cmd_bar/05_multiplicity.js +++ b/src/components/cmd_bar/05_multiplicity.js @@ -128,7 +128,7 @@ const mapStateToProps = (state, props) => ( // eslint-disable-line disableRmMpySt: Cfg.btnCmdMpy(state.layout), isFocusAddPeakSt: state.ui.sweepType === LIST_UI_SWEEP_TYPE.MULTIPLICITY_PEAK_ADD, isFocusRmPeakSt: state.ui.sweepType === LIST_UI_SWEEP_TYPE.MULTIPLICITY_PEAK_RM, - disableMpyPeakSt: Cfg.btnCmdMpyPeak(state.layout, state.multiplicity.present), + disableMpyPeakSt: Cfg.btnCmdMpyPeak(state.layout, state.multiplicity.present, state.curve.curveIdx), curveSt: state.curve, } ); diff --git a/src/helpers/cfg.js b/src/helpers/cfg.js index c10dcc59..91c34191 100644 --- a/src/helpers/cfg.js +++ b/src/helpers/cfg.js @@ -28,9 +28,15 @@ const btnCmdIntg = (layoutSt) => !(Format.isNmrLayout(layoutSt)|| Format.isHplcU const btnCmdMpy = (layoutSt) => !Format.isNmrLayout(layoutSt); -const btnCmdMpyPeak = (layoutSt, mpySt) => { - const { smExtext } = mpySt; - return btnCmdMpy(layoutSt) || !smExtext; +const btnCmdMpyPeak = (layoutSt, mpySt, curveIdx = 0) => { + const { multiplicities } = mpySt; + let smExtextVal = false; + if (multiplicities) { + const selectedMultiplicity = multiplicities[curveIdx]; + const { smExtext } = selectedMultiplicity; + smExtextVal = smExtext; + } + return btnCmdMpy(layoutSt) || !smExtextVal; }; const hideCmdThres = (layoutSt) => Format.isMsLayout(layoutSt); diff --git a/src/sagas/saga_multiplicity.js b/src/sagas/saga_multiplicity.js index f863c6b6..d70a0446 100644 --- a/src/sagas/saga_multiplicity.js +++ b/src/sagas/saga_multiplicity.js @@ -106,11 +106,11 @@ function* addUiPeakToStack(action) { }); if (isDuplicate) return; - const newSelectedMulti = Object.assign({}, selectedMulti,{ stack: newStack }); // eslint-disable-line + const newSelectedMulti = Object.assign({}, selectedMulti, { stack: newStack }); // eslint-disable-line const newMultiplicities = [...multiplicities]; newMultiplicities[curveIdx] = newSelectedMulti; - const payload = Object.assign({}, mpySt, { multiplicities: newSelectedMulti }); // eslint-disable-line + const payload = Object.assign({}, mpySt, { multiplicities: newMultiplicities }); // eslint-disable-line yield put({ type: MULTIPLICITY.PEAK_ADD_BY_UI_RDC,