Do not display html component if description is only empty tags
This commit is contained in:
parent
9132668943
commit
d17a52307f
2 changed files with 20 additions and 11 deletions
|
@ -10,7 +10,7 @@ import PlanningEventManager from "../utils/PlanningEventManager";
|
||||||
|
|
||||||
function PreviewEventDashboardItem(props) {
|
function PreviewEventDashboardItem(props) {
|
||||||
const {colors} = props.theme;
|
const {colors} = props.theme;
|
||||||
|
const isEmpty = PlanningEventManager.isDescriptionEmpty(props.event['description']);
|
||||||
if (props.event !== undefined && props.event !== null) {
|
if (props.event !== undefined && props.event !== null) {
|
||||||
const hasImage = props.event['logo'] !== '' && props.event['logo'] !== null;
|
const hasImage = props.event['logo'] !== '' && props.event['logo'] !== null;
|
||||||
const getImage = () => <Avatar.Image
|
const getImage = () => <Avatar.Image
|
||||||
|
@ -33,17 +33,19 @@ function PreviewEventDashboardItem(props) {
|
||||||
title={props.event['title']}
|
title={props.event['title']}
|
||||||
subtitle={PlanningEventManager.getFormattedEventTime(props.event)}
|
subtitle={PlanningEventManager.getFormattedEventTime(props.event)}
|
||||||
/>}
|
/>}
|
||||||
<Card.Content style={{
|
{!isEmpty ?
|
||||||
height: props.event['description'].length > 70 ? 100 : 50,
|
<Card.Content style={{
|
||||||
overflow: 'hidden',
|
maxHeight: 150,
|
||||||
}}>
|
overflow: 'hidden',
|
||||||
<HTML html={"<div>" + props.event['description'] + "</div>"}
|
}}>
|
||||||
tagsStyles={{
|
<HTML html={"<div>" + props.event['description'] + "</div>"}
|
||||||
p: {color: colors.text,},
|
tagsStyles={{
|
||||||
div: {color: colors.text},
|
p: {color: colors.text,},
|
||||||
}}/>
|
div: {color: colors.text},
|
||||||
|
}}/>
|
||||||
|
|
||||||
|
</Card.Content> : null}
|
||||||
|
|
||||||
</Card.Content>
|
|
||||||
<Card.Actions style={{
|
<Card.Actions style={{
|
||||||
marginLeft: 'auto',
|
marginLeft: 'auto',
|
||||||
marginTop: 'auto',
|
marginTop: 'auto',
|
||||||
|
|
|
@ -73,4 +73,11 @@ export default class PlanningEventManager {
|
||||||
return formattedStr
|
return formattedStr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static isDescriptionEmpty (description: string) {
|
||||||
|
return description
|
||||||
|
.replace('<p>', '')
|
||||||
|
.replace('</p>', '')
|
||||||
|
.replace('<br>', '').trim() === '';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue