Skip to content

Commit

Permalink
Minor fixes before making an official V1.0 release (#1251)
Browse files Browse the repository at this point in the history
# Minor fixes before making an official V1.0 release

## JIRA Ticket

None

## Description

Just fixing up any minor things before finalising the 1.0.0 release.

## Proposed Changes

- Auto-incrementer field editor was too strict in checking values and
didn't allow deleting of current value
- Auto-incrementer sometimes didn't get the existing ranges, I think
because of the initial value in useQuery

## How to Test

Check that all of the above are working well on mobile.

## Checklist

- [x] I have confirmed all commits have been signed.
- [x] I have added JSDoc style comments to any new functions or classes.
- [x] Relevant documentation such as READMEs, guides, and class comments
are updated.
  • Loading branch information
stevecassidy authored Dec 11, 2024
2 parents 7e50400 + 9299089 commit 00f9de5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
27 changes: 19 additions & 8 deletions app/src/gui/components/autoincrement/edit-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export const AutoIncrementEditForm = ({
);
return ranges;
},
initialData: [],
enabled: true,
});

Expand Down Expand Up @@ -112,9 +111,11 @@ export const AutoIncrementEditForm = ({

const updateRange = (index: number) => {
return (range: LocalAutoIncrementRange) => {
const rangesCopy = [...ranges];
rangesCopy[index] = range;
updateRanges(rangesCopy);
if (ranges) {
const rangesCopy = [...ranges];
rangesCopy[index] = range;
updateRanges(rangesCopy);
}
};
};

Expand Down Expand Up @@ -207,20 +208,25 @@ type IncremenenterRangeProps = {
* @param props component props
*/
const IncrementerRange = (props: IncremenenterRangeProps) => {
const [start, setStart] = useState(props.range.start);
const [stop, setStop] = useState(props.range.stop);
const [start, setStart] = useState<number | string>(props.range.start);
const [stop, setStop] = useState<number | string>(props.range.stop);

const handleStartChange = (event: any) => {
if (event.target.value === '') {
// set start but don't update the range
setStart('');
return;
}
const newStart = parseInt(event.target.value);
if (newStart >= 0) {
setStart(newStart);
if (newStart >= props.range.stop) {
// initialise a range of 100 if they enter a start > stop
setStop(newStart + 100);
setStop(newStart + 99);
props.updateRange({
...props.range,
start: newStart,
stop: newStart + 100,
stop: newStart + 99,
});
} else {
props.updateRange({
Expand All @@ -232,6 +238,11 @@ const IncrementerRange = (props: IncremenenterRangeProps) => {
};

const handleStopChange = (event: any) => {
if (event.target.value === '') {
// set stop but don't update the range
setStop('');
return;
}
const newStop = parseInt(event.target.value);
if (newStop > props.range.start) {
setStop(newStop);
Expand Down
1 change: 0 additions & 1 deletion app/src/gui/components/record/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
upsertFAIMSData,
} from '@faims3/data-model';
import {NavigateFunction} from 'react-router-dom';
import {DEBUG_APP} from '../../../buildconfig';
import * as ROUTES from '../../../constants/routes';
import {store} from '../../../context/store';
import {getFieldPersistentData} from '../../../local-data/field-persistent';
Expand Down

0 comments on commit 00f9de5

Please sign in to comment.