diff --git a/src/components/Fields/DocSelect.tsx b/src/components/Fields/DocSelect.tsx
index 7464eb7d..ad8b200c 100644
--- a/src/components/Fields/DocSelect.tsx
+++ b/src/components/Fields/DocSelect.tsx
@@ -4,6 +4,7 @@ import IconButton from "@material-ui/core/IconButton";
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles";
import { TextField } from "@material-ui/core";
import Typography from "@material-ui/core/Typography";
+import Chip from "@material-ui/core/Chip";
const useStyles = makeStyles((theme: Theme) =>
createStyles({
@@ -11,6 +12,7 @@ const useStyles = makeStyles((theme: Theme) =>
position: "relative",
display: "flex",
flexWrap: "wrap",
+ alignItems: "center",
},
typography: {
padding: theme.spacing(2),
@@ -20,6 +22,9 @@ const useStyles = makeStyles((theme: Theme) =>
minWidth: 230,
},
paper: { minWidth: 200 },
+ chip: {
+ margin: theme.spacing(1),
+ },
})
);
interface Props {
@@ -51,18 +56,34 @@ const DocSelect = (props: Props) => {
setSearch((oldValues: any) => ({
...oldValues,
collection: collectionPath,
- anchorEl: event.currentTarget,
- onSubmit: onSubmit,
+ config: config,
+ onSubmit: (value: any) => {
+ onSubmit([value]);
+ },
}));
};
- // if (isScrolling) return
;
return (
- test
+ {value &&
+ value.map((doc: any) => (
+ `${doc.snapshot[key]} `
+ )}
+ //onClick={handleClick}
+ //onDelete={handleDelete}
+ className={classes.chip}
+ />
+ ))}
+ {/*
+ {value[0]
+ ? config.primaryKeys.map((key: any) => `${value[0].snapshot[key]} `)
+ : ""}
+ */}
);
};
diff --git a/src/components/SearchBox.tsx b/src/components/SearchBox.tsx
index 58be6f4c..7316f704 100644
--- a/src/components/SearchBox.tsx
+++ b/src/components/SearchBox.tsx
@@ -58,13 +58,14 @@ interface Props {
searchData: {
collection: string;
onSubmit: Function | undefined;
+ config: any;
};
clearSearch: Function;
}
const SearchBox = (props: Props) => {
const { searchData, clearSearch } = props;
- const { collection, onSubmit } = searchData;
+ const { collection, onSubmit, config } = searchData;
const [query, setQuery] = useState("");
const classes = useStyles();
@@ -99,15 +100,25 @@ const SearchBox = (props: Props) => {
delete snapshot._highlightResult;
if (onSubmit) {
onSubmit({ snapshot, docPath: `${collection}/${snapshot.objectID}` });
- clearSearch();
- setQuery("");
+ clear();
}
}}
>
-
+ `${hit[key]} `)
+ }
+ secondary={
+ config && config.secondaryKeys.map((key: string) => `${hit[key]} `)
+ }
+ />
);
-
+ const clear = async () => {
+ await setHits([]);
+ await setQuery("");
+ clearSearch();
+ };
return (
{
className={classes.modal}
open={open}
onClose={(event: any, reason: any) => {
- clearSearch();
- setQuery("");
+ clear();
}}
closeAfterTransition
BackdropComponent={Backdrop}
@@ -127,6 +137,7 @@ const SearchBox = (props: Props) => {
) => {
setQuery(e.target.value);