Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
majkshkurti committed Oct 20, 2024
1 parent 6b16fa1 commit b46b0ef
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 89 deletions.
8 changes: 7 additions & 1 deletion apps/web/components/map/controls/Legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,13 @@ export function Legend(props: LegendProps) {
{geometryTypes.map(
(type) =>
layer.feature_layer_geometry_type === type &&
layer.properties && <LegendRows key={type} properties={layer.properties} type={type} />
layer.properties && (
<LegendRows
key={type}
properties={layer.properties as FeatureLayerProperties}
type={type}
/>
)
)}
</>
)}
Expand Down
7 changes: 4 additions & 3 deletions apps/web/components/map/panels/ProjectNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const ProjectNavigation = ({ projectId }) => {
: t(basemap.subtitle),
}));
}, [basemaps, i18n, t]);

const rightSidebar: MapSidebarProps = {
topItems: [
{
Expand All @@ -94,7 +93,9 @@ const ProjectNavigation = ({ projectId }) => {
icon: ICON_NAME.FILTER,
name: t("filter"),
component: <Filter projectId={projectId} />,
disabled: !activeLayer || activeLayer?.type !== layerType.Values.feature,
disabled:
!activeLayer ||
(activeLayer?.type !== layerType.Values.feature && activeLayer?.type !== layerType.Values.table),
},
{
id: MapSidebarItemID.STYLE,
Expand Down Expand Up @@ -123,7 +124,7 @@ const ProjectNavigation = ({ projectId }) => {

const activeRightComponent = useMemo(() => {
if (activeRight) {
return rightSidebar.topItems?.find((item) => item.id === activeRight)?.component;
return rightSidebar.topItems?.find((item) => item.id === activeRight && !item.disabled)?.component;
} else if (prevActiveRightRef.current) {
return rightSidebar.topItems?.find((item) => item.id === prevActiveRightRef.current)?.component;
}
Expand Down
85 changes: 46 additions & 39 deletions apps/web/components/map/panels/filter/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useTranslation } from "@/i18n/client";
import { updateProjectLayer } from "@/lib/api/projects";
import { setActiveRightPanel } from "@/lib/store/map/slice";
import { createTheCQLBasedOnExpression, parseCQLQueryToObject } from "@/lib/transformers/filter";
import { layerType } from "@/lib/validations/common";
import { type Expression as ExpressionType, FilterType } from "@/lib/validations/filter";

import type { SelectorItem } from "@/types/map/common";
Expand All @@ -46,7 +47,11 @@ const FilterPanel = ({ projectId }: { projectId: string }) => {
// Add filter expression
const [addExpressionAnchorEl, setAddExpressionAnchorEl] = React.useState<null | HTMLElement>(null);
const handleAddExpressionClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAddExpressionAnchorEl(event.currentTarget);
if (activeLayer?.type === layerType.Values.feature) {
setAddExpressionAnchorEl(event.currentTarget);
} else {
createExpression(FilterType.Logical);
}
};
const handleAddExpressionClose = () => {
setAddExpressionAnchorEl(null);
Expand Down Expand Up @@ -235,44 +240,46 @@ const FilterPanel = ({ projectId }: { projectId: string }) => {
{t("common:add_expression")}
</Typography>
</Button>
<Menu
anchorEl={addExpressionAnchorEl}
sx={{
"& .MuiPaper-root": {
boxShadow: "0px 0px 10px 0px rgba(58, 53, 65, 0.1)",
},
}}
anchorOrigin={{ vertical: "top", horizontal: "center" }}
transformOrigin={{ vertical: "bottom", horizontal: "center" }}
open={open}
MenuListProps={{
"aria-labelledby": "basic-button",
sx: {
width: addExpressionAnchorEl && addExpressionAnchorEl.offsetWidth - 10,
p: 0,
},
}}
onClose={handleAddExpressionClose}>
<Box>
<ClickAwayListener onClickAway={handleAddExpressionClose}>
<MenuList>
{addExpressionItems.map((item, index) => (
<MenuItem
key={index}
onClick={() => {
createExpression(item.sourceType);
handleAddExpressionClose();
}}>
<ListItemIcon>
<Icon iconName={item.iconName} style={{ fontSize: "15px" }} />
</ListItemIcon>
<Typography variant="body2">{item.label}</Typography>
</MenuItem>
))}
</MenuList>
</ClickAwayListener>
</Box>
</Menu>
{activeLayer.type === layerType.Values.feature && (
<Menu
anchorEl={addExpressionAnchorEl}
sx={{
"& .MuiPaper-root": {
boxShadow: "0px 0px 10px 0px rgba(58, 53, 65, 0.1)",
},
}}
anchorOrigin={{ vertical: "top", horizontal: "center" }}
transformOrigin={{ vertical: "bottom", horizontal: "center" }}
open={open}
MenuListProps={{
"aria-labelledby": "basic-button",
sx: {
width: addExpressionAnchorEl && addExpressionAnchorEl.offsetWidth - 10,
p: 0,
},
}}
onClose={handleAddExpressionClose}>
<Box>
<ClickAwayListener onClickAway={handleAddExpressionClose}>
<MenuList>
{addExpressionItems.map((item, index) => (
<MenuItem
key={index}
onClick={() => {
createExpression(item.sourceType);
handleAddExpressionClose();
}}>
<ListItemIcon>
<Icon iconName={item.iconName} style={{ fontSize: "15px" }} />
</ListItemIcon>
<Typography variant="body2">{item.label}</Typography>
</MenuItem>
))}
</MenuList>
</ClickAwayListener>
</Box>
</Menu>
)}
{/* CLEAR FILTER */}
<Button
variant="outlined"
Expand Down
4 changes: 3 additions & 1 deletion apps/web/components/map/panels/properties/Properties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ const PropertiesPanel = ({ projectId }: { projectId: string }) => {
<>
<ProjectLayerDropdown projectId={projectId} />
<LayerInfo layer={activeLayer} />
<Symbology layer={activeLayer} />
{(activeLayer.type === "feature" || activeLayer.type === "raster") && (
<Symbology layer={activeLayer} />
)}
</>
)}
</>
Expand Down
Loading

0 comments on commit b46b0ef

Please sign in to comment.