forked from Bahmni/implementer-interface
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yamuna | FBE - 22 | Implementation of form conditions Editor #4
Open
yamunachukka
wants to merge
32
commits into
master
Choose a base branch
from
control-events
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 20 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
42b9414
Sneha | FBE-29 | When a form is edited after publish copy transaltion…
bsneha90TW 1c8a98d
Vinay | FBE - 32 | Add form name in translations page and save the tr…
vinay-ThoughtWorks e82f368
Sowmika, Alekhya | FBE-70 | Add save button on preview popup
sowmika148 3795f46
Sowmika, Alekhya | FBE-70 | Use renderWithControls instead of container
sowmika148 0cd10fc
Sowmika, Alekhya | FBE-70 | Execute formSave event when save button o…
sowmika148 dbc4ebe
Sowmika, Alekhya | FBE-70 | Handle errors from onFormSave event
sowmika148 f7878d5
Sowmika, Swetha | FBE-34 | Fix form event getting copied while creati…
swetha1992 dedec8f
Vinay | FBE - 32 | Add saveFormNameTranslations call on form publish
vinay-ThoughtWorks 2782daa
Vinay | FBE - 32 | Handle form name change
vinay-ThoughtWorks 3a4594e
Vinay | FBE - 66 | Fix form controls scroll in minimum resolution scr…
vinay-ThoughtWorks 200ff3d
Vinay, Swetha | FBE-73 | Support form name translations for bulk impo…
vinay-ThoughtWorks e624530
Vinay, Swetha | FBE-73 | Fix tests
vinay-ThoughtWorks ae8ea17
Vinay | FBE - 32 | Display recently saved name even on locale change
vinay-ThoughtWorks 472ad18
Vinay | FBE - 66 | Fix scroll issue with minimal resolution for ubuntu
vinay-ThoughtWorks 3169ab0
Yamuna | FBE - 22 | Add full screen viewer for all form events
4b882cd
Yamuna | FBE - 22 | Change all controls form viewer Obs dropdown to r…
a824f8e
Yamuna | FBE - 22 | Move styles to css class
de38372
Yamuna | FBE - 22 | Add proper spaces in Css file & Remove setState B…
571a43c
Yamuna | FBE - 22 | Add unit tests for fbe-22 functionality
efc0b21
Yamuna | FBE - 22 | Css changes to have vertical scroll in form condi…
5555634
Yamuna | FBE - 22 | Modify code to support code review comments
03867f0
Yamuna | FBE - 22 | Remove unused code
177d9a3
Yamuna | FBE - 22 | Add support for reading obscontrol in hierrachy a…
86075db
Yamuna | FBE - 22 | Add unit test for getObsControlEvents method in F…
d34d454
Yamuna | FBE - 22 | Resolving conflicts with master
5038c3f
Yamuna | FBE - 22 | Applying Resolve conflicts with master
e483288
Revert "Yamuna | FBE - 22 | Applying Resolve conflicts with master"
f46b2e9
Revert "Yamuna | FBE - 22 | Resolving conflicts with master"
e4fc8e2
Yamuna | FBE - 22 | Applying Resolve conflicts with master
dec8b99
Yamuna | FBE-22 | Add tests for unit test coverage
603aa3a
Yamuna | FBE - 22 | Update unittests to meet coverage percentage
de772fe
Yamuna | FBE - 22 | Fix line spacing between label and code editor in…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,51 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
import { setChangedProperty } from '../actions/control'; | ||
|
||
export class FormConditionsContainer extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { events: {} }; | ||
} | ||
|
||
componentWillUpdate(newProps) { | ||
const updatedEvents = newProps.formDetails && newProps.formDetails.events; | ||
if (updatedEvents && this.state.events !== updatedEvents) { | ||
this.setState({ events: updatedEvents }); | ||
this.props.updateFormEvents(updatedEvents); | ||
} | ||
} | ||
|
||
updateProperty() { | ||
const properties = { [this.props.eventProperty]: true, formTitle: this.props.formTitle }; | ||
this.props.dispatch(setChangedProperty(properties)); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="form-controls-container"> | ||
<label>{this.props.label}</label> | ||
<button onClick={() => this.updateProperty()}> | ||
<i aria-hidden="true" className="fa fa-code" /> | ||
</button> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
FormConditionsContainer.propTypes = { | ||
dispatch: PropTypes.func, | ||
eventProperty: PropTypes.string, | ||
formDetails: PropTypes.object, | ||
formTitle: PropTypes.string, | ||
label: PropTypes.string, | ||
updateFormEvents: PropTypes.func, | ||
}; | ||
|
||
const mapStateToProps = (state) => ({ | ||
formDetails: state.formDetails, | ||
}); | ||
|
||
export default connect(mapStateToProps)(FormConditionsContainer); |
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,125 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { JSHINT } from 'jshint'; | ||
import ObsControlScriptEditorModal from 'form-builder/components/ObsControlScriptEditorModal'; | ||
|
||
window.JSHINT = JSHINT; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this required here? ObsControlScriptEditorModal has it already? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not required. removed here |
||
|
||
export default class FormConditionsModal extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { selectedControlEventTitleId: undefined, | ||
selectedControlEventTitleName: undefined, selectedControlScript: undefined }; | ||
this.selectedControlOption = undefined; | ||
this.prevSelectedControlOption = undefined; | ||
this.selectedControlTitleId = undefined; | ||
this.selectedControlTitleName = undefined; | ||
this.selectedControlScript = undefined; | ||
this.updateSelectedOption = this.updateSelectedOption.bind(this); | ||
} | ||
|
||
updateSelectedOption(element) { | ||
this.prevSelectedControlOption = this.selectedControlOption; | ||
this.selectedControlOption = element.target.value; | ||
const selectedControlEventObj = this.props.controlEvents.find(control => | ||
control.id === this.selectedControlOption); | ||
const selectedControlScriptObj = selectedControlEventObj ? | ||
selectedControlEventObj.events : undefined; | ||
this.selectedControlTitleId = selectedControlEventObj ? selectedControlEventObj.id : undefined; | ||
this.selectedControlTitleName = selectedControlEventObj ? selectedControlEventObj.name : | ||
undefined; | ||
this.selectedControlScript = selectedControlScriptObj ? | ||
selectedControlScriptObj.onValueChange : undefined; | ||
if (this.selectedControlOption !== this.prevSelectedControlOption) { | ||
this.setState({ selectedControlEventTitleId: this.selectedControlTitleId }); | ||
this.setState({ selectedControlEventTitleName: this.selectedControlTitleName }); | ||
this.setState({ selectedControlScript: this.selectedControlScript }); | ||
} | ||
} | ||
|
||
showObsControlScriptEditorModal(controlScript, controlEventTitleId, controlEventTitleName) { | ||
if (controlEventTitleId !== undefined) { | ||
return (<ObsControlScriptEditorModal | ||
close={this.props.close} | ||
script={controlScript} | ||
titleId={controlEventTitleId} | ||
titleName={controlEventTitleName} | ||
updateScript={this.props.updateScript} | ||
/> | ||
); | ||
} | ||
return null; | ||
} | ||
render() { | ||
const obs = this.props.controlEvents !== undefined ? this.props.controlEvents : []; | ||
const ObsWithControlEvents = obs.filter(o => o.events !== undefined); | ||
const obsWithoutControlEvents = obs.filter(o => o.events === undefined); | ||
const formDetailEvents = this.props.formDetails.events ? this.props.formDetails.events | ||
: { onFormInit: undefined, onFormSave: undefined }; | ||
return ( | ||
<div className="form-conditions-modal-container"> | ||
<h2 className="header-title">{this.props.formTitle} - Form Conditions</h2> | ||
|
||
<div className="left-panel" > | ||
<br /> | ||
{ this.showObsControlScriptEditorModal(formDetailEvents.onFormInit, null, | ||
'Form Event')} | ||
<br /> | ||
{ this.showObsControlScriptEditorModal(formDetailEvents.onFormSave, null, | ||
'Save Event')} | ||
<br /> | ||
</div> | ||
<div className="right-panel" > | ||
<br /> | ||
<div> | ||
<label className="label" >Control Events:</label> | ||
<select className="obs-dropdown" onChange={this.updateSelectedOption}> | ||
<option key="0" value="0" >Select Option</option>) | ||
{obsWithoutControlEvents.map((e) => | ||
<option key={e.id} value={e.id} >{e.name}</option>)} | ||
</select> | ||
</div> | ||
<span className="line-break-3"></span> | ||
<div> | ||
{ | ||
ObsWithControlEvents.map((e) => | ||
this.showObsControlScriptEditorModal(e.events.onValueChange, e.id, e.name) | ||
) | ||
} | ||
</div> | ||
{ | ||
<div> {this.showObsControlScriptEditorModal(this.state.selectedControlScript, | ||
this.state.selectedControlEventTitleId, this.state.selectedControlEventTitleName)} | ||
<span className="line-break-2"></span> | ||
</div> | ||
} | ||
</div> | ||
|
||
<div className="button-wrapper" > | ||
<button className="btn" onClick={() => this.props.close()} type="reset"> | ||
Cancel | ||
</button> | ||
</div> | ||
|
||
</div> | ||
); | ||
} | ||
} | ||
|
||
FormConditionsModal.propTypes = { | ||
close: PropTypes.func.isRequired, | ||
controlEvents: PropTypes.array, | ||
formDetails: PropTypes.shape({ | ||
events: PropTypes.object, | ||
}), | ||
formTitle: PropTypes.string, | ||
selectedControlEventTitleId: PropTypes.string, | ||
selectedControlEventTitleName: PropTypes.string, | ||
selectedControlScript: PropTypes.string, | ||
updateScript: PropTypes.func.isRequired, | ||
}; | ||
|
||
FormConditionsModal.defaultProps = { | ||
formDetails: { events: {} }, | ||
}; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are you using this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.Forgot to delete.Deleted Now