diff options
Diffstat (limited to 'web/react/components/file_attachment_list.jsx')
-rw-r--r-- | web/react/components/file_attachment_list.jsx | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/web/react/components/file_attachment_list.jsx b/web/react/components/file_attachment_list.jsx new file mode 100644 index 000000000..0b52d6a70 --- /dev/null +++ b/web/react/components/file_attachment_list.jsx @@ -0,0 +1,47 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +var ViewImageModal = require('./view_image.jsx'); +var FileAttachment = require('./file_attachment.jsx'); +var Constants = require('../utils/constants.jsx'); + +module.exports = React.createClass({ + displayName: "FileAttachmentList", + propTypes: { + filenames: React.PropTypes.arrayOf(React.PropTypes.string).isRequired, + postId: React.PropTypes.string.isRequired, + channelId: React.PropTypes.string, + userId: React.PropTypes.string + }, + getInitialState: function() { + return {startImgId: 0}; + }, + render: function() { + var filenames = this.props.filenames; + + var postImageModalId = "view_image_modal_" + this.props.postId; + + var postFiles = []; + for (var i = 0; i < filenames.length && i < Constants.MAX_DISPLAY_FILES; i++) { + postFiles.push(<FileAttachment key={i} filenames={filenames} index={i} imageModalId={postImageModalId} handleImageClick={this.handleImageClick} />); + } + + return ( + <div> + <div className="post-image__columns"> + {postFiles} + </div> + <ViewImageModal + channelId={this.props.channelId} + userId={this.props.userId} + modalId={postImageModalId} + startId={this.state.startImgId} + imgCount={0} + filenames={filenames} /> + </div> + ); + }, + handleImageClick: function(e) { + this.setState({startImgId: parseInt($(e.target.parentNode).attr('data-img-id'))}); + } +}); |