enter submits modals (#945)

This commit is contained in:
Colin Megill
2019-09-25 15:18:33 -07:00
committed by GitHub
parent 32feb36172
commit e64f4f06fb
2 changed files with 118 additions and 91 deletions
@@ -76,7 +76,9 @@ class Categories extends React.Component {
> >
{/* READ ONLY CATEGORICAL FIELDS */} {/* READ ONLY CATEGORICAL FIELDS */}
{/* this is duplicative but flat, could be abstracted */} {/* this is duplicative but flat, could be abstracted */}
{_.map(allCategoryNames, catName => {_.map(
allCategoryNames,
catName =>
!schema.annotations.obsByName[catName].writable ? ( !schema.annotations.obsByName[catName].writable ? (
<Category <Category
key={catName} key={catName}
@@ -87,7 +89,9 @@ class Categories extends React.Component {
) : null ) : null
)} )}
{/* WRITEABLE FIELDS */} {/* WRITEABLE FIELDS */}
{_.map(allCategoryNames, catName => {_.map(
allCategoryNames,
catName =>
schema.annotations.obsByName[catName].writable ? ( schema.annotations.obsByName[catName].writable ? (
<Category <Category
key={catName} key={catName}
@@ -104,6 +108,12 @@ class Categories extends React.Component {
title="Create new category" title="Create new category"
isOpen={createAnnoModeActive} isOpen={createAnnoModeActive}
onClose={this.handleDisableAnnoMode} onClose={this.handleDisableAnnoMode}
>
<form
onSubmit={e => {
e.preventDefault();
this.handleCreateUserAnno();
}}
> >
<div className={Classes.DIALOG_BODY}> <div className={Classes.DIALOG_BODY}>
<div style={{ marginBottom: 20 }}> <div style={{ marginBottom: 20 }}>
@@ -124,7 +134,9 @@ class Categories extends React.Component {
items={allCategoryNames} items={allCategoryNames}
filterable={false} filterable={false}
itemRenderer={(d, { handleClick }) => { itemRenderer={(d, { handleClick }) => {
return <MenuItem onClick={handleClick} key={d} text={d} />; return (
<MenuItem onClick={handleClick} key={d} text={d} />
);
}} }}
noResults={<MenuItem disabled text="No results." />} noResults={<MenuItem disabled text="No results." />}
onItemSelect={d => { onItemSelect={d => {
@@ -143,13 +155,20 @@ class Categories extends React.Component {
<div className={Classes.DIALOG_FOOTER}> <div className={Classes.DIALOG_FOOTER}>
<div className={Classes.DIALOG_FOOTER_ACTIONS}> <div className={Classes.DIALOG_FOOTER_ACTIONS}>
<Tooltip content="Close this dialog without creating a category."> <Tooltip content="Close this dialog without creating a category.">
<Button onClick={this.handleDisableAnnoMode}>Cancel</Button> <Button onClick={this.handleDisableAnnoMode}>
Cancel
</Button>
</Tooltip> </Tooltip>
<Button onClick={this.handleCreateUserAnno} intent="primary"> <Button
onClick={this.handleCreateUserAnno}
intent="primary"
type="submit"
>
Create new category Create new category
</Button> </Button>
</div> </div>
</div> </div>
</form>
</Dialog> </Dialog>
<Button onClick={this.handleEnableAnnoMode} intent="primary"> <Button onClick={this.handleEnableAnnoMode} intent="primary">
Create new category Create new category
@@ -311,6 +311,12 @@ class Category extends React.Component {
title="Add new label" title="Add new label"
isOpen={annotations.isAddingNewLabel} isOpen={annotations.isAddingNewLabel}
onClose={this.disableAddNewLabelMode} onClose={this.disableAddNewLabelMode}
>
<form
onSubmit={e => {
e.preventDefault();
this.handleAddNewLabelToCategory();
}}
> >
<div className={Classes.DIALOG_BODY}> <div className={Classes.DIALOG_BODY}>
<div style={{ marginBottom: 20 }}> <div style={{ marginBottom: 20 }}>
@@ -340,11 +346,13 @@ class Category extends React.Component {
} }
onClick={this.handleAddNewLabelToCategory} onClick={this.handleAddNewLabelToCategory}
intent="primary" intent="primary"
type="submit"
> >
Add new label to category Add new label to category
</Button> </Button>
</div> </div>
</div> </div>
</form>
</Dialog> </Dialog>
<Popover <Popover
interactionKind={PopoverInteractionKind.HOVER} interactionKind={PopoverInteractionKind.HOVER}