Skip to content

Commit

Permalink
refactor: prevent change the line boroadening if the exponential filt…
Browse files Browse the repository at this point in the history
…er not activated
  • Loading branch information
hamed-musallam committed Nov 20, 2024
1 parent eafab85 commit 9dbffb5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/component/header/SimpleApodizationOptionsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Checkbox } from '@blueprintjs/core';
import { memo } from 'react';

import type { ExtractFilterEntry } from '../../data/types/common/ExtractFilterEntry.js';
import { useToaster } from '../context/ToasterContext.js';
import ActionButtons from '../elements/ActionButtons.js';
import Label from '../elements/Label.js';
import { NumberInput2Controller } from '../elements/NumberInput2Controller.js';
Expand All @@ -18,6 +19,7 @@ interface ApodizationOptionsInnerPanelProps {
function ApodizationOptionsInnerPanel(
props: ApodizationOptionsInnerPanelProps,
) {
const toaster = useToaster();
const { formMethods, submitHandler, handleApplyFilter, handleCancelFilter } =
useSharedApodization(props.filter, { applyFilterOnload: true });

Expand All @@ -26,11 +28,24 @@ function ApodizationOptionsInnerPanel(
handleSubmit,
control,
formState: { isValid },
watch,
} = formMethods;

const isExponentialActive = watch('options.exponential.apply') || false;

const { onChange: onLivePreviewFieldChange, ...livePreviewFieldOptions } =
register('livePreview');

function handleClick() {
if (!isExponentialActive) {
toaster.show({
intent: 'danger',
message:
'Activate "Exponential" filter from the Processing panel first',
});
}
}

return (
<HeaderWrapper>
<Label title="Line broadening:" shortTitle="LB:" style={headerLabelStyle}>
Expand All @@ -43,6 +58,8 @@ function ApodizationOptionsInnerPanel(
onValueChange={() => {
submitHandler();
}}
readOnly={!isExponentialActive}
onClick={handleClick}
/>
</Label>

Expand Down

0 comments on commit 9dbffb5

Please sign in to comment.