Skip to content

Commit

Permalink
autoincrement
Browse files Browse the repository at this point in the history
  • Loading branch information
tytremblay committed Apr 2, 2024
1 parent 2a4d4c6 commit 47c0ef6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/2024/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"required": true,
"code": "matchNumber",
"preserveDataOnReset": true,
"autoIncrement": true
"autoIncrementOnReset": true
},
{
"title": "Robot",
Expand Down
2 changes: 1 addition & 1 deletion config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"multiSelect": {
"type": "boolean"
},
"autoIncrement": {
"autoIncrementOnReset": {
"type": "boolean"
}
},
Expand Down
1 change: 1 addition & 0 deletions src/components/inputs/BaseInputProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface InputProps {
defaultValue?: any;
min?: number;
max?: number;
autoIncrementOnReset?: boolean;
}

export type InputTypes =
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface NumberInputProps extends BaseInputProps {
export default function NumberInput(data: NumberInputProps) {
function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
e.preventDefault();
data.onChange(e.currentTarget.value);
data.onChange(Number(e.currentTarget.value));
}

return (
Expand Down
9 changes: 5 additions & 4 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ export function resetSections() {
.forEach(f => {
if (!f.preserveDataOnReset) {
f.value = f.defaultValue;
}
/*
else if (f.type === 'number' || f.type === 'counter') {
} else if (
(f.type === 'number' || f.type === 'counter') &&
f.autoIncrementOnReset
) {
f.value = f.value + 1;
}*/
}
}),
),
);
Expand Down

0 comments on commit 47c0ef6

Please sign in to comment.