11var React = require ( 'react/addons' )
22var ReactRouter = require ( 'react-router' )
3+ var Link = ReactRouter . Link
34var moment = require ( 'moment' )
45
56var ForceUpdate = require ( '../Mixins/ForceUpdate' )
@@ -13,6 +14,31 @@ module.exports = React.createClass({
1314 articles : React . PropTypes . array ,
1415 showOnlyWithTag : React . PropTypes . func
1516 } ,
17+ handleArticleClikck : function ( article ) {
18+ if ( article . type === 'code' ) {
19+ return function ( ) {
20+ var params = this . getParams ( )
21+
22+ this . transitionTo ( 'codes' , {
23+ userName : params . userName ,
24+ planetName : params . planetName ,
25+ localId : article . localId
26+ } )
27+ } . bind ( this )
28+ }
29+
30+ if ( article . type === 'note' ) {
31+ return function ( ) {
32+ var params = this . getParams ( )
33+
34+ this . transitionTo ( 'notes' , {
35+ userName : params . userName ,
36+ planetName : params . planetName ,
37+ localId : article . localId
38+ } )
39+ } . bind ( this )
40+ }
41+ } ,
1642 render : function ( ) {
1743 var articles = this . props . articles . map ( function ( article ) {
1844 var tags = article . Tags . length > 0 ? article . Tags . map ( function ( tag ) {
@@ -28,24 +54,15 @@ module.exports = React.createClass({
2854 var handleClick
2955
3056 if ( article . type === 'code' ) {
31-
32- handleClick = function ( ) {
33- this . transitionTo ( 'codes' , {
34- userName : params . userName ,
35- planetName : params . planetName ,
36- localId : article . localId
37- } )
38- } . bind ( this )
39-
4057 return (
41- < li onClick = { handleClick } key = { 'code-' + article . id } >
58+ < li onClick = { this . handleArticleClikck ( article ) } key = { 'code-' + article . id } >
4259 < div className = { 'articleItem' + ( isActive ? ' active' : '' ) } >
4360 < div className = 'itemLeft' >
4461 < ProfileImage className = 'profileImage' size = '25' email = { article . User . email } />
4562 < i className = 'fa fa-code fa-fw' > </ i >
4663 </ div >
4764 < div className = 'itemRight' >
48- < div className = 'updatedAt ' > { moment ( article . updatedAt ) . fromNow ( ) } </ div >
65+ < div className = 'itemInfo ' > { moment ( article . updatedAt ) . fromNow ( ) } by < span className = 'userProfileName' > { article . User . profileName } </ span > </ div >
4966 < div className = 'description' > { article . description . length > 50 ? article . description . substring ( 0 , 50 ) + ' …' : article . description } </ div >
5067 < div className = 'tags' > < i className = 'fa fa-tags' /> { tags } </ div >
5168 </ div >
@@ -55,24 +72,16 @@ module.exports = React.createClass({
5572 )
5673 }
5774
58- handleClick = function ( ) {
59- this . transitionTo ( 'notes' , {
60- userName : params . userName ,
61- planetName : params . planetName ,
62- localId : article . localId
63- } )
64- } . bind ( this )
65-
6675 return (
67- < li onClick = { handleClick } key = { 'note-' + article . id } >
76+ < li onClick = { this . handleArticleClikck ( article ) } key = { 'note-' + article . id } >
6877 < div className = { 'articleItem blueprintItem' + ( isActive ? ' active' : '' ) } >
6978 < div className = 'itemLeft' >
7079 < ProfileImage className = 'profileImage' size = '25' email = { article . User . email } />
7180 < i className = 'fa fa-file-text-o fa-fw' > </ i >
7281 </ div >
7382
7483 < div className = 'itemRight' >
75- < div className = 'updatedAt ' > { moment ( article . updatedAt ) . fromNow ( ) } </ div >
84+ < div className = 'itemInfo ' > { moment ( article . updatedAt ) . fromNow ( ) } by < span className = 'userProfileName' > { article . User . profileName } </ span > </ div >
7685 < div className = 'description' > { article . title } </ div >
7786 < div className = 'tags' > < i className = 'fa fa-tags' /> { tags } </ div >
7887 </ div >
0 commit comments