2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-05-29 16:28:05 +02:00
|
|
|
import React from 'react';
|
2015-07-01 15:28:48 +02:00
|
|
|
import Router from 'react-router';
|
|
|
|
|
2015-07-09 15:44:20 +02:00
|
|
|
import PieceListStore from '../../stores/piece_list_store';
|
|
|
|
import PieceListActions from '../../actions/piece_list_actions';
|
|
|
|
|
2015-07-01 19:05:47 +02:00
|
|
|
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
|
|
|
|
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
|
|
|
|
import Tooltip from 'react-bootstrap/lib/Tooltip';
|
|
|
|
|
2015-07-09 14:04:48 +02:00
|
|
|
import AccordionListItemEditionWidget from './accordion_list_item_edition_widget';
|
|
|
|
|
2015-06-02 14:25:26 +02:00
|
|
|
import { getLangText } from '../../utils/lang_utils';
|
2015-06-01 11:51:03 +02:00
|
|
|
|
2015-05-29 16:28:05 +02:00
|
|
|
let AccordionListItem = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
className: React.PropTypes.string,
|
2015-06-05 11:06:36 +02:00
|
|
|
content: React.PropTypes.object,
|
|
|
|
children: React.PropTypes.object
|
2015-05-29 16:28:05 +02:00
|
|
|
},
|
2015-07-09 14:04:48 +02:00
|
|
|
|
|
|
|
mixins: [Router.Navigation],
|
|
|
|
|
2015-07-09 15:44:20 +02:00
|
|
|
componentDidMount() {
|
|
|
|
if(this.props.content.num_editions !== 0) {
|
|
|
|
PieceListActions.fetchFirstEditionForPiece(this.props.content.id);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onChange(state) {
|
|
|
|
this.setState(state);
|
2015-07-01 15:28:48 +02:00
|
|
|
},
|
2015-07-09 14:04:48 +02:00
|
|
|
|
2015-07-01 19:05:47 +02:00
|
|
|
getGlyphicon(){
|
|
|
|
if (this.props.content.requestAction){
|
|
|
|
return (
|
|
|
|
<OverlayTrigger delay={500} placement="left"
|
2015-07-03 19:08:56 +02:00
|
|
|
overlay={<Tooltip>{getLangText('You have actions pending in one of your editions')}</Tooltip>}>
|
2015-07-01 19:05:47 +02:00
|
|
|
<Glyphicon glyph='bell' />
|
|
|
|
</OverlayTrigger>);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
2015-07-09 14:04:48 +02:00
|
|
|
|
2015-05-29 16:28:05 +02:00
|
|
|
render() {
|
|
|
|
return (
|
2015-06-01 11:51:03 +02:00
|
|
|
<div className="row">
|
|
|
|
<div className={this.props.className}>
|
|
|
|
<div className="wrapper">
|
2015-07-01 13:54:58 +02:00
|
|
|
<div className="col-xs-4 col-sm-3 col-md-2 col-lg-2 clear-paddings">
|
2015-07-01 15:28:48 +02:00
|
|
|
<div className="thumbnail-wrapper" onClick={this.handleClick}>
|
2015-07-01 13:54:58 +02:00
|
|
|
<img src={this.props.content.thumbnail} />
|
|
|
|
</div>
|
2015-06-01 11:51:03 +02:00
|
|
|
</div>
|
2015-07-01 13:54:58 +02:00
|
|
|
<div className="col-xs-8 col-sm-9 col-md-9 col-lg-9 col-md-offset-1 col-lg-offset-1 accordion-list-item-header">
|
2015-07-02 14:40:04 +02:00
|
|
|
<OverlayTrigger delay={500} placement="left"
|
|
|
|
overlay={<Tooltip>{this.props.content.title}</Tooltip>}>
|
|
|
|
<h1 className="truncate" onClick={this.handleClick}>{this.props.content.title}</h1>
|
|
|
|
</OverlayTrigger>
|
2015-06-02 14:25:26 +02:00
|
|
|
<h3>{getLangText('by %s', this.props.content.artist_name)}</h3>
|
2015-07-08 11:32:55 +02:00
|
|
|
<div>
|
2015-07-01 13:54:58 +02:00
|
|
|
<span>{this.props.content.date_created.split('-')[0]}</span>
|
2015-07-09 15:44:20 +02:00
|
|
|
<AccordionListItemEditionWidget
|
2015-07-09 17:01:08 +02:00
|
|
|
piece={this.props.content}/>
|
2015-07-08 11:32:55 +02:00
|
|
|
{/* <a href={this.props.content.license_type.url} target="_blank" className="pull-right">
|
2015-07-01 18:58:13 +02:00
|
|
|
{getLangText('%s license', this.props.content.license_type.code)}
|
2015-07-08 11:32:55 +02:00
|
|
|
</a> */}
|
2015-07-09 14:04:48 +02:00
|
|
|
|
2015-07-08 11:32:55 +02:00
|
|
|
</div>
|
2015-06-01 11:51:03 +02:00
|
|
|
</div>
|
|
|
|
<span style={{'clear': 'both'}}></span>
|
2015-07-01 19:05:47 +02:00
|
|
|
<div className="request-action-batch">
|
|
|
|
{this.getGlyphicon()}
|
|
|
|
</div>
|
2015-05-29 16:28:05 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2015-06-01 11:51:03 +02:00
|
|
|
{this.props.children}
|
|
|
|
</div>
|
2015-05-29 16:28:05 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default AccordionListItem;
|