From da38a21dd57f8f06f983df259000a22e4a92937b Mon Sep 17 00:00:00 2001 From: Marcus Oskarsson Date: Tue, 10 Oct 2023 11:50:57 +0200 Subject: [PATCH] Function was moved state no longer available Moved logic to DatacCollection and Characterisaiton where its used. --- ui/src/components/Tasks/Characterisation.js | 10 +++++++++- ui/src/components/Tasks/DataCollection.js | 10 +++++++++- ui/src/components/Tasks/fields.js | 7 ------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ui/src/components/Tasks/Characterisation.js b/ui/src/components/Tasks/Characterisation.js index 04cf6da7b..afc6f12ff 100644 --- a/ui/src/components/Tasks/Characterisation.js +++ b/ui/src/components/Tasks/Characterisation.js @@ -490,6 +490,14 @@ export default connect((state) => { const { type } = state.taskForm.taskData; const { limits } = state.taskForm.defaultParameters[type.toLowerCase()]; + const parameters = state.taskForm.taskData.parameters; + + if (parseFloat(parameters.osc_range) === 0) { + parameters.osc_range = + state.taskForm.defaultParameters[ + type.toLowerCase() + ].acq_parameters.osc_range; + } return { path: `${state.login.rootPath}/${subdir}`, @@ -504,7 +512,7 @@ export default connect((state) => { use_min_dose: selector(state, 'use_min_dose'), use_min_time: selector(state, 'use_min_time'), initialValues: { - ...state.taskForm.taskData.parameters, + ...parameters, beam_size: state.sampleview.currentAperture, resolution: state.taskForm.sampleIds.constructor !== Array diff --git a/ui/src/components/Tasks/DataCollection.js b/ui/src/components/Tasks/DataCollection.js index befce872a..622f90da8 100644 --- a/ui/src/components/Tasks/DataCollection.js +++ b/ui/src/components/Tasks/DataCollection.js @@ -365,6 +365,14 @@ export default connect((state) => { const { type } = state.taskForm.taskData; const { limits } = state.taskForm.defaultParameters[type.toLowerCase()]; + const parameters = state.taskForm.taskData.parameters; + + if (parseFloat(parameters.osc_range) === 0) { + parameters.osc_range = + state.taskForm.defaultParameters[ + type.toLowerCase() + ].acq_parameters.osc_range; + } return { path: `${state.login.rootPath}/${subdir}`, @@ -372,7 +380,7 @@ export default connect((state) => { acqParametersLimits: limits, beamline: state.beamline, initialValues: { - ...state.taskForm.taskData.parameters, + ...parameters, beam_size: state.sampleview.currentAperture, resolution: state.taskForm.sampleIds.constructor !== Array diff --git a/ui/src/components/Tasks/fields.js b/ui/src/components/Tasks/fields.js index 69a22b327..f9e7e7373 100644 --- a/ui/src/components/Tasks/fields.js +++ b/ui/src/components/Tasks/fields.js @@ -11,13 +11,6 @@ export function getLastUsedParameters(type, newParams) { const parameters = lastParameters === null ? newParams : JSON.parse(lastParameters); - if (parseFloat(parameters.osc_range) === 0) { - parameters.osc_range = - state.taskForm.defaultParameters[ - type.toLowerCase() - ].acq_parameters.osc_range; - } - return parameters; }