diff --git a/client/package-lock.json b/client/package-lock.json index bbec58c..5fbb9c8 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -8698,6 +8698,11 @@ "react-double-scrollbar": "0.0.15" } }, + "material-ui-nested-menu-item": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/material-ui-nested-menu-item/-/material-ui-nested-menu-item-1.0.2.tgz", + "integrity": "sha512-LZb8xI0FrAI/A3P2vT3CB9bmSoOFWOK0dikTc1t9VvEpp1a8hZkbVUz7VhETnoLUYu3NXCkgulmXcl3zitqI9A==" + }, "md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", diff --git a/client/package.json b/client/package.json index 3fe72d3..fec4ea1 100644 --- a/client/package.json +++ b/client/package.json @@ -18,6 +18,7 @@ "jsurl": "^0.1.5", "lodash": "^4.17.20", "material-table": "^1.69.0", + "material-ui-nested-menu-item": "^1.0.2", "react": "^16.13.1", "react-dnd": "^11.1.3", "react-dnd-html5-backend": "^11.1.3", diff --git a/client/src/components/Window.tsx b/client/src/components/Window.tsx index f241ca6..31842be 100644 --- a/client/src/components/Window.tsx +++ b/client/src/components/Window.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { ThemeProvider, CssBaseline, createMuiTheme } from '@material-ui/core'; -import { QBQueryElem } from './querybuilder/QBQueryElem'; import { QueryLeafElem, QueryLeafBy, QueryLeafOp, QueryElem, QueryNodeElem, queryOr, queryAnd } from '../lib/Query'; +import QueryBuilder from './querybuilder/QueryBuilder'; const darkTheme = createMuiTheme({ palette: { @@ -32,6 +32,6 @@ export default function Window(props: any) { return - + } \ No newline at end of file diff --git a/client/src/components/querybuilder/QBQueryButton.tsx b/client/src/components/querybuilder/QBQueryButton.tsx new file mode 100644 index 0000000..e1a1246 --- /dev/null +++ b/client/src/components/querybuilder/QBQueryButton.tsx @@ -0,0 +1,122 @@ +import React, { useState } from 'react'; +import { IconButton, Menu, MenuItem, TextField, Box } from '@material-ui/core'; +import SearchIcon from '@material-ui/icons/Search'; +import NestedMenuItem from "material-ui-nested-menu-item"; +import { QueryElem, QueryLeafBy, QueryLeafOp } from '../../lib/Query'; +import Autocomplete from '@material-ui/lab/Autocomplete' + +export function QBQueryButtonBase(props: any) { + return + + +} + +export interface FreeSoloInputProps { + label: string, + options: string[], + onSubmit: (s: string, exactMatch: boolean) => void, +} + +export function QBMenuFreeSoloInput(props: FreeSoloInputProps) { + const [value, setValue] = useState(''); + + const onInputChange = (event: any, _val: any, reason: any) => { + if (reason === 'reset') { + // User selected a preset option. + props.onSubmit(_val, true); + } else { + setValue(_val); + } + } + + return { + if (e.key === 'Enter') { + // User submitted free-form value. + props.onSubmit(value, props.options.includes(value)); + } + }} + renderInput={(params: any) => } + /> +} + + +export interface MenuProps { + anchorEl: null | HTMLElement, + onClose: () => void, + onCreateQuery: (q: QueryElem) => void, +} + +export function QBQueryButtonMenu(props: MenuProps) { + let anchorEl = props.anchorEl; + let onClose = props.onClose; + + const artists = [ + 'Queens', + 'Muse', + 'Triggerfinger' + ]; + + return + + { + onClose(); + props.onCreateQuery({ + a: QueryLeafBy.ArtistName, + op: exact ? QueryLeafOp.Equals : QueryLeafOp.Like, + b: s + }); + }} + /> + + +} + +export interface IProps { + +} + +export default function QBQueryButton(props: IProps) { + const [anchorEl, setAnchorEl] = React.useState(null); + const onOpen = (e: React.MouseEvent) => { + setAnchorEl(e.currentTarget); + } + const onClose = () => { + setAnchorEl(null); + } + const onCreateQuery = (q: QueryElem) => { + console.log("created query:", q); + } + + return <> + + + ; +} \ No newline at end of file diff --git a/client/src/components/querybuilder/QueryBuilder.tsx b/client/src/components/querybuilder/QueryBuilder.tsx new file mode 100644 index 0000000..2b43124 --- /dev/null +++ b/client/src/components/querybuilder/QueryBuilder.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import { Box } from '@material-ui/core'; +import QBQueryButton from './QBQueryButton'; +import { QBQueryElem } from './QBQueryElem'; +import { QueryElem } from '../../lib/Query'; + +export interface IProps { + query: QueryElem +} + +export default function QueryBuilder(props: IProps) { + return + + + + + + + +} \ No newline at end of file