-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(web): search areas template height
- Loading branch information
1 parent
aba9f9b
commit fa7e5b5
Showing
15 changed files
with
259 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/@liexp/ui/src/components/Input/AutocompleteAreaInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { type Area } from "@liexp/shared/lib/io/http"; | ||
import * as React from "react"; | ||
import { useEndpointQueries } from "../../hooks/useEndpointQueriesProvider"; | ||
import { AreaList, AreaListItem } from "../lists/AreaList"; | ||
import { Grid, Typography } from "../mui"; | ||
import { AutocompleteInput } from "./AutocompleteInput"; | ||
|
||
export interface AutocompleteAreaInputProps { | ||
className?: string; | ||
selectedItems: Area.Area[]; | ||
onChange: (items: Area.Area[]) => void; | ||
discrete?: boolean; | ||
} | ||
|
||
export const AutocompleteAreaInput: React.FC<AutocompleteAreaInputProps> = ({ | ||
selectedItems, | ||
onChange, | ||
discrete = true, | ||
...props | ||
}) => { | ||
const Queries = useEndpointQueries(); | ||
return ( | ||
<AutocompleteInput<Area.Area> | ||
placeholder="Search area..." | ||
getOptionLabel={(a) => (typeof a === "string" ? a : a.label)} | ||
searchToFilter={(description) => ({ description })} | ||
selectedItems={selectedItems} | ||
query={(p) => Queries.Area.list.useQuery(p, undefined, discrete, 'search')} | ||
renderTags={(items) => ( | ||
<AreaList | ||
areas={items.map((i) => ({ | ||
...i, | ||
selected: true, | ||
}))} | ||
style={{ flexWrap: "wrap", flexDirection: "column" }} | ||
onAreaClick={(a) => { | ||
onChange(items.filter((i) => i.id !== a.id)); | ||
}} | ||
/> | ||
)} | ||
renderOption={(props, item, state) => { | ||
return ( | ||
<Grid | ||
container | ||
spacing={2} | ||
key={item.id} | ||
onClick={() => { | ||
onChange( | ||
selectedItems.filter((i) => i.id !== item.id).concat(item), | ||
); | ||
}} | ||
> | ||
<Grid item md={3}> | ||
<AreaListItem | ||
item={{ | ||
...item, | ||
selected: false, | ||
}} | ||
style={{ height: 100 }} | ||
/> | ||
</Grid> | ||
<Grid item md={9}> | ||
<Typography variant="subtitle1">{item.label}</Typography> | ||
</Grid> | ||
</Grid> | ||
); | ||
}} | ||
onItemsChange={onChange} | ||
{...props} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
packages/@liexp/ui/src/containers/areas/ExploreAreasBox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { type Area } from "@liexp/shared/lib/io/http"; | ||
import * as React from "react"; | ||
import { AutoSizer } from "react-virtualized"; | ||
import AreasMap from "../../components/AreasMap"; | ||
import QueriesRenderer from "../../components/QueriesRenderer"; | ||
import { AreaList } from "../../components/lists/AreaList"; | ||
import { Box, Grid } from "../../components/mui"; | ||
|
||
interface ExploreAreasBoxProps { | ||
onAreaClick: (a: Area.Area) => void; | ||
} | ||
|
||
export const ExploreAreasBox: React.FC<ExploreAreasBoxProps> = ({ | ||
onAreaClick, | ||
}) => { | ||
return ( | ||
<QueriesRenderer | ||
queries={(Q) => ({ | ||
areas: Q.Area.list.useQuery( | ||
{ | ||
filter: null, | ||
}, | ||
undefined, | ||
false, | ||
), | ||
})} | ||
render={({ areas: { data: areas } }) => { | ||
return ( | ||
<AutoSizer | ||
defaultHeight={600} | ||
style={{ width: "100%", height: "100%" }} | ||
> | ||
{({ width, height }) => { | ||
const innerHeight = height - height * 0.2; | ||
return ( | ||
<Grid | ||
container | ||
spacing={2} | ||
style={{ height: innerHeight, width: "100%" }} | ||
> | ||
<Grid item md={8}> | ||
<Box style={{ width: "100%", maxHeight: "100%" }}> | ||
<AreasMap | ||
areas={areas} | ||
height={height * (2 / 3)} | ||
onMapClick={(features) => { | ||
if (features.length > 0) { | ||
const area: any = features[0].getProperties(); | ||
onAreaClick(area); | ||
} | ||
}} | ||
/> | ||
</Box> | ||
</Grid> | ||
<Grid | ||
item | ||
md={4} | ||
style={{ height: innerHeight, overflow: "auto" }} | ||
> | ||
<AreaList | ||
areas={areas.map((a) => ({ ...a, selected: false }))} | ||
onAreaClick={onAreaClick} | ||
style={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
width: "100%", | ||
height: "100%", | ||
}} | ||
/> | ||
</Grid> | ||
</Grid> | ||
); | ||
}} | ||
</AutoSizer> | ||
); | ||
}} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.