Skip to content

Commit

Permalink
Improve Auto-incrementers (#1241)
Browse files Browse the repository at this point in the history
# Fix: Improve Auto-incrementers

## JIRA Ticket

None

## Description

Auto increment fields are used to generate human readable IDs for
records. There
was a bug that caused them to not work if the initial value of the field
was
set to "" as it was in the designer. 

These fields require that a range of numbers is set for the device
before records can
be properly created. The past behaviour was to notice when they weren't
set up but
not really help the user set them.

## Proposed Changes

- Deals with the case when the initial value is ""
- Turn the range setting form into a popup dialog
- trigger the popup if a user tries to create a record without the
ranges being set

## How to Test

Open a notebook with an auto increment field configured, eg. [Campus
Survey](https://github.com/FAIMS/FAIMS3-Notebook-Campus-Survey-Demo).
Try to create
a record after activating the notebook, you should see a popup to allow
you to set
the ranges.

Same popup is accessible via the Settings tab on the notebook.


## 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 5, 2024
2 parents 2cafedd + 30e1d90 commit 1404857
Show file tree
Hide file tree
Showing 6 changed files with 399 additions and 482 deletions.
10 changes: 6 additions & 4 deletions app/src/gui/components/autoincrement/edit-form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@
*/

import {fireEvent, render, screen, waitFor} from '@testing-library/react';
import BasicAutoIncrementer from './edit-form';
import {AutoIncrementEditForm} from './edit-form';
import {expect, describe, it} from 'vitest';

const props = {
project_id: '',
form_id: '',
field_id: '',
label: '',
open: true,
handleClose: () => {},
};

describe('Check edit-form component', () => {
it('Check add btn', async () => {
render(<BasicAutoIncrementer {...props} />);
render(<AutoIncrementEditForm {...props} />);
const addRangeBtn = screen.getByTestId('addNewRangeBtn');

await waitFor(() => {
Expand All @@ -45,7 +47,7 @@ describe('Check edit-form component', () => {
});
});
it('Check remove btn', async () => {
render(<BasicAutoIncrementer {...props} />);
render(<AutoIncrementEditForm {...props} />);
const addRangeBtn = screen.getByTestId('addNewRangeBtn');

await waitFor(() => {
Expand All @@ -67,7 +69,7 @@ describe('Check edit-form component', () => {
});
});
it('Check adding range start and stop fields', async () => {
render(<BasicAutoIncrementer {...props} />);
render(<AutoIncrementEditForm {...props} />);
const addRangeBtn = screen.getByTestId('addNewRangeBtn');

await waitFor(() => {
Expand Down
Loading

0 comments on commit 1404857

Please sign in to comment.