mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
add onPreview onRemove override on upload.
This commit is contained in:
parent
325c9c2b2b
commit
d584b20dd8
@ -172,11 +172,21 @@ const AntUpload = React.createClass({
|
||||
}
|
||||
},
|
||||
|
||||
handlePreview(file) {
|
||||
if ('onPreview' in this.props) {
|
||||
this.props.onPreview(file);
|
||||
}
|
||||
},
|
||||
|
||||
handleManualRemove(file) {
|
||||
/*eslint-disable */
|
||||
file.status = 'removed';
|
||||
/*eslint-enable */
|
||||
this.handleRemove(file);
|
||||
if ('onRemove' in this.props) {
|
||||
this.props.onRemove(file);
|
||||
} else {
|
||||
this.handleRemove(file);
|
||||
}
|
||||
},
|
||||
|
||||
onChange(info) {
|
||||
@ -235,6 +245,7 @@ const AntUpload = React.createClass({
|
||||
uploadList = (
|
||||
<UploadList listType={this.props.listType}
|
||||
items={this.state.fileList}
|
||||
onPreview={this.handlePreview}
|
||||
onRemove={this.handleManualRemove} />
|
||||
);
|
||||
}
|
||||
|
@ -28,6 +28,10 @@ export default React.createClass({
|
||||
handleClose(file) {
|
||||
this.props.onRemove(file);
|
||||
},
|
||||
handlePreview(file, e) {
|
||||
e.preventDefault();
|
||||
return this.props.onPreview(file);
|
||||
},
|
||||
componentDidUpdate() {
|
||||
if (this.props.listType !== 'picture' && this.props.listType !== 'picture-card') {
|
||||
return;
|
||||
@ -65,6 +69,7 @@ export default React.createClass({
|
||||
}
|
||||
} else {
|
||||
icon = (<a className={`${prefixCls}-list-item-thumbnail`}
|
||||
onClick={this.handlePreview.bind(this, file)}
|
||||
href={file.url}
|
||||
target="_blank"><img src={file.thumbUrl || file.url} alt={file.name} /></a>
|
||||
);
|
||||
@ -87,13 +92,13 @@ export default React.createClass({
|
||||
<div className={`${prefixCls}-list-item-info`}>
|
||||
{icon}
|
||||
{file.url
|
||||
? <a href={file.url} target="_blank" className={`${prefixCls}-list-item-name`}>{file.name}</a>
|
||||
? <a onClick={this.handlePreview.bind(this, file)} href={file.url} target="_blank" className={`${prefixCls}-list-item-name`}>{file.name}</a>
|
||||
: <span className={`${prefixCls}-list-item-name`}>{file.name}</span>}
|
||||
{
|
||||
this.props.listType === 'picture-card' && file.status !== 'uploading'
|
||||
? (
|
||||
<span>
|
||||
<a href={file.url} target="_blank" style={{ pointerEvents: file.url ? '' : 'none' }}><Icon type="eye-o" /></a>
|
||||
<a onClick={this.handlePreview.bind(this, file)} href={file.url} target="_blank" style={{ pointerEvents: file.url ? '' : 'none' }}><Icon type="eye-o" /></a>
|
||||
<Icon type="delete" onClick={this.handleClose.bind(this, file)} />
|
||||
</span>
|
||||
) : <Icon type="cross" onClick={this.handleClose.bind(this, file)} />
|
||||
|
Loading…
Reference in New Issue
Block a user