-
Notifications
You must be signed in to change notification settings - Fork 75
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
Murilo Varela
committed
Jun 21, 2017
1 parent
af80a47
commit be0fc30
Showing
3 changed files
with
71 additions
and
23 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
app/assets/javascripts/components/jquery_wrappers/InputTagit.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,29 @@ | ||
import React from 'react'; | ||
|
||
class InputTagit extends React.Component { | ||
componentDidMount() { | ||
this.loadTagit(); | ||
} | ||
|
||
loadTagit() { | ||
$(this.input).tagit( | ||
this.tagitProperties() | ||
).on('change', this.props.onChange); | ||
} | ||
|
||
tagitProperties() { | ||
console.log(this.props); | ||
return { | ||
availableTags: this.props.availableLabels, | ||
readOnly: this.props.disabled, | ||
}; | ||
} | ||
|
||
render () { | ||
return ( | ||
<input ref={ input => { this.input = input } } { ...this.props.input } tabIndex="this.props.labels"/> | ||
); | ||
} | ||
} | ||
|
||
export default InputTagit; |
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 React from 'react'; | ||
import InputTagit from 'components/jquery_wrappers/InputTagit'; | ||
|
||
const StoryLabels = ({ name, className, value, availableLabels, onChange, disabled = false }) => | ||
<div> | ||
<label htmlFor={name}>{ I18n.t(`activerecord.attributes.story.${name}`) }</label> | ||
<br /> | ||
<InputTagit | ||
onChange={onChange} | ||
availableLabels={availableLabels} | ||
disabled={disabled} | ||
input={{ | ||
name, | ||
defaultValue: value, | ||
className: `form-control input-sm ${className}`, | ||
disabled, | ||
}} | ||
/> | ||
</div> | ||
|
||
export default StoryLabels; |
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