-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rahul Gupta
authored and
Rahul Gupta
committed
Sep 3, 2024
1 parent
afb7aa2
commit 851de7e
Showing
9 changed files
with
168 additions
and
245 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
import { useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Component from './Component'; | ||
import DEFAULT_COMPONENTS from './DefaultComponents'; | ||
import { Button } from '../components'; | ||
|
||
const AdvancedComponents = ({ entity }) => { | ||
const [showAdvanced, setShowAdvanced] = useState(false); | ||
|
||
const components = entity ? entity.components : {}; | ||
const definedComponents = Object.keys(components).filter((key) => { | ||
console.log(key); | ||
return DEFAULT_COMPONENTS.indexOf(key) === -1; | ||
}); | ||
|
||
const toggleAdvanced = () => { | ||
setShowAdvanced(!showAdvanced); | ||
}; | ||
|
||
return ( | ||
<div className="advanced-components"> | ||
<Button variant="toolbtn" onClick={toggleAdvanced}> | ||
{showAdvanced ? 'Hide Advanced' : 'Show Advanced'} | ||
</Button> | ||
{showAdvanced && | ||
definedComponents.sort().map((key) => ( | ||
<div key={key} className={'details'}> | ||
<Component | ||
isCollapsed={definedComponents.length > 2} | ||
component={components[key]} | ||
entity={entity} | ||
name={key} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
AdvancedComponents.propTypes = { | ||
entity: PropTypes.object | ||
}; | ||
|
||
export default AdvancedComponents; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import PropTypes from 'prop-types'; | ||
import { Button } from '../components'; | ||
import Events from '../../lib/Events'; | ||
import AdvancedComponents from './AdvancedComponents'; | ||
import PropertyRow from './PropertyRow'; | ||
|
||
const GeoSidebar = ({ entity }) => { | ||
const openGeoModal = () => { | ||
Events.emit('opengeomodal', { entity }); | ||
}; | ||
|
||
// Check if entity and its components exist | ||
const component = entity?.components?.['street-geo']; | ||
|
||
return ( | ||
<div className="geo-sidebar"> | ||
<div className="geo-controls"> | ||
<div className="details"> | ||
{component && component.schema && component.data && ( | ||
<PropertyRow | ||
key="maps" | ||
name="maps" | ||
label="Map Source" | ||
schema={component.schema['maps']} | ||
data={component.data['maps']} | ||
componentname="street-geo" | ||
isSingle={false} | ||
entity={entity} | ||
/> | ||
)} | ||
<div className="propertyRow"> | ||
{entity && entity.components && entity.components['street-geo'] ? ( | ||
<> | ||
<Button variant="toolbtn" onClick={openGeoModal}> | ||
Change Location | ||
</Button> | ||
<AdvancedComponents entity={entity} /> | ||
</> | ||
) : ( | ||
<div> | ||
<Button variant="toolbtn" onClick={openGeoModal}> | ||
Set Location | ||
</Button> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
GeoSidebar.propTypes = { | ||
entity: PropTypes.object.isRequired | ||
}; | ||
|
||
export default GeoSidebar; |
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
Oops, something went wrong.