-
Notifications
You must be signed in to change notification settings - Fork 30
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
Changed "Enter Value" to "Add Remarks" #224
base: master
Are you sure you want to change the base?
Changes from 4 commits
5408f83
d6466d4
851316f
5a29ade
0959def
9f6eec3
ea8f48b
1fda699
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import RIEStatefulBase from 'riek/lib/RIEStatefulBase'; | ||
export default class TextArea extends RIEStatefulBase { | ||
keyDown = (event) => { | ||
if (event.keyCode === 27) { this.cancelEditing() } // Escape | ||
}; | ||
|
||
renderEditingComponent = () => { | ||
return <textarea | ||
rows={this.props.rows} | ||
cols={this.props.cols} | ||
disabled={this.state.loading} | ||
className={this.makeClassString()} | ||
defaultValue={this.props.value} | ||
onInput={this.textChanged} | ||
onBlur={this.finishEditing} | ||
ref="input" | ||
onKeyDown={this.keyDown} | ||
{...this.props.editProps} />; | ||
}; | ||
|
||
renderNormalComponent = () => { | ||
const value = this.state.newValue || this.props.value | ||
const spans_and_brs = [] | ||
var anySpan = false | ||
let i = 0 | ||
value.split("\n").map(line => { | ||
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. This isn't really the right use of a 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. I'm thinking about keeping the map, and using it to return the length of all the lines to see if there are only empty lines:
I'll probably end up making it a |
||
if(line.length > 0){ | ||
anySpan = true | ||
spans_and_brs.push(<span key={i}>{line}</span>) | ||
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. instead of keeping track of 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. Or, don't do this now, and at the end do something like |
||
} | ||
spans_and_brs.push(<br key={i+1} />) | ||
i += 2 | ||
}); | ||
|
||
spans_and_brs.pop() // remove last br tag | ||
if(!anySpan){ | ||
spans_and_brs.length=0 | ||
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. I'm not sure you are supposed to ever just set the length of an array to 0 in javascript. What is the purpose of this? To clear it out? If that is the case, just do Maybe I'm misreading the intent of this block though. 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. Ah, but this would require you to change the |
||
spans_and_brs.unshift(<span key="placeholder">{''}</span>) | ||
} | ||
return <span | ||
tabIndex="0" | ||
className={this.makeClassString()} | ||
onFocus={this.startEditing} | ||
onClick={this.startEditing} | ||
{...this.props.defaultProps}>{spans_and_brs}</span>; | ||
}; | ||
} |
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.
Nitpick: javascript vars don't use this format, rename to
spansAndBrs
;