-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Visualisations): Adds new template "What are the most popular le…
…arning experience activity types?". (#1500 - [LL-268](https://learningpool.atlassian.net/browse/LL-268)) #1500 https://learningpool.atlassian.net/browse/LL-268
- Loading branch information
1 parent
d2c49ec
commit 7d44f8a
Showing
19 changed files
with
249 additions
and
1 deletion.
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
27 changes: 27 additions & 0 deletions
27
ui/src/containers/Visualisations/TemplateLearningExperienceType/Card.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,27 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Map } from 'immutable'; | ||
import TemplateCard from '../components/TemplateCard'; | ||
import buildModel from './buildModel'; | ||
import { title, image } from './constants'; | ||
|
||
/** | ||
* @param {immutable.Map} props.model | ||
* @param {() => void} props.saveModel | ||
*/ | ||
const Card = ({ | ||
model, | ||
saveModel, | ||
}) => ( | ||
<TemplateCard | ||
title={title} | ||
srcImage={image} | ||
onClick={() => saveModel({ attrs: buildModel(model) })} /> | ||
); | ||
|
||
Card.propTypes = { | ||
model: PropTypes.instanceOf(Map).isRequired, | ||
saveModel: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default React.memo(Card); |
74 changes: 74 additions & 0 deletions
74
ui/src/containers/Visualisations/TemplateLearningExperienceType/Editor.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,74 @@ | ||
import React, { useCallback } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Map } from 'immutable'; | ||
import DescriptionForm from '../components/DescriptionForm'; | ||
import PreviewPeriodPicker from '../components/PreviewPeriodPicker'; | ||
import Viewer from './Viewer'; | ||
|
||
/** | ||
* @param {immutable.Map} props.model - visualisation model | ||
* @param {string} props.orgTimezone | ||
* @param {(args: object) => void} props.updateModel | ||
* @param {(args: object) => void} props.setInMetadata | ||
*/ | ||
const Editor = ({ | ||
model, | ||
updateModel, | ||
}) => { | ||
const id = model.get('_id'); | ||
|
||
console.log(model.get('sourceView')); | ||
|
||
const onChangeDescription = useCallback((description) => { | ||
updateModel({ | ||
schema: 'visualisation', | ||
id, | ||
path: 'description', | ||
value: description, | ||
}); | ||
}, [id]); | ||
|
||
const onChangePreviewPeriod = useCallback((previewPeriod) => { | ||
updateModel({ | ||
schema: 'visualisation', | ||
id, | ||
path: 'previewPeriod', | ||
value: previewPeriod, | ||
}); | ||
}, [id]); | ||
|
||
return ( | ||
<div className="row"> | ||
<div className="col-md-6 left-border"> | ||
<div> | ||
<DescriptionForm | ||
visualisationId={id} | ||
description={model.get('description', '')} | ||
onChange={onChangeDescription} /> | ||
</div> | ||
</div> | ||
|
||
<div className="col-md-6"> | ||
<div className="form-group form-inline" style={{ textAlign: 'right' }}> | ||
<PreviewPeriodPicker | ||
visualisationId={id} | ||
previewPeriod={model.get('previewPeriod')} | ||
onChange={onChangePreviewPeriod} /> | ||
</div> | ||
|
||
<div style={{ height: '400px', paddingTop: 5 }}> | ||
<Viewer | ||
visualisationId={id} | ||
showSourceView={model.get('sourceView')} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
Editor.propTypes = { | ||
model: PropTypes.instanceOf(Map).isRequired, | ||
updateModel: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default Editor; |
25 changes: 25 additions & 0 deletions
25
ui/src/containers/Visualisations/TemplateLearningExperienceType/Viewer.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,25 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import SourceResults from 'ui/containers/VisualiseResults/SourceResults'; | ||
import BarChartResults from 'ui/containers/VisualiseResults/BarChartResults'; | ||
|
||
/** | ||
* @param {string} props.visualisationId | ||
* @param {boolean} props.showSourceView | ||
*/ | ||
const Viewer = ({ | ||
visualisationId, | ||
showSourceView, | ||
}) => { | ||
if (showSourceView) { | ||
return <SourceResults id={visualisationId} />; | ||
} | ||
return <BarChartResults id={visualisationId} />; | ||
}; | ||
|
||
Viewer.propTypes = { | ||
visualisationId: PropTypes.string.isRequired, | ||
showSourceView: PropTypes.bool.isRequired, | ||
}; | ||
|
||
export default React.memo(Viewer); |
21 changes: 21 additions & 0 deletions
21
ui/src/containers/Visualisations/TemplateLearningExperienceType/buildModel.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,21 @@ | ||
import { Map } from 'immutable'; | ||
import { TEMPLATE_LEARNING_EXPERIENCE_TYPE } from 'lib/constants/visualise'; | ||
import { LAST_7_DAYS } from 'ui/utils/constants'; | ||
import { description } from './constants'; | ||
|
||
/** | ||
* @param {immutable.Map} model | ||
* @returns {immutable.Map} | ||
*/ | ||
const buildModel = model => | ||
model | ||
.set('type', TEMPLATE_LEARNING_EXPERIENCE_TYPE) | ||
.set('description', description) | ||
.set('axesgroup', new Map({ optionKey: 'statement.context.contextActivities.grouping', searchString: 'statement.context.contextActivities.grouping' })) | ||
.set('axesoperator', 'uniqueCount') | ||
.set('axesvalue', new Map({ optionKey: 'statements', searchString: 'Statements' })) | ||
.set('axesxLabel', 'Statements') | ||
.set('axesyLabel', 'Learning Experience Types') | ||
.set('previewPeriod', LAST_7_DAYS); | ||
|
||
export default buildModel; |
5 changes: 5 additions & 0 deletions
5
ui/src/containers/Visualisations/TemplateLearningExperienceType/constants.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,5 @@ | ||
import { LEADERBOARD_GREY_IMAGE } from 'ui/components/VisualiseIcon/assets'; | ||
|
||
export const title = 'What are the most popular learning experience activity types?'; | ||
export const description = 'What are the most popular learning experience activity types?'; | ||
export const image = LEADERBOARD_GREY_IMAGE; |
25 changes: 25 additions & 0 deletions
25
ui/src/containers/Visualisations/TemplateLearningExperienceType/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,25 @@ | ||
import { compose } from 'recompose'; | ||
import PropTypes from 'prop-types'; | ||
import { Map } from 'immutable'; | ||
import { connect } from 'react-redux'; | ||
import { updateModel } from 'ui/redux/modules/models'; | ||
import { setInMetadata } from 'ui/redux/modules/metadata'; | ||
import Editor from './Editor'; | ||
|
||
/** | ||
* @param {immutable.Map} props.model - visualisation model | ||
* @param {string} props.orgTimezone | ||
*/ | ||
const TemplateLearningExperienceType = compose( | ||
connect( | ||
() => ({}), | ||
{ updateModel, setInMetadata }, | ||
), | ||
)(Editor); | ||
|
||
TemplateLearningExperienceType.propTypes = { | ||
model: PropTypes.instanceOf(Map).isRequired, | ||
orgTimezone: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default TemplateLearningExperienceType; |
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
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
Oops, something went wrong.