Skip to content

Commit

Permalink
tweak to autoincrementer field settings
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Cassidy <[email protected]>
  • Loading branch information
stevecassidy committed Dec 9, 2024
1 parent e54149d commit 5a78c68
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 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 @@ -207,20 +206,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 +236,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

0 comments on commit 5a78c68

Please sign in to comment.