Anno editing label/category error states (#1048)

* anno error states

* label validation should not treat empty string as error

* disable Submit if no label or category entered

* edit category name error states

* flex start

* pr cleanup

* label name validation fixes

* PR comment responses
This commit is contained in:
Colin Megill
2019-11-21 19:08:29 -05:00
committed by GitHub
parent ee62dd355f
commit c2ededfc62
3 changed files with 227 additions and 67 deletions
@@ -64,9 +64,11 @@ class Categories extends React.Component {
categoryNameError = name => {
/*
return false if this is a LEGAL/acceptable category name,
return false if this is a LEGAL/acceptable category name or NULL/empty string,
or return an error type.
*/
if (!name) return false;
const { categoricalSelection } = this.props;
const allCategoryNames = Object.keys(categoricalSelection);
@@ -83,6 +85,7 @@ class Categories extends React.Component {
categoryNameErrorMessage = name => {
const err = this.categoryNameError(name);
if (err === false) return null;
if (err === "duplicate") {
return (
<span>
@@ -167,7 +170,6 @@ class Categories extends React.Component {
autoFocus
value={newCategoryText}
intent={
newCategoryText &&
this.categoryNameError(newCategoryText)
? "warning"
: "none"
@@ -180,11 +182,9 @@ class Categories extends React.Component {
<p
style={{
marginTop: 7,
visibility:
newCategoryText &&
this.categoryNameError(newCategoryText)
? "visible"
: "hidden",
visibility: this.categoryNameError(newCategoryText)
? "visible"
: "hidden",
color: Colors.ORANGE3
}}
>
@@ -227,7 +227,10 @@ class Categories extends React.Component {
</Tooltip>
<Button
onClick={this.handleCreateUserAnno}
disabled={this.categoryNameError(newCategoryText)}
disabled={
!newCategoryText ||
this.categoryNameError(newCategoryText)
}
intent="primary"
type="submit"
>