nmrium 0.24.0 → 0.26.0
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/lib/component/1d/IntegralResizable.js +13 -13
- package/lib/component/1d/multiAnalysis/AnalysisRange.js +30 -31
- package/lib/component/1d/multiplicityTree/MultiplicityTree.js +5 -5
- package/lib/component/1d/ranges/Range.js +24 -33
- package/lib/component/2d/zones/Signal.js +8 -8
- package/lib/component/2d/zones/Zone.js +3 -3
- package/lib/component/EventsTrackers/KeysListenerTracker.js +1 -1
- package/lib/component/NMRium.js +22 -29
- package/lib/component/assignment/AssignmentsContext.d.ts +35 -0
- package/lib/component/assignment/AssignmentsContext.js +83 -0
- package/lib/component/assignment/AssignmentsReducer.d.ts +32 -0
- package/lib/component/assignment/AssignmentsReducer.js +39 -0
- package/lib/component/assignment/actions/initAssignment.d.ts +5 -0
- package/lib/component/assignment/actions/initAssignment.js +62 -0
- package/lib/component/assignment/actions/removeAssignment.d.ts +16 -0
- package/lib/component/assignment/actions/removeAssignment.js +24 -0
- package/lib/component/assignment/actions/setActiveAssignment.d.ts +10 -0
- package/lib/component/assignment/actions/setActiveAssignment.js +8 -0
- package/lib/component/assignment/actions/toggleAssignment.d.ts +7 -0
- package/lib/component/assignment/actions/toggleAssignment.js +44 -0
- package/lib/component/assignment/index.d.ts +0 -18
- package/lib/component/assignment/index.js +12 -266
- package/lib/component/assignment/utilities/filterForIDsWithAssignment.d.ts +2 -0
- package/lib/component/assignment/utilities/filterForIDsWithAssignment.js +3 -0
- package/lib/component/context/GlobalContext.d.ts +12 -3
- package/lib/component/context/GlobalContext.js +1 -1
- package/lib/component/elements/ActionButtons.d.ts +10 -0
- package/lib/component/elements/ActionButtons.js +14 -0
- package/lib/component/elements/Button.d.ts +30 -5
- package/lib/component/elements/Button.js +151 -4
- package/lib/component/elements/ContextMenu.js +6 -6
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.d.ts +5 -1
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +38 -10
- package/lib/component/elements/ReactTable/ReactTable.d.ts +3 -1
- package/lib/component/elements/ReactTable/ReactTable.js +7 -2
- package/lib/component/elements/ReactTable/Style.d.ts +1 -3
- package/lib/component/elements/ReactTable/Style.js +1 -7
- package/lib/component/elements/ToolTip/ToolTip.js +3 -2
- package/lib/component/elements/resizer/DivResizer.d.ts +2 -0
- package/lib/component/elements/resizer/DivResizer.js +107 -0
- package/lib/component/elements/resizer/Resizer.d.ts +18 -0
- package/lib/component/elements/resizer/Resizer.js +12 -0
- package/lib/component/elements/resizer/SVGResizer.d.ts +2 -0
- package/lib/component/elements/resizer/SVGResizer.js +71 -0
- package/lib/component/elements/resizer/useDraggable.d.ts +19 -0
- package/lib/component/elements/resizer/useDraggable.js +52 -0
- package/lib/component/header/AutoPeakPickingOptionPanel.js +4 -15
- package/lib/component/header/BaseLineCorrectionPanel.js +2 -9
- package/lib/component/header/ManualPhaseCorrectionPanel.js +2 -9
- package/lib/component/header/RangesPickingOptionPanel.js +3 -16
- package/lib/component/header/ZeroFillingOptionsPanel.js +2 -9
- package/lib/component/header/Zones2DOptionPanel.js +3 -14
- package/lib/component/hooks/useExport.js +11 -9
- package/lib/component/loader/DropZone.js +1 -0
- package/lib/component/modal/AlignSpectraModal.js +2 -1
- package/lib/component/modal/ExportAsMatrixModal.js +2 -1
- package/lib/component/modal/ImportPublicationStringModal.js +2 -1
- package/lib/component/modal/LoadJCAMPModal.js +7 -6
- package/lib/component/modal/ModalStyle.js +4 -26
- package/lib/component/modal/MoleculeStructureEditorModal.js +2 -1
- package/lib/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
- package/lib/component/modal/PredictSpectraModal.js +2 -7
- package/lib/component/modal/SaveAsModal.d.ts +1 -1
- package/lib/component/modal/SaveAsModal.js +2 -1
- package/lib/component/modal/setting/FormattingTabContent.js +17 -11
- package/lib/component/modal/setting/GeneralSettings.js +3 -1
- package/lib/component/modal/setting/settingsValidation.d.ts +8 -0
- package/lib/component/modal/setting/settingsValidation.js +40 -0
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +6 -4
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +4 -3
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +13 -6
- package/lib/component/panels/AutomaticAssignment/useAutoAssignments.d.ts +10 -0
- package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +60 -0
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +11 -5
- package/lib/component/panels/MoleculesPanel/Utilities.d.ts +20 -11
- package/lib/component/panels/MoleculesPanel/Utilities.js +50 -68
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts +2 -2
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +55 -60
- package/lib/component/panels/RangesPanel/RangesHeader.js +2 -2
- package/lib/component/panels/RangesPanel/RangesPanel.js +1 -1
- package/lib/component/panels/RangesPanel/RangesTableRow.js +12 -11
- package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.d.ts +16 -9
- package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.js +2 -2
- package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.d.ts +2 -3
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +1 -1
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +5 -18
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.d.ts +5 -7
- package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.js +2 -2
- package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.d.ts +4 -8
- package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.d.ts +5 -9
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.js +4 -4
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumns.d.ts +4 -8
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +1 -1
- package/lib/component/panels/ZonesPanel/ZonesTableRow.d.ts +2 -1
- package/lib/component/panels/ZonesPanel/ZonesTableRow.js +20 -20
- package/lib/component/panels/header/SpectraAutomaticPickingButton.d.ts +2 -0
- package/lib/component/panels/header/SpectraAutomaticPickingButton.js +30 -0
- package/lib/component/panels/predictionPanel/PredictionOptions.js +2 -18
- package/lib/component/reducer/Reducer.d.ts +2 -0
- package/lib/component/reducer/Reducer.js +4 -1
- package/lib/component/reducer/actions/AssignmentsActions.d.ts +9 -0
- package/lib/component/reducer/actions/AssignmentsActions.js +18 -0
- package/lib/component/reducer/actions/LoadActions.d.ts +1 -1
- package/lib/component/reducer/actions/LoadActions.js +10 -5
- package/lib/component/reducer/preferencesReducer.d.ts +1 -8
- package/lib/component/reducer/preferencesReducer.js +16 -16
- package/lib/component/reducer/types/Types.d.ts +1 -0
- package/lib/component/reducer/types/Types.js +1 -0
- package/lib/component/utility/Export.d.ts +3 -3
- package/lib/component/utility/Export.js +10 -9
- package/lib/component/utility/FormatNumber.js +1 -1
- package/lib/component/workspaces/Workspace.d.ts +2 -4
- package/lib/component/workspaces/basic.js +8 -9
- package/lib/data/SpectraManager.js +23 -15
- package/lib/data/data1d/Data1DManager.d.ts +1 -1
- package/lib/data/data1d/Data1DManager.js +2 -1
- package/lib/data/data1d/Spectrum1D/toJSON.d.ts +2 -0
- package/lib/data/data1d/Spectrum1D/toJSON.js +1 -0
- package/lib/data/data1d/database.d.ts +1 -2
- package/lib/data/data1d/database.js +1 -1
- package/lib/data/data1d/filter1d/exclusionZones.d.ts +1 -4
- package/lib/data/data2d/Data2DManager.d.ts +1 -1
- package/lib/data/data2d/Data2DManager.js +2 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
- package/lib/data/data2d/Spectrum2D/toJSON.d.ts +2 -0
- package/lib/data/data2d/Spectrum2D/toJSON.js +1 -0
- package/lib/data/types/common/Source.d.ts +1 -0
- package/lib/data/types/data2d/Signal2DAxisData.d.ts +1 -1
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/IntegralResizable.js +12 -12
- package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +29 -30
- package/lib-cjs/component/1d/multiplicityTree/MultiplicityTree.js +6 -6
- package/lib-cjs/component/1d/ranges/Range.js +26 -35
- package/lib-cjs/component/2d/zones/Signal.js +9 -9
- package/lib-cjs/component/2d/zones/Zone.js +4 -4
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +2 -2
- package/lib-cjs/component/NMRium.js +22 -29
- package/lib-cjs/component/assignment/AssignmentsContext.js +88 -0
- package/lib-cjs/component/assignment/AssignmentsReducer.js +45 -0
- package/lib-cjs/component/assignment/actions/initAssignment.js +65 -0
- package/lib-cjs/component/assignment/actions/removeAssignment.js +29 -0
- package/lib-cjs/component/assignment/actions/setActiveAssignment.js +11 -0
- package/lib-cjs/component/assignment/actions/toggleAssignment.js +47 -0
- package/lib-cjs/component/assignment/index.js +15 -269
- package/lib-cjs/component/assignment/utilities/filterForIDsWithAssignment.js +7 -0
- package/lib-cjs/component/context/GlobalContext.js +1 -1
- package/lib-cjs/component/elements/ActionButtons.js +20 -0
- package/lib-cjs/component/elements/Button.js +150 -4
- package/lib-cjs/component/elements/ContextMenu.js +6 -6
- package/lib-cjs/component/elements/ReactTable/Elements/ReactTableRow.js +42 -14
- package/lib-cjs/component/elements/ReactTable/ReactTable.js +7 -2
- package/lib-cjs/component/elements/ReactTable/Style.js +1 -9
- package/lib-cjs/component/elements/ToolTip/ToolTip.js +3 -2
- package/lib-cjs/component/elements/resizer/DivResizer.js +113 -0
- package/lib-cjs/component/elements/resizer/Resizer.js +18 -0
- package/lib-cjs/component/elements/resizer/SVGResizer.js +77 -0
- package/lib-cjs/component/elements/resizer/useDraggable.js +55 -0
- package/lib-cjs/component/header/AutoPeakPickingOptionPanel.js +3 -14
- package/lib-cjs/component/header/BaseLineCorrectionPanel.js +2 -9
- package/lib-cjs/component/header/ManualPhaseCorrectionPanel.js +2 -9
- package/lib-cjs/component/header/RangesPickingOptionPanel.js +2 -15
- package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +2 -9
- package/lib-cjs/component/header/Zones2DOptionPanel.js +2 -13
- package/lib-cjs/component/hooks/useExport.js +11 -9
- package/lib-cjs/component/loader/DropZone.js +1 -0
- package/lib-cjs/component/modal/AlignSpectraModal.js +2 -1
- package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -1
- package/lib-cjs/component/modal/ImportPublicationStringModal.js +2 -1
- package/lib-cjs/component/modal/LoadJCAMPModal.js +7 -6
- package/lib-cjs/component/modal/ModalStyle.js +4 -26
- package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +5 -1
- package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
- package/lib-cjs/component/modal/PredictSpectraModal.js +2 -7
- package/lib-cjs/component/modal/SaveAsModal.js +2 -1
- package/lib-cjs/component/modal/setting/FormattingTabContent.js +17 -11
- package/lib-cjs/component/modal/setting/GeneralSettings.js +3 -1
- package/lib-cjs/component/modal/setting/settingsValidation.js +66 -0
- package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignment.js +6 -4
- package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +13 -6
- package/lib-cjs/component/panels/AutomaticAssignment/useAutoAssignments.js +67 -0
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +12 -6
- package/lib-cjs/component/panels/MoleculesPanel/Utilities.js +50 -68
- package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +55 -60
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +3 -3
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +15 -14
- package/lib-cjs/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/hooks/useEditRangeModal.js +2 -2
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -16
- package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.js +1 -1
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.js +4 -4
- package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/ZonesTableRow.js +21 -21
- package/lib-cjs/component/panels/header/SpectraAutomaticPickingButton.js +37 -0
- package/lib-cjs/component/panels/predictionPanel/PredictionOptions.js +2 -18
- package/lib-cjs/component/reducer/Reducer.js +4 -1
- package/lib-cjs/component/reducer/actions/AssignmentsActions.js +21 -0
- package/lib-cjs/component/reducer/actions/LoadActions.js +9 -4
- package/lib-cjs/component/reducer/preferencesReducer.js +16 -16
- package/lib-cjs/component/reducer/types/Types.js +2 -1
- package/lib-cjs/component/utility/Export.js +10 -9
- package/lib-cjs/component/utility/FormatNumber.js +1 -1
- package/lib-cjs/component/workspaces/basic.js +8 -9
- package/lib-cjs/data/SpectraManager.js +23 -15
- package/lib-cjs/data/data1d/Data1DManager.js +2 -1
- package/lib-cjs/data/data1d/Spectrum1D/toJSON.js +1 -0
- package/lib-cjs/data/data2d/Data2DManager.js +2 -1
- package/lib-cjs/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
- package/lib-cjs/data/data2d/Spectrum2D/toJSON.js +1 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +25 -26
- package/lib/component/1d/Resizable.d.ts +0 -12
- package/lib/component/1d/Resizable.js +0 -105
- package/lib-cjs/component/1d/Resizable.js +0 -110
|
@@ -1,35 +1,24 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { ConcatenationString } from '../../../data/utilities/Concatenation';
|
|
3
3
|
import checkModifierKeyActivated from '../../../data/utilities/checkModifierKeyActivated';
|
|
4
|
-
import {
|
|
4
|
+
import { useAssignment, useAssignmentData, } from '../../assignment/AssignmentsContext';
|
|
5
|
+
import { filterForIDsWithAssignment } from '../../assignment/utilities/filterForIDsWithAssignment';
|
|
5
6
|
import { useDispatch } from '../../context/DispatchContext';
|
|
6
7
|
import { useAlert } from '../../elements/popup/Alert';
|
|
7
8
|
import { HighlightedSource, useHighlightData } from '../../highlight';
|
|
8
9
|
import { DISPLAYER_MODE } from '../../reducer/core/Constants';
|
|
9
10
|
import { SET_DIAID_RANGE, SET_DIAID_ZONE } from '../../reducer/types/Types';
|
|
10
11
|
import { extractFromAtom, findDatumAndSignalIndex, getCurrentDiaIDsToHighlight, getHighlightsOnHover, toggleDiaIDs, } from './Utilities';
|
|
11
|
-
export default function useAtomAssignment({ displayerMode, activeTab, zones, ranges, }) {
|
|
12
|
+
export default function useAtomAssignment({ displayerMode, activeTab: nucleus, zones, ranges, }) {
|
|
12
13
|
const alert = useAlert();
|
|
13
14
|
const dispatch = useDispatch();
|
|
14
15
|
const highlightData = useHighlightData();
|
|
15
|
-
const
|
|
16
|
-
const activeAssignment = useAssignment(
|
|
17
|
-
?
|
|
16
|
+
const assignments = useAssignmentData();
|
|
17
|
+
const activeAssignment = useAssignment(assignments.data.activated
|
|
18
|
+
? assignments.data.activated.id
|
|
18
19
|
: ConcatenationString);
|
|
19
20
|
const [onAtomHoverHighlights, setOnAtomHoverHighlights] = useState([]);
|
|
20
21
|
const [onAtomHoverAction, setOnAtomHoverAction] = useState(null);
|
|
21
|
-
const [elements, setElements] = useState([]);
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (activeTab) {
|
|
24
|
-
const split = activeTab.split(',');
|
|
25
|
-
if (split.length === 1) {
|
|
26
|
-
setElements([activeTab.replace(/[0-9]/g, '')]);
|
|
27
|
-
}
|
|
28
|
-
else if (split.length === 2) {
|
|
29
|
-
setElements(split.map((nucleus) => nucleus.replace(/[0-9]/g, '')));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}, [activeTab]);
|
|
33
22
|
useEffect(() => {
|
|
34
23
|
if (onAtomHoverAction) {
|
|
35
24
|
if (onAtomHoverAction === 'show') {
|
|
@@ -63,23 +52,24 @@ export default function useAtomAssignment({ displayerMode, activeTab, zones, ran
|
|
|
63
52
|
}, [displayerMode, ranges, zones]);
|
|
64
53
|
const assignedDiaIDs = useMemo(() => {
|
|
65
54
|
const assignedDiaID = { x: [], y: [] };
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
const assignment = assignments.data.assignments;
|
|
56
|
+
for (let id in assignment) {
|
|
57
|
+
if (assignment[id].x) {
|
|
58
|
+
assignedDiaID.x.push(...assignment[id].x);
|
|
69
59
|
}
|
|
70
|
-
if (
|
|
71
|
-
assignedDiaID.y.push(...
|
|
60
|
+
if (assignment[id].y) {
|
|
61
|
+
assignedDiaID.y.push(...assignment[id].y);
|
|
72
62
|
}
|
|
73
63
|
}
|
|
74
64
|
// with its structure it's prepared for showing assigned IDs per axis
|
|
75
65
|
return assignedDiaID;
|
|
76
|
-
}, [
|
|
66
|
+
}, [assignments.data]);
|
|
77
67
|
// used for atom highlighting for now, until we would like to highlight atoms per axis separately
|
|
78
68
|
const assignedDiaIDsMerged = useMemo(() => assignedDiaIDs.x.concat(assignedDiaIDs.y), [assignedDiaIDs.x, assignedDiaIDs.y]);
|
|
79
69
|
const currentDiaIDsToHighlight = useMemo(() => {
|
|
80
70
|
let highlights = [];
|
|
81
71
|
highlightData.highlight.highlighted.forEach((highlightID) => {
|
|
82
|
-
const temp =
|
|
72
|
+
const temp = assignments.data.assignments[highlightID];
|
|
83
73
|
if (temp) {
|
|
84
74
|
const { datum } = findDatumAndSignalIndex(data, highlightID);
|
|
85
75
|
const type = highlightData.highlight.sourceData?.type;
|
|
@@ -87,56 +77,51 @@ export default function useAtomAssignment({ displayerMode, activeTab, zones, ran
|
|
|
87
77
|
(type === HighlightedSource.ZONE || type === HighlightedSource.RANGE)) {
|
|
88
78
|
// we are on range/zone level only, so add the belonging signal IDs to highlight too
|
|
89
79
|
highlights = highlights.concat(datum.signals
|
|
90
|
-
.map((signal) => filterForIDsWithAssignment(
|
|
91
|
-
0
|
|
80
|
+
.map((signal) => filterForIDsWithAssignment(assignments, [signal.id]).length > 0
|
|
92
81
|
? signal.diaIDs
|
|
93
82
|
: [])
|
|
94
83
|
.flat());
|
|
95
84
|
}
|
|
96
85
|
}
|
|
97
86
|
});
|
|
98
|
-
return getCurrentDiaIDsToHighlight(
|
|
99
|
-
}, [
|
|
87
|
+
return getCurrentDiaIDsToHighlight(assignments).concat(highlights);
|
|
88
|
+
}, [
|
|
89
|
+
assignments,
|
|
90
|
+
data,
|
|
91
|
+
highlightData.highlight.highlighted,
|
|
92
|
+
highlightData.highlight.sourceData?.type,
|
|
93
|
+
]);
|
|
100
94
|
const toggleAssignment = useCallback((diaID, atomInformation) => {
|
|
101
95
|
// a previous version of the code prevented to assign many time the same atom
|
|
102
96
|
// see revision cc13abc18f77b6787b923e3c4edaef51750d9e90
|
|
103
97
|
return toggleDiaIDs(diaID, atomInformation);
|
|
104
98
|
}, []);
|
|
105
99
|
const handleOnClickAtom = useCallback((atom, event) => {
|
|
106
|
-
if (!checkModifierKeyActivated(event)) {
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
if (!checkModifierKeyActivated(event) && activeAssignment.activated) {
|
|
101
|
+
const { axis, id } = activeAssignment.activated;
|
|
102
|
+
if (id && axis) {
|
|
103
|
+
const atomInformation = extractFromAtom(atom, nucleus, axis);
|
|
109
104
|
if (atomInformation.nbAtoms > 0) {
|
|
110
105
|
// save assignment in assignment hook
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
const dimension = displayerMode === DISPLAYER_MODE.DM_1D ? '1D' : '2D';
|
|
107
|
+
activeAssignment.toggle(atomInformation.oclIDs, dimension);
|
|
108
|
+
// console.log(activeAssignment);
|
|
114
109
|
// save assignment (diaIDs) in range/zone data
|
|
115
110
|
const { datum, signalIndex } = findDatumAndSignalIndex(data, activeAssignment.id);
|
|
116
111
|
if (datum) {
|
|
117
112
|
// determine the level of setting the diaIDs array (range vs. signal level) and save there
|
|
118
|
-
let
|
|
119
|
-
let nbAtoms = 0;
|
|
113
|
+
// let nbAtoms = 0;
|
|
120
114
|
// on range/zone level
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
[_diaID, nbAtoms] = toggleAssignment(datum[activeAssignment.activeAxis].diaIDs || [], atomInformation);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else if (datum.signals?.[signalIndex]) {
|
|
130
|
-
// on signal level
|
|
131
|
-
if (displayerMode === DISPLAYER_MODE.DM_1D) {
|
|
132
|
-
[_diaID, nbAtoms] = toggleAssignment(datum.signals[signalIndex].diaIDs || [], atomInformation);
|
|
115
|
+
if (displayerMode === DISPLAYER_MODE.DM_1D) {
|
|
116
|
+
const range = datum;
|
|
117
|
+
let _diaIDs = [];
|
|
118
|
+
if (signalIndex === undefined) {
|
|
119
|
+
_diaIDs = range?.diaIDs || [];
|
|
133
120
|
}
|
|
134
|
-
else
|
|
135
|
-
|
|
136
|
-
.diaIDs || [], atomInformation);
|
|
121
|
+
else {
|
|
122
|
+
_diaIDs = range?.signals[signalIndex]?.diaIDs || [];
|
|
137
123
|
}
|
|
138
|
-
|
|
139
|
-
if (displayerMode === DISPLAYER_MODE.DM_1D) {
|
|
124
|
+
const [_diaID, nbAtoms] = toggleAssignment(_diaIDs, atomInformation);
|
|
140
125
|
dispatch({
|
|
141
126
|
type: SET_DIAID_RANGE,
|
|
142
127
|
payload: {
|
|
@@ -147,20 +132,29 @@ export default function useAtomAssignment({ displayerMode, activeTab, zones, ran
|
|
|
147
132
|
},
|
|
148
133
|
});
|
|
149
134
|
}
|
|
150
|
-
else
|
|
135
|
+
else {
|
|
136
|
+
const zone = datum;
|
|
137
|
+
let _diaIDs = [];
|
|
138
|
+
if (signalIndex === undefined) {
|
|
139
|
+
_diaIDs = zone[axis]?.diaIDs || [];
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
_diaIDs = zone?.signals[signalIndex][axis]?.diaIDs || [];
|
|
143
|
+
}
|
|
144
|
+
const [_diaID, nbAtoms] = toggleAssignment(_diaIDs, atomInformation);
|
|
151
145
|
dispatch({
|
|
152
146
|
type: SET_DIAID_ZONE,
|
|
153
147
|
payload: {
|
|
154
148
|
nbAtoms,
|
|
155
149
|
zoneData: datum,
|
|
156
150
|
diaIDs: _diaID,
|
|
157
|
-
axis:
|
|
151
|
+
axis: axis,
|
|
158
152
|
signalIndex,
|
|
159
153
|
},
|
|
160
154
|
});
|
|
161
155
|
}
|
|
162
156
|
}
|
|
163
|
-
activeAssignment.
|
|
157
|
+
activeAssignment.setActive(axis);
|
|
164
158
|
}
|
|
165
159
|
else {
|
|
166
160
|
alert.info('Not assigned! Different atom type or no attached hydrogens found!');
|
|
@@ -173,15 +167,15 @@ export default function useAtomAssignment({ displayerMode, activeTab, zones, ran
|
|
|
173
167
|
data,
|
|
174
168
|
dispatch,
|
|
175
169
|
displayerMode,
|
|
176
|
-
|
|
170
|
+
nucleus,
|
|
177
171
|
toggleAssignment,
|
|
178
172
|
]);
|
|
179
173
|
const handleOnAtomHover = useCallback((atom) => {
|
|
180
|
-
const oclIDs = extractFromAtom(atom,
|
|
174
|
+
const { oclIDs } = extractFromAtom(atom, nucleus);
|
|
181
175
|
// on enter the atom
|
|
182
176
|
if (oclIDs.length > 0) {
|
|
183
177
|
// set all IDs to highlight when hovering over an atom from assignment data
|
|
184
|
-
const highlights = getHighlightsOnHover(
|
|
178
|
+
const highlights = getHighlightsOnHover(assignments, oclIDs, data);
|
|
185
179
|
setOnAtomHoverHighlights(highlights);
|
|
186
180
|
setOnAtomHoverAction('show');
|
|
187
181
|
}
|
|
@@ -189,7 +183,8 @@ export default function useAtomAssignment({ displayerMode, activeTab, zones, ran
|
|
|
189
183
|
// on leave the atom
|
|
190
184
|
setOnAtomHoverAction('hide');
|
|
191
185
|
}
|
|
192
|
-
|
|
186
|
+
// }
|
|
187
|
+
}, [assignments, data, nucleus]);
|
|
193
188
|
return {
|
|
194
189
|
handleOnAtomHover,
|
|
195
190
|
handleOnClickAtom,
|
|
@@ -7,7 +7,7 @@ import { rangesToACS } from 'nmr-processing';
|
|
|
7
7
|
import { useCallback } from 'react';
|
|
8
8
|
import { FaFileExport, FaUnlink, FaSitemap, FaChartBar } from 'react-icons/fa';
|
|
9
9
|
import { ImLink } from 'react-icons/im';
|
|
10
|
-
import { useAssignmentData } from '../../assignment';
|
|
10
|
+
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
11
11
|
import { useDispatch } from '../../context/DispatchContext';
|
|
12
12
|
import { usePreferences } from '../../context/PreferencesContext';
|
|
13
13
|
import Button from '../../elements/ButtonToolTip';
|
|
@@ -102,7 +102,7 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
102
102
|
}, [alert]);
|
|
103
103
|
const saveAsHTMLHandler = useCallback(() => {
|
|
104
104
|
const { originFrequency: observedFrequency, nucleus } = info;
|
|
105
|
-
const format = lodashGet(preferences.current, `formatting.
|
|
105
|
+
const format = lodashGet(preferences.current, `formatting.nuclei[${nucleus.toLowerCase()}]`, '0.0');
|
|
106
106
|
const nbDecimalDelta = getNumberOfDecimals(format.ppm);
|
|
107
107
|
const nbDecimalJ = getNumberOfDecimals(format.hz);
|
|
108
108
|
const result = rangesToACS(ranges.values, {
|
|
@@ -4,7 +4,7 @@ import { css } from '@emotion/react';
|
|
|
4
4
|
import lodashGet from 'lodash/get';
|
|
5
5
|
import { xGetFromToIndex } from 'ml-spectra-processing';
|
|
6
6
|
import { useCallback, useMemo, memo, useState, useRef } from 'react';
|
|
7
|
-
import { useAssignmentData } from '../../assignment';
|
|
7
|
+
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
8
8
|
import { useChartData } from '../../context/ChartContext';
|
|
9
9
|
import { useDispatch } from '../../context/DispatchContext';
|
|
10
10
|
import { usePreferences } from '../../context/PreferencesContext';
|
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import lodashGet from 'lodash/get';
|
|
5
5
|
import { useMemo, useCallback, useState } from 'react';
|
|
6
|
-
import {
|
|
6
|
+
import { useAssignment, useAssignmentData, } from '../../assignment/AssignmentsContext';
|
|
7
|
+
import { filterForIDsWithAssignment } from '../../assignment/utilities/filterForIDsWithAssignment';
|
|
7
8
|
import { HighlightedSource, useHighlight, useHighlightData, } from '../../highlight';
|
|
8
9
|
import { isColumnVisible } from '../extra/preferences/ColumnsHelper';
|
|
9
10
|
import AbsoluteColumn from './TableColumns/AbsoluteColumn';
|
|
@@ -24,10 +25,10 @@ const ConstantlyHighlightedRowStyle = css `
|
|
|
24
25
|
function RangesTableRow({ rowData, onUnlink, onContextMenu, preferences, }) {
|
|
25
26
|
const assignmentData = useAssignmentData();
|
|
26
27
|
const assignmentRange = useAssignment(rowData.id);
|
|
27
|
-
const highlightRange = useHighlight([assignmentRange.id].concat(assignmentRange.assigned
|
|
28
|
-
const highlightRangeAssignmentsColumn = useHighlight(assignmentRange.assigned
|
|
28
|
+
const highlightRange = useHighlight([assignmentRange.id].concat(assignmentRange.assigned?.x || []).concat(filterForIDsWithAssignment(assignmentData, rowData.signals.map((_signal) => _signal.id))), { type: HighlightedSource.RANGE });
|
|
29
|
+
const highlightRangeAssignmentsColumn = useHighlight(assignmentRange.assigned?.x || [], { type: HighlightedSource.RANGE });
|
|
29
30
|
const assignmentSignal = useAssignment(rowData.tableMetaInfo.id);
|
|
30
|
-
const highlightSignal = useHighlight([assignmentSignal.id].concat(assignmentSignal.assigned
|
|
31
|
+
const highlightSignal = useHighlight([assignmentSignal.id].concat(assignmentSignal.assigned?.x || []), { type: HighlightedSource.SIGNAL });
|
|
31
32
|
const highlightData = useHighlightData();
|
|
32
33
|
const [unlinkRangeButtonVisibility, showUnlinkRangeButton] = useState(false);
|
|
33
34
|
const [unlinkSignalButtonVisibility, showUnlinkSignalButton] = useState(false);
|
|
@@ -64,16 +65,16 @@ function RangesTableRow({ rowData, onUnlink, onContextMenu, preferences, }) {
|
|
|
64
65
|
}, [assignmentRange, assignmentSignal, onUnlink, rowData]);
|
|
65
66
|
const linkHandler = useCallback((e, assignment) => {
|
|
66
67
|
e.stopPropagation();
|
|
67
|
-
assignment.
|
|
68
|
+
assignment.setActive('x');
|
|
68
69
|
}, []);
|
|
69
70
|
const onHoverRange = useMemo(() => {
|
|
70
71
|
return {
|
|
71
72
|
onMouseEnter: () => {
|
|
72
|
-
assignmentRange.
|
|
73
|
+
assignmentRange.show('x');
|
|
73
74
|
highlightRange.show();
|
|
74
75
|
},
|
|
75
76
|
onMouseLeave: () => {
|
|
76
|
-
assignmentRange.
|
|
77
|
+
assignmentRange.hide();
|
|
77
78
|
highlightRange.hide();
|
|
78
79
|
},
|
|
79
80
|
};
|
|
@@ -81,11 +82,11 @@ function RangesTableRow({ rowData, onUnlink, onContextMenu, preferences, }) {
|
|
|
81
82
|
const onHoverRangeAssignmentsColumn = useMemo(() => {
|
|
82
83
|
return {
|
|
83
84
|
onMouseEnter: () => {
|
|
84
|
-
assignmentRange.
|
|
85
|
+
assignmentRange.show('x');
|
|
85
86
|
highlightRangeAssignmentsColumn.show();
|
|
86
87
|
},
|
|
87
88
|
onMouseLeave: () => {
|
|
88
|
-
assignmentRange.
|
|
89
|
+
assignmentRange.hide();
|
|
89
90
|
highlightRangeAssignmentsColumn.hide();
|
|
90
91
|
},
|
|
91
92
|
};
|
|
@@ -93,11 +94,11 @@ function RangesTableRow({ rowData, onUnlink, onContextMenu, preferences, }) {
|
|
|
93
94
|
const onHoverSignal = useMemo(() => {
|
|
94
95
|
return {
|
|
95
96
|
onMouseEnter: () => {
|
|
96
|
-
assignmentSignal.
|
|
97
|
+
assignmentSignal.show('x');
|
|
97
98
|
highlightSignal.show();
|
|
98
99
|
},
|
|
99
100
|
onMouseLeave: () => {
|
|
100
|
-
assignmentSignal.
|
|
101
|
+
assignmentSignal.hide();
|
|
101
102
|
highlightSignal.hide();
|
|
102
103
|
},
|
|
103
104
|
};
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import { AssignmentsData } from '../../../assignment/AssignmentsContext';
|
|
3
|
+
interface RangAssignmentColumnProps {
|
|
3
4
|
rowData: any;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
onHover: {
|
|
6
|
+
onMouseEnter: () => void;
|
|
7
|
+
onMouseLeave: () => void;
|
|
8
|
+
};
|
|
9
|
+
assignment: AssignmentsData;
|
|
10
|
+
highlight: {
|
|
11
|
+
isActive: boolean;
|
|
12
|
+
};
|
|
13
|
+
onUnlinkVisibilityChange?: (element: any) => void;
|
|
14
|
+
unlinkVisibility: boolean;
|
|
15
|
+
onLink?: (a: any, b: any) => void;
|
|
16
|
+
onUnlink?: (element: any, b: boolean) => void;
|
|
10
17
|
rowSpanTags: any;
|
|
11
|
-
onHover: any;
|
|
12
18
|
highlightData: any;
|
|
13
|
-
}
|
|
19
|
+
}
|
|
20
|
+
declare function RangeAssignmentsColumn({ rowData, assignment, highlight, onUnlinkVisibilityChange, unlinkVisibility, onLink, onUnlink, rowSpanTags, onHover, highlightData, }: RangAssignmentColumnProps): JSX.Element;
|
|
14
21
|
declare const _default: import("react").MemoExoticComponent<typeof RangeAssignmentsColumn>;
|
|
15
22
|
export default _default;
|
|
@@ -16,7 +16,7 @@ function RangeAssignmentsColumn({ rowData, assignment, highlight, onUnlinkVisibi
|
|
|
16
16
|
}, [onUnlinkVisibilityChange]);
|
|
17
17
|
const spanCss = useMemo(() => {
|
|
18
18
|
const flag = assignment.isActive ||
|
|
19
|
-
assignment.
|
|
19
|
+
assignment.isOver ||
|
|
20
20
|
(highlight.isActive &&
|
|
21
21
|
highlightData.highlight.sourceData?.type !== HighlightedSource.SIGNAL);
|
|
22
22
|
return flag
|
|
@@ -27,7 +27,7 @@ function RangeAssignmentsColumn({ rowData, assignment, highlight, onUnlinkVisibi
|
|
|
27
27
|
: { color: 'black', fontWeight: 'normal' };
|
|
28
28
|
}, [
|
|
29
29
|
assignment.isActive,
|
|
30
|
-
assignment.
|
|
30
|
+
assignment.isOver,
|
|
31
31
|
highlight.isActive,
|
|
32
32
|
highlightData.highlight.sourceData?.type,
|
|
33
33
|
]);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { AssignmentsData } from '../../../assignment/AssignmentsContext';
|
|
2
3
|
interface SignalAssignmentsColumnProps {
|
|
3
4
|
rowData: any;
|
|
4
5
|
onHover: {
|
|
5
6
|
onMouseEnter: () => void;
|
|
6
7
|
onMouseLeave: () => void;
|
|
7
8
|
};
|
|
8
|
-
assignment:
|
|
9
|
-
isActive: boolean;
|
|
10
|
-
};
|
|
9
|
+
assignment: AssignmentsData;
|
|
11
10
|
highlight: {
|
|
12
11
|
isActive: boolean;
|
|
13
12
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useMemo } from 'react';
|
|
3
|
-
import { useAssignmentData } from '../../../assignment';
|
|
3
|
+
import { useAssignmentData } from '../../../assignment/AssignmentsContext';
|
|
4
4
|
import { useDispatch } from '../../../context/DispatchContext';
|
|
5
5
|
import { useModal } from '../../../elements/popup/Modal';
|
|
6
6
|
import { positions, transitions } from '../../../elements/popup/options';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { SvgNmrSameTop, SvgNmrResetScale
|
|
2
|
+
import { SvgNmrSameTop, SvgNmrResetScale } from 'cheminfo-font';
|
|
3
3
|
import { memo, useCallback } from 'react';
|
|
4
4
|
import { FaCreativeCommonsSamplingPlus, FaEye, FaEyeSlash, } from 'react-icons/fa';
|
|
5
5
|
import { useChartData } from '../../context/ChartContext';
|
|
@@ -7,11 +7,11 @@ import { useDispatch } from '../../context/DispatchContext';
|
|
|
7
7
|
import Button from '../../elements/ButtonToolTip';
|
|
8
8
|
import { useAlert } from '../../elements/popup/Alert';
|
|
9
9
|
import { useModal } from '../../elements/popup/Modal';
|
|
10
|
-
import { useCheckToolsVisibility } from '../../hooks/useCheckToolsVisibility';
|
|
11
10
|
import { DISPLAYER_MODE } from '../../reducer/core/Constants';
|
|
12
|
-
import { ADD_MISSING_PROJECTION, CHANGE_VISIBILITY, DELETE_SPECTRA, RESET_SPECTRA_SCALE, SET_SPECTRA_SAME_TOP,
|
|
11
|
+
import { ADD_MISSING_PROJECTION, CHANGE_VISIBILITY, DELETE_SPECTRA, RESET_SPECTRA_SCALE, SET_SPECTRA_SAME_TOP, } from '../../reducer/types/Types';
|
|
13
12
|
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
14
|
-
|
|
13
|
+
import { SpectraAutomaticPickingButton } from '../header/SpectraAutomaticPickingButton';
|
|
14
|
+
function SpectraPanelHeaderInner({ data, activeSpectrum, activeTab, displayerMode, spectrums, }) {
|
|
15
15
|
const modal = useModal();
|
|
16
16
|
const alert = useAlert();
|
|
17
17
|
const dispatch = useDispatch();
|
|
@@ -65,29 +65,16 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeTab, displayerMod
|
|
|
65
65
|
const resetScaleHandler = useCallback(() => {
|
|
66
66
|
dispatch({ type: RESET_SPECTRA_SCALE });
|
|
67
67
|
}, [dispatch]);
|
|
68
|
-
|
|
69
|
-
void (async () => {
|
|
70
|
-
const hideLoading = await alert.showLoading('Automatic Ranges/Zones detection for all spectra in progress');
|
|
71
|
-
setTimeout(() => {
|
|
72
|
-
dispatch({ type: AUTO_RANGES_SPECTRA_PICKING });
|
|
73
|
-
dispatch({ type: AUTO_ZONES_SPECTRA_PICKING });
|
|
74
|
-
hideLoading();
|
|
75
|
-
}, 0);
|
|
76
|
-
})();
|
|
77
|
-
}, [dispatch, alert]);
|
|
78
|
-
return (_jsxs(DefaultPanelHeader, { onDelete: handleDelete, counter: spectrums?.length, deleteToolTip: "Delete all spectra", children: [_jsx(Button, { popupTitle: "Hide all spectra", onClick: hideAllSpectrumsHandler, children: _jsx(FaEyeSlash, {}) }), _jsx(Button, { popupTitle: "Show all spectra", onClick: showAllSpectrumsHandler, children: _jsx(FaEye, {}) }), activeSpectrum && activeTab && activeTab.split(',').length > 1 && (_jsx(Button, { popupTitle: "Add missing projection", onClick: addMissingProjectionHandler, children: _jsx(FaCreativeCommonsSamplingPlus, {}) })), displayerMode === DISPLAYER_MODE.DM_1D && spectrums.length > 1 && (_jsxs(_Fragment, { children: [_jsx(Button, { popupTitle: "Reset Scale", onClick: resetScaleHandler, children: _jsx(SvgNmrResetScale, {}) }), _jsx(Button, { popupTitle: "Same Top", onClick: setSameTopHandler, children: _jsx(SvgNmrSameTop, {}) })] })), data && data.length > 0 && isAutomaticPickingVisible && (_jsx(Button, { popupTitle: "Automatic Ranges/Zones picking for all spectra", onClick: automaticPickingHandler, children: _jsx(SvgNmrRangePicking, {}) }))] }));
|
|
68
|
+
return (_jsxs(DefaultPanelHeader, { onDelete: handleDelete, counter: spectrums?.length, deleteToolTip: "Delete all spectra", children: [_jsx(Button, { popupTitle: "Hide all spectra", onClick: hideAllSpectrumsHandler, children: _jsx(FaEyeSlash, {}) }), _jsx(Button, { popupTitle: "Show all spectra", onClick: showAllSpectrumsHandler, children: _jsx(FaEye, {}) }), activeSpectrum && activeTab && activeTab.split(',').length > 1 && (_jsx(Button, { popupTitle: "Add missing projection", onClick: addMissingProjectionHandler, children: _jsx(FaCreativeCommonsSamplingPlus, {}) })), displayerMode === DISPLAYER_MODE.DM_1D && spectrums.length > 1 && (_jsxs(_Fragment, { children: [_jsx(Button, { popupTitle: "Reset Scale", onClick: resetScaleHandler, children: _jsx(SvgNmrResetScale, {}) }), _jsx(Button, { popupTitle: "Same Top", onClick: setSameTopHandler, children: _jsx(SvgNmrSameTop, {}) })] })), _jsx(SpectraAutomaticPickingButton, {})] }));
|
|
79
69
|
}
|
|
80
70
|
const MemoizedSpectraPanelHeader = memo(SpectraPanelHeaderInner);
|
|
81
71
|
export default function SpectrumsTabs({ spectrums }) {
|
|
82
72
|
const { data, activeSpectrum, activeTab, displayerMode } = useChartData();
|
|
83
|
-
const isToolVisible = useCheckToolsVisibility();
|
|
84
|
-
const isAutomaticPickingVisible = isToolVisible('autoRangesTool');
|
|
85
73
|
return (_jsx(MemoizedSpectraPanelHeader, { ...{
|
|
86
74
|
data,
|
|
87
75
|
activeSpectrum,
|
|
88
76
|
activeTab,
|
|
89
77
|
displayerMode,
|
|
90
78
|
spectrums,
|
|
91
|
-
isAutomaticPickingVisible,
|
|
92
79
|
} }));
|
|
93
80
|
}
|
|
@@ -5,7 +5,7 @@ import { getLinkDelta, getLinkDim, } from 'nmr-correlation';
|
|
|
5
5
|
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
import { FaFlask, FaSlidersH } from 'react-icons/fa';
|
|
7
7
|
import { findRange, findSignal1D, findSignal2D, findSpectrum, findZone, } from '../../../data/utilities/FindUtilities';
|
|
8
|
-
import { useAssignmentData } from '../../assignment';
|
|
8
|
+
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
9
9
|
import { useChartData } from '../../context/ChartContext';
|
|
10
10
|
import { useDispatch } from '../../context/DispatchContext';
|
|
11
11
|
import Select from '../../elements/Select';
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Fragment, useCallback } from 'react';
|
|
3
3
|
import { FaEdit, FaRegTrashAlt, FaSearchPlus } from 'react-icons/fa';
|
|
4
4
|
import { SignalKinds } from '../../../../data/constants/SignalsKinds';
|
|
5
|
-
import { useAssignmentData } from '../../../assignment';
|
|
5
|
+
import { useAssignmentData } from '../../../assignment/AssignmentsContext';
|
|
6
6
|
import { useDispatch } from '../../../context/DispatchContext';
|
|
7
7
|
import Select from '../../../elements/Select';
|
|
8
8
|
import { useModal, positions, transitions, } from '../../../elements/popup/Modal';
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { AssignmentsData, Axis } from '../../../assignment/AssignmentsContext';
|
|
2
3
|
import { RowDataProps } from './ActionsColumn';
|
|
3
4
|
export interface SignalAssignmentsColumnProps {
|
|
4
5
|
rowData: RowDataProps;
|
|
5
|
-
assignment:
|
|
6
|
-
isActive: any;
|
|
7
|
-
activeAxis: any;
|
|
8
|
-
};
|
|
6
|
+
assignment: AssignmentsData;
|
|
9
7
|
highlight: {
|
|
10
8
|
isActive: any;
|
|
11
9
|
};
|
|
12
10
|
onHover: () => void;
|
|
13
|
-
onClick: (
|
|
14
|
-
onUnlink: (
|
|
11
|
+
onClick: (event: any, assignment: AssignmentsData, axis: Axis) => void;
|
|
12
|
+
onUnlink: (event: any, flag: boolean, axis: Axis) => void;
|
|
15
13
|
showUnlinkButton: boolean;
|
|
16
|
-
axis:
|
|
14
|
+
axis: Axis;
|
|
17
15
|
setShowUnlinkButton: (element: boolean) => void;
|
|
18
16
|
}
|
|
19
17
|
declare function SignalAssignmentsColumn({ rowData, assignment, highlight, onHover, onClick, onUnlink, axis, showUnlinkButton, setShowUnlinkButton, }: SignalAssignmentsColumnProps): JSX.Element;
|
|
@@ -3,7 +3,7 @@ import lodashGet from 'lodash/get';
|
|
|
3
3
|
import { FaMinusCircle } from 'react-icons/fa';
|
|
4
4
|
function SignalAssignmentsColumn({ rowData, assignment, highlight, onHover, onClick, onUnlink, axis, showUnlinkButton, setShowUnlinkButton, }) {
|
|
5
5
|
return (_jsx("td", { ...onHover, ...{ onClick: (e) => onClick(e, assignment, axis) }, style: highlight.isActive ||
|
|
6
|
-
(assignment.isActive && assignment.
|
|
6
|
+
(assignment.isActive && assignment.activated?.axis === axis)
|
|
7
7
|
? {
|
|
8
8
|
color: 'red',
|
|
9
9
|
fontWeight: 'bold',
|
|
@@ -13,6 +13,6 @@ function SignalAssignmentsColumn({ rowData, assignment, highlight, onHover, onCl
|
|
|
13
13
|
visibility: showUnlinkButton ? 'visible' : 'hidden',
|
|
14
14
|
padding: 0,
|
|
15
15
|
margin: 0,
|
|
16
|
-
}, onClick: (e) => onUnlink(e, false, axis), children: _jsx(FaMinusCircle, { color: "red" }) }) })] })) : assignment.isActive && assignment.
|
|
16
|
+
}, onClick: (e) => onUnlink(e, false, axis), children: _jsx(FaMinusCircle, { color: "red" }) }) })] })) : assignment.isActive && assignment.activated?.axis === axis ? ('0') : ('') }));
|
|
17
17
|
}
|
|
18
18
|
export default SignalAssignmentsColumn;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { AssignmentsData, Axis } from '../../../assignment/AssignmentsContext';
|
|
2
3
|
import { RowDataProps } from './ActionsColumn';
|
|
3
4
|
interface SignalAssignmentsColumnsProps {
|
|
4
5
|
rowData: RowDataProps;
|
|
@@ -8,20 +9,15 @@ interface SignalAssignmentsColumnsProps {
|
|
|
8
9
|
showUnlinkButtonSignalY: boolean;
|
|
9
10
|
setShowUnlinkButtonSignalX: (element: boolean) => void;
|
|
10
11
|
setShowUnlinkButtonSignalY: (element: boolean) => void;
|
|
11
|
-
onClick: (
|
|
12
|
-
onUnlink: (
|
|
12
|
+
onClick: (event: any, assignment: AssignmentsData, axis: Axis) => void;
|
|
13
|
+
onUnlink: (event: any, flag: boolean, axis: Axis) => void;
|
|
13
14
|
highlightSignalX: {
|
|
14
15
|
isActive: any;
|
|
15
16
|
};
|
|
16
17
|
highlightSignalY: {
|
|
17
18
|
isActive: any;
|
|
18
19
|
};
|
|
19
|
-
assignmentSignal:
|
|
20
|
-
activeAxis: any;
|
|
21
|
-
onHoverAxis: any;
|
|
22
|
-
isActive: boolean;
|
|
23
|
-
isOnHover: boolean;
|
|
24
|
-
};
|
|
20
|
+
assignmentSignal: AssignmentsData;
|
|
25
21
|
}
|
|
26
22
|
declare function SignalAssignmentsColumns({ rowData, assignmentSignal, onHoverSignalX, onHoverSignalY, showUnlinkButtonSignalX, showUnlinkButtonSignalY, setShowUnlinkButtonSignalX, setShowUnlinkButtonSignalY, onClick, onUnlink, highlightSignalX, highlightSignalY, }: SignalAssignmentsColumnsProps): JSX.Element;
|
|
27
23
|
export default SignalAssignmentsColumns;
|
|
@@ -2,6 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
3
|
import SignalAssignmentsColumn from './SignalAssignmentsColumn';
|
|
4
4
|
function SignalAssignmentsColumns({ rowData, assignmentSignal, onHoverSignalX, onHoverSignalY, showUnlinkButtonSignalX, showUnlinkButtonSignalY, setShowUnlinkButtonSignalX, setShowUnlinkButtonSignalY, onClick, onUnlink, highlightSignalX, highlightSignalY, }) {
|
|
5
|
-
return (_jsxs(Fragment, { children: [_jsx(SignalAssignmentsColumn, { rowData: rowData, assignment: assignmentSignal, highlight: highlightSignalX, onHover: onHoverSignalX, onClick: onClick, onUnlink: onUnlink, axis:
|
|
5
|
+
return (_jsxs(Fragment, { children: [_jsx(SignalAssignmentsColumn, { rowData: rowData, assignment: assignmentSignal, highlight: highlightSignalX, onHover: onHoverSignalX, onClick: onClick, onUnlink: onUnlink, axis: "x", showUnlinkButton: showUnlinkButtonSignalX, setShowUnlinkButton: setShowUnlinkButtonSignalX }), _jsx(SignalAssignmentsColumn, { rowData: rowData, assignment: assignmentSignal, highlight: highlightSignalY, onHover: onHoverSignalY, onClick: onClick, onUnlink: onUnlink, axis: "y", showUnlinkButton: showUnlinkButtonSignalY, setShowUnlinkButton: setShowUnlinkButtonSignalY })] }));
|
|
6
6
|
}
|
|
7
7
|
export default SignalAssignmentsColumns;
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
import { AssignmentsData, Axis } from '../../../assignment/AssignmentsContext';
|
|
2
3
|
import { RowDataProps } from './ActionsColumn';
|
|
3
4
|
export interface ZoneAssignmentColumnProps {
|
|
4
5
|
rowData: RowDataProps;
|
|
5
6
|
axis: any;
|
|
6
7
|
onHover: () => void;
|
|
7
|
-
onClick: (
|
|
8
|
-
onUnlink: (
|
|
8
|
+
onClick: (event: MouseEvent, assignment: AssignmentsData, axis: Axis) => void;
|
|
9
|
+
onUnlink: (event: MouseEvent, flag: boolean, axis: Axis) => void;
|
|
9
10
|
highlight: {
|
|
10
11
|
isActive: any;
|
|
11
12
|
};
|
|
12
|
-
assignment:
|
|
13
|
-
activeAxis: any;
|
|
14
|
-
onHoverAxis: any;
|
|
15
|
-
isActive: boolean;
|
|
16
|
-
isOnHover: boolean;
|
|
17
|
-
};
|
|
13
|
+
assignment: AssignmentsData;
|
|
18
14
|
showUnlinkButton: boolean;
|
|
19
15
|
setShowUnlinkButton: (element: boolean) => void;
|
|
20
16
|
rowSpanTags: any;
|
|
@@ -2,8 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import lodashGet from 'lodash/get';
|
|
3
3
|
import { FaMinusCircle } from 'react-icons/fa';
|
|
4
4
|
function ZoneAssignmentColumn({ rowData, assignment, highlight, onHover, onClick, onUnlink, axis, showUnlinkButton, setShowUnlinkButton, rowSpanTags, }) {
|
|
5
|
-
return (_jsx("td", { ...rowSpanTags, ...onHover, ...{ onClick: (e) => onClick(e, assignment, axis) }, children: lodashGet(rowData, `${axis}.nbAtoms`, 0) > 0 ? (lodashGet(rowData, `${axis}.diaIDs`, 0).length > 0 ? (_jsxs("div", { onMouseEnter: () => setShowUnlinkButton(true), onMouseLeave: () => setShowUnlinkButton(false), children: [rowData[axis].nbAtoms, " ", `(`, _jsx("span", { style: (assignment.isActive && assignment.
|
|
6
|
-
(assignment.
|
|
5
|
+
return (_jsx("td", { ...rowSpanTags, ...onHover, ...{ onClick: (e) => onClick(e, assignment, axis) }, children: lodashGet(rowData, `${axis}.nbAtoms`, 0) > 0 ? (lodashGet(rowData, `${axis}.diaIDs`, 0).length > 0 ? (_jsxs("div", { onMouseEnter: () => setShowUnlinkButton(true), onMouseLeave: () => setShowUnlinkButton(false), children: [rowData[axis].nbAtoms, " ", `(`, _jsx("span", { style: (assignment.isActive && assignment.activated?.axis === axis) ||
|
|
6
|
+
(assignment.isOver && assignment.highlighted?.axis === axis) ||
|
|
7
7
|
highlight.isActive
|
|
8
8
|
? {
|
|
9
9
|
color: 'red',
|
|
@@ -13,9 +13,9 @@ function ZoneAssignmentColumn({ rowData, assignment, highlight, onHover, onClick
|
|
|
13
13
|
visibility: showUnlinkButton ? 'visible' : 'hidden',
|
|
14
14
|
padding: 0,
|
|
15
15
|
margin: 0,
|
|
16
|
-
}, onClick: (e) => onUnlink(e, true, axis), children: _jsx(FaMinusCircle, { color: "red" }) }) })] })) : assignment.isActive && assignment.
|
|
16
|
+
}, onClick: (e) => onUnlink(e, true, axis), children: _jsx(FaMinusCircle, { color: "red" }) }) })] })) : assignment.isActive && assignment.activated?.axis === axis ? (_jsxs("div", { children: [`${lodashGet(rowData, `${axis}.nbAtoms`, '')} (`, _jsx("span", { style: {
|
|
17
17
|
color: 'red',
|
|
18
18
|
fontWeight: 'bold',
|
|
19
|
-
}, children: "0" }), ')'] })) : (rowData[axis].nbAtoms)) : assignment.isActive && assignment.
|
|
19
|
+
}, children: "0" }), ')'] })) : (rowData[axis].nbAtoms)) : assignment.isActive && assignment.activated?.axis === axis ? (_jsxs("div", { children: ['0 (', _jsx("span", { style: { color: 'red', fontWeight: 'bold' }, children: "0" }), ')'] })) : ('') }));
|
|
20
20
|
}
|
|
21
21
|
export default ZoneAssignmentColumn;
|