aquariumbio / aquarium

The Aquarium Lab Operating System
http://klavinslab.org/aquaverse/
MIT License
58 stars 15 forks source link

v3: sample_types: [ save ] button not vetted correctly for new sample types #514

Open gnomicosuw opened 3 years ago

gnomicosuw commented 3 years ago

repro:

  1. go to http://localhost:3000

  2. login

  3. go to http://localhost:3000/sample_types/new result: the [ save ] button is grayed out

  4. type in a name only (or alternatively type in a description only) result: the [ save ] button is enabled expected result: the [ save ] button should be disabled

NOTES: a sample type requires a name a description.

the line of code: (see SampeTypeDefinitionForm.jsx => line 105) ==> setDisableSubmit(!(!!sampleTypeName || !!sampleTypeDescription));

should at minimum be ==> setDisableSubmit(!sampleTypeName || !sampleTypeDescription); // if either is 'false' then disable submit

HOWEVER, Note that the backend also removes leading and trailing spaces in the name and description, so we should also check ==> setDisableSubmit(!sampleTypeName.trim() || !sampleTypeDescription.trim()); // if the trimmed value of either is false then disable submit