-
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.
Added DetailedLink info for page from '?fullobject' request
- Loading branch information
Showing
7 changed files
with
176 additions
and
188 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
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 |
---|---|---|
@@ -1,67 +1,38 @@ | ||
/** | ||
* Edit map block. | ||
* @module components/manage/Blocks/Maps/Edit | ||
*/ | ||
|
||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Link } from 'react-router-dom'; | ||
import React from 'react'; | ||
import { injectIntl } from 'react-intl'; | ||
import { settings } from '~/config'; | ||
import { BodyClass } from '@plone/volto/helpers'; | ||
|
||
import { Button } from 'semantic-ui-react'; | ||
// import AddLinkForm from './AddLinkForm'; | ||
|
||
function removeDuplicates(myArr, prop) { | ||
return myArr.filter((obj, pos, arr) => { | ||
return arr.map(mapObj => mapObj[prop]).indexOf(obj[prop]) === pos; | ||
}); | ||
} | ||
|
||
class View extends Component { | ||
/** | ||
* Property types. | ||
* @property {Object} propTypes Property types. | ||
* @static | ||
*/ | ||
static propTypes = { | ||
data: PropTypes.objectOf(PropTypes.any).isRequired, | ||
// pathname: PropTypes.string.isRequired, | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
link: this.props.data.link | ||
}; | ||
} | ||
getPath(url) { | ||
if (!url) return ''; | ||
return url | ||
.replace(settings.apiPath, '') | ||
.replace(settings.internalApiPath, ''); | ||
} | ||
|
||
import { Link } from 'react-router-dom'; | ||
|
||
render() { | ||
return ( | ||
<div> | ||
{this.state.link && ( | ||
<Link className="detailed-link-block" onClick={(e) => e.preventDefault} to={this.getPath(this.state.link.value)}> | ||
<div className="detailed-link-block-item-title"> | ||
{this.state.link.text} | ||
</div> | ||
<p> | ||
import { settings } from '~/config'; | ||
|
||
{this.state.link.description && <p>{this.state.link.description}</p>} | ||
</p> | ||
const getPath = url => { | ||
if (!url) return ''; | ||
return url | ||
.replace(settings.apiPath, '') | ||
.replace(settings.internalApiPath, ''); | ||
}; | ||
|
||
const View = props => { | ||
return ( | ||
<div> | ||
{(props.data?.detailedLink && ( | ||
<div> | ||
<div className="detailed-link-block-item-title"> | ||
{props.data.detailedLink.title || props.data.detailedLink.text} | ||
</div> | ||
<p>{props.data.detailedLink.description || ''}</p> | ||
<Link | ||
className="detailed-link-block" | ||
onClick={e => e.preventDefault} | ||
to={getPath(props.data.detailedLink.value)} | ||
> | ||
<Button basic>Read more</Button> | ||
</Link> | ||
) || 'Select a page from sidebar'} | ||
</div> | ||
); | ||
} | ||
} | ||
</div> | ||
)) || | ||
'Select a page from sidebar'} | ||
</div> | ||
); | ||
}; | ||
|
||
export default injectIntl(View); |
Oops, something went wrong.