-
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.
- Loading branch information
Showing
10 changed files
with
222 additions
and
69 deletions.
There are no files selected for viewing
Binary file not shown.
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
45 changes: 45 additions & 0 deletions
45
..._modules/capture-core/src/components/DataEntry/dataEntryInfoWidgets/withFeedbackWidget.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,45 @@ | ||
// @flow | ||
import * as React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import getDataEntryKey from '../common/getDataEntryKey'; | ||
import withInfoWidget from './withInfoWidget'; | ||
|
||
type Props = { | ||
feedbackItems: Array<any>, | ||
|
||
}; | ||
|
||
const getFeedbackWidget = () => | ||
class FeedbackWidgetBuilder extends React.Component<Props> { | ||
renderFeedbackItems = (feedbackItems: any) => | ||
(<div> | ||
{feedbackItems.displayTexts && | ||
feedbackItems.displayTexts.map(item => (<div key={item}>{item}</div>))} | ||
</div>) | ||
|
||
render = () => { | ||
const { feedbackItems } = this.props; | ||
return ( | ||
<div> | ||
{feedbackItems && this.renderFeedbackItems(feedbackItems)} | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
|
||
const mapStateToProps = (state: ReduxState, props: any) => { | ||
const itemId = state.dataEntries[props.id].itemId; | ||
const key = getDataEntryKey(props.id, itemId); | ||
return { | ||
feedbackItems: state.rulesEffectsFeedback && state.rulesEffectsFeedback[key] ? | ||
state.rulesEffectsFeedback[key] : null, | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = () => ({}); | ||
|
||
export default () => | ||
(InnerComponent: React.ComponentType<any>) => | ||
// $FlowSuppress | ||
withInfoWidget()(InnerComponent, connect(mapStateToProps, mapDispatchToProps, null, { withRef: true })(getFeedbackWidget())); |
40 changes: 40 additions & 0 deletions
40
...core_modules/capture-core/src/components/DataEntry/dataEntryInfoWidgets/withInfoWidget.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,40 @@ | ||
// @flow | ||
|
||
import * as React from 'react'; | ||
|
||
type Props = { | ||
infoWidgets: Array<React.Component<any>> | ||
}; | ||
|
||
const getInfoWidget = (InnerComponent: React.ComponentType<any>, Widget: React.ComponentType<any>) => | ||
class InfoWidgetBuilder extends React.Component<Props> { | ||
innerInstance: ?any; | ||
getInfoWidgets = () => { | ||
const infoWidgets = this.props.infoWidgets; | ||
const widget = this.getWidget(infoWidgets ? infoWidgets.length : 0); | ||
return infoWidgets ? [...infoWidgets, widget] : [widget]; | ||
}; | ||
getWidget = (key: any) => | ||
( | ||
<Widget | ||
key={key} | ||
{...this.props} | ||
/>) | ||
render = () => { | ||
const { infoWidgets, ...passOnProps } = this.props; | ||
|
||
return ( | ||
<div> | ||
<InnerComponent | ||
ref={(innerInstance) => { this.innerInstance = innerInstance; }} | ||
infoWidgets={this.getInfoWidgets()} | ||
{...passOnProps} | ||
/> | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
export default () => | ||
(InnerComponent: React.ComponentType<any>, Widget: React.ComponentType<any>) => | ||
getInfoWidget(InnerComponent, Widget); |
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.