-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: geometry scheduledat occuredat in changelog
- Loading branch information
Showing
11 changed files
with
266 additions
and
3 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
3 changes: 3 additions & 0 deletions
3
...onents/WidgetsChangelog/common/ChangelogTable/ChangelogCells/ChangelogChangeCell/index.js
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,3 @@ | ||
// @flow | ||
|
||
export { ChangelogChangeCell } from './ChangelogChangeCell'; |
98 changes: 98 additions & 0 deletions
98
...tsChangelog/common/ChangelogTable/ChangelogCells/ChangelogValueCell/ChangelogValueCell.js
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,98 @@ | ||
// @flow | ||
import React from 'react'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import { colors, spacers } from '@dhis2/ui'; | ||
import { CHANGE_TYPES } from '../../../Changelog/Changelog.constants'; | ||
import { | ||
DefaultChangelogComponentsByChangeType, | ||
PlygonChangelogComponentsByChangeType, | ||
} from './ChangelogValueCellComponents'; | ||
|
||
type Props = { | ||
dataItemId: string, | ||
changeType: $Values<typeof CHANGE_TYPES>, | ||
previousValue?: string, | ||
currentValue?: string, | ||
classes: { | ||
container: string, | ||
valueContainer: string, | ||
buttonContainer: string, | ||
previousValue: string, | ||
currentValue: string, | ||
updatePreviousValue: string, | ||
updateCurrentValue: string, | ||
updateArrow: string, | ||
viewButton: string, | ||
}, | ||
}; | ||
|
||
const styles = { | ||
container: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
whiteSpace: 'normal', | ||
height: '100%', | ||
}, | ||
buttonContainer: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
previousValue: { | ||
color: colors.grey700, | ||
wordBreak: 'break-word', | ||
}, | ||
currentValue: { | ||
color: colors.grey900, | ||
wordBreak: 'break-word', | ||
}, | ||
updateArrow: { | ||
display: 'inline-flex', | ||
alignItems: 'center', | ||
margin: spacers.dp4, | ||
}, | ||
viewButton: { | ||
background: 'none', | ||
border: 'none', | ||
cursor: 'pointer', | ||
color: colors.grey800, | ||
display: 'flex', | ||
alignItems: 'center', | ||
'&:hover': { | ||
textDecoration: 'underline', | ||
color: 'black', | ||
}, | ||
}, | ||
}; | ||
|
||
export const ChangelogValueCellPlain = ({ | ||
dataItemId, | ||
changeType, | ||
currentValue, | ||
previousValue, | ||
classes, | ||
}: Props) => { | ||
if (!currentValue) { return null; } | ||
const isPolygon = dataItemId === 'geometry' && currentValue.length > 2; | ||
const ComponentsByChangeType = isPolygon | ||
? PlygonChangelogComponentsByChangeType | ||
: DefaultChangelogComponentsByChangeType; | ||
|
||
const ChangelogComponent = ComponentsByChangeType[changeType]; | ||
|
||
if (!ChangelogComponent) { | ||
console.error(`No component found for change type: ${changeType}`); | ||
return null; | ||
} | ||
|
||
return ( | ||
<ChangelogComponent | ||
previousValue={previousValue} | ||
currentValue={currentValue} | ||
classes={classes} | ||
/> | ||
); | ||
}; | ||
|
||
export const ChangelogValueCell = withStyles(styles)(ChangelogValueCellPlain); |
13 changes: 13 additions & 0 deletions
13
...lls/ChangelogValueCell/ChangelogValueCellComponents/ChangelogValueCellComponents.types.js
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,13 @@ | ||
// @flow | ||
export type ChangelogValueCellProps = { | ||
previousValue?: string, | ||
currentValue?: string, | ||
classes: { | ||
container: string, | ||
buttonContainer: string, | ||
previousValue: string, | ||
currentValue: string, | ||
updateArrow: string, | ||
viewButton: string, | ||
}, | ||
}; |
33 changes: 33 additions & 0 deletions
33
...angelogCells/ChangelogValueCell/ChangelogValueCellComponents/ChangelogValueCellDefault.js
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,33 @@ | ||
// @flow | ||
import React from 'react'; | ||
import { IconArrowRight16 } from '@dhis2/ui'; | ||
import { CHANGE_TYPES } from '../../../../Changelog/Changelog.constants'; | ||
import type { ChangelogValueCellProps } from './ChangelogValueCellComponents.types'; | ||
|
||
const Updated = ({ previousValue, currentValue, classes }: ChangelogValueCellProps) => ( | ||
<div className={classes.container}> | ||
<span className={classes.previousValue}>{previousValue}</span> | ||
<span className={classes.updateArrow}> | ||
<IconArrowRight16 /> | ||
</span> | ||
<span className={classes.currentValue}>{currentValue}</span> | ||
</div> | ||
); | ||
|
||
const Created = ({ currentValue, classes }: ChangelogValueCellProps) => ( | ||
<div className={classes.container}> | ||
<span className={classes.currentValue}>{currentValue}</span> | ||
</div> | ||
); | ||
|
||
const Deleted = ({ previousValue, classes }: ChangelogValueCellProps) => ( | ||
<div className={classes.container}> | ||
<span className={classes.previousValue}>{previousValue}</span> | ||
</div> | ||
); | ||
|
||
export const DefaultChangelogComponentsByChangeType = Object.freeze({ | ||
[CHANGE_TYPES.UPDATED]: Updated, | ||
[CHANGE_TYPES.CREATED]: Created, | ||
[CHANGE_TYPES.DELETED]: Deleted, | ||
}); |
93 changes: 93 additions & 0 deletions
93
...angelogCells/ChangelogValueCell/ChangelogValueCellComponents/ChangelogValueCellPolygon.js
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,93 @@ | ||
// @flow | ||
import React, { useState } from 'react'; | ||
import { IconArrowRight16, IconChevronUp16, IconChevronDown16 } from '@dhis2/ui'; | ||
import { CHANGE_TYPES } from '../../../../Changelog/Changelog.constants'; | ||
import type { ChangelogValueCellProps } from './ChangelogValueCellComponents.types'; | ||
|
||
const ValueDisplay = ({ value, showMore, className }) => ( | ||
<span className={className}>{showMore ? value : value?.slice(0, 1)}</span> | ||
); | ||
|
||
const ViewMoreButton = ({ showMore, onClick, classes }) => ( | ||
<button className={classes.viewButton} onClick={onClick}> | ||
{showMore ? 'View less' : 'View more'} | ||
{showMore ? <IconChevronUp16 /> : <IconChevronDown16 />} | ||
</button> | ||
); | ||
|
||
const Updated = ({ previousValue, currentValue, classes }: ChangelogValueCellProps) => { | ||
const [showMore, setShowMore] = useState(false); | ||
|
||
return ( | ||
<> | ||
<div className={classes.container}> | ||
<ValueDisplay | ||
value={previousValue} | ||
showMore={showMore} | ||
className={classes.previousValue} | ||
/> | ||
<span className={classes.updateArrow}> | ||
<IconArrowRight16 /> | ||
</span> | ||
<ValueDisplay | ||
value={currentValue} | ||
showMore={showMore} | ||
className={classes.currentValue} | ||
/> | ||
</div> | ||
<div className={classes.buttonContainer}> | ||
<ViewMoreButton | ||
showMore={showMore} | ||
onClick={() => setShowMore(!showMore)} | ||
classes={classes} | ||
/> | ||
</div> | ||
</> | ||
|
||
); | ||
}; | ||
|
||
|
||
const Created = ({ currentValue, classes }: ChangelogValueCellProps) => { | ||
const [showMore, setShowMore] = useState(false); | ||
|
||
return ( | ||
<div className={classes.container}> | ||
<ValueDisplay | ||
value={currentValue} | ||
showMore={showMore} | ||
className={classes.currentValue} | ||
/> | ||
<ViewMoreButton | ||
showMore={showMore} | ||
onClick={() => setShowMore(!showMore)} | ||
classes={classes} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
const Deleted = ({ previousValue, classes }: ChangelogValueCellProps) => { | ||
const [showMore, setShowMore] = useState(false); | ||
|
||
return ( | ||
<div className={classes.container}> | ||
<ValueDisplay | ||
value={previousValue} | ||
showMore={showMore} | ||
className={classes.previousValue} | ||
/> | ||
<ViewMoreButton | ||
showMore={showMore} | ||
onClick={() => setShowMore(!showMore)} | ||
classes={classes} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export const PlygonChangelogComponentsByChangeType = Object.freeze({ | ||
[CHANGE_TYPES.UPDATED]: Updated, | ||
[CHANGE_TYPES.CREATED]: Created, | ||
[CHANGE_TYPES.DELETED]: Deleted, | ||
}); |
6 changes: 6 additions & 0 deletions
6
...on/ChangelogTable/ChangelogCells/ChangelogValueCell/ChangelogValueCellComponents/index.js
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,6 @@ | ||
// @flow | ||
|
||
export { DefaultChangelogComponentsByChangeType } from './ChangelogValueCellDefault'; | ||
export { PlygonChangelogComponentsByChangeType } from './ChangelogValueCellPolygon'; | ||
|
||
export type { ChangelogValueCellProps } from './ChangelogValueCellComponents.types'; |
3 changes: 3 additions & 0 deletions
3
...ponents/WidgetsChangelog/common/ChangelogTable/ChangelogCells/ChangelogValueCell/index.js
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,3 @@ | ||
// @flow | ||
|
||
export { ChangelogValueCell } from './ChangelogValueCell'; |
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