Skip to content

Commit

Permalink
feat: add modes config to limit controls
Browse files Browse the repository at this point in the history
Closes #168
  • Loading branch information
stdavis committed Apr 13, 2023
1 parent fa95fa6 commit 044fc88
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 52 deletions.
6 changes: 4 additions & 2 deletions public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@
"limitFacilityType": {
"field": "breakout",
"labels": ["UDOT", "Local"],
"values": ["state", "local"]
"values": ["state", "local"],
"modes": ["road", "activeTransportation"]
},
"limitROW": {
"field": "COR_PRES",
"labels": ["ROW Needed", "No ROW Needed"],
"values": ["Yes", "No"]
"values": ["Yes", "No"],
"modes": ["road", "activeTransportation"]
},
"projectTypes": {
"road": {
Expand Down
82 changes: 36 additions & 46 deletions public/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,40 @@
},
"title": "Translation",
"type": "object"
},
"limitControl": {
"type": "object",
"required": ["field", "labels", "values", "modes"],
"additionalProperties": false,
"properties": {
"field": {
"title": "Field",
"type": "string"
},
"labels": {
"title": "Label",
"type": "array",
"items": {
"type": "string"
}
},
"values": {
"title": "Values",
"type": "array",
"items": {
"type": "string"
}
},
"modes": {
"title": "Modes",
"description": "The modes that this control should be enabled for",
"type": "array",
"items": {
"type": "string",
"enum": ["road", "transit", "activeTransportation"]
}
}
}
}
},
"required": [
Expand Down Expand Up @@ -243,56 +277,12 @@
"limitFacilityType": {
"title": "Limit to ... Facilities config",
"description": "Configuration for the Limit to ... Facilities filter. If this property is missing, then the associated control will be hidden",
"type": "object",
"required": ["field", "labels", "values"],
"additionalProperties": false,
"properties": {
"field": {
"title": "Field",
"type": "string"
},
"labels": {
"title": "Label",
"type": "array",
"items": {
"type": "string"
}
},
"values": {
"title": "Values",
"type": "array",
"items": {
"type": "string"
}
}
}
"$ref": "#/definitions/limitControl"
},
"limitROW": {
"title": "Limit to [no] ROW Needed config",
"description": "Configuration for the Limit to [no] ROW Needed filter. If this property is missing, then the associated control will be hidden",
"type": "object",
"required": ["field", "labels", "values"],
"additionalProperties": false,
"properties": {
"field": {
"title": "Field",
"type": "string"
},
"labels": {
"title": "Label",
"type": "array",
"items": {
"type": "string"
}
},
"values": {
"title": "Values",
"type": "array",
"items": {
"type": "string"
}
}
}
"$ref": "#/definitions/limitControl"
},
"projectTypes": {
"title": "Project Types",
Expand Down
33 changes: 29 additions & 4 deletions src/components/AdvancedControls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function AdvancedControls({ disabled, dispatch, isOpen, labelColo
disabled={disabled || !state.mode.includes(config.filter.symbolValues.mode.road)}
/>
))}
{config.filter.limitFacilityType ? (
{config.filter.limitFacilityType?.modes?.includes('road') ? (
<LimitType
color={labelColors?.road}
labels={config.filter.limitFacilityType.labels}
Expand All @@ -86,7 +86,7 @@ export default function AdvancedControls({ disabled, dispatch, isOpen, labelColo
values={config.filter.limitFacilityType.values}
/>
) : null}
{config.filter.limitROW ? (
{config.filter.limitROW?.modes.includes('road') ? (
<LimitType
color={labelColors?.road}
labels={config.filter.limitROW.labels}
Expand Down Expand Up @@ -118,6 +118,31 @@ export default function AdvancedControls({ disabled, dispatch, isOpen, labelColo
disabled={disabled || !state.mode.includes(config.filter.symbolValues.mode.transit)}
/>
))}
{config.filter.limitFacilityType?.modes?.includes('transit') ? (
<LimitType
color={labelColors?.road}
labels={config.filter.limitFacilityType.labels}
onChange={(selected, type) =>
dispatch({ type: 'limitFacilityType', payload: { selected, type }, meta: 'transit' })
}
postFix="Facilities"
selected={state.limitFacilityType.road.selected}
type={state.limitFacilityType.road.type}
values={config.filter.limitFacilityType.values}
/>
) : null}
{config.filter.limitROW?.modes.includes('transit') ? (
<LimitType
color={labelColors?.road}
labels={config.filter.limitROW.labels}
onChange={(selected, type) =>
dispatch({ type: 'limitROW', payload: { selected, type }, meta: 'transit' })
}
selected={state.limitROW.road.selected}
type={state.limitROW.road.type}
values={config.filter.limitROW.values}
/>
) : null}
</Col>
</Row>
<Row>
Expand Down Expand Up @@ -161,7 +186,7 @@ export default function AdvancedControls({ disabled, dispatch, isOpen, labelColo
disabled={disabled || !state.mode.includes(config.filter.symbolValues.mode.activeTransportation)}
/>
))}
{config.filter.limitFacilityType ? (
{config.filter.limitFacilityType?.modes?.includes('activeTransportation') ? (
<LimitType
color={labelColors?.activeTransportation}
labels={config.filter.limitFacilityType.labels}
Expand All @@ -174,7 +199,7 @@ export default function AdvancedControls({ disabled, dispatch, isOpen, labelColo
values={config.filter.limitFacilityType.values}
/>
) : null}
{config.filter.limitROW ? (
{config.filter.limitROW?.modes?.includes('activeTransportation') ? (
<LimitType
color={labelColors?.activeTransportation}
labels={config.filter.limitROW.labels}
Expand Down

0 comments on commit 044fc88

Please sign in to comment.