mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 15:44:59 +00:00
Add/remove one file in Content Manager for Bookshelf
This commit is contained in:
parent
5f0618f94c
commit
2bdf226490
@ -134,18 +134,6 @@ class ImgPreview extends React.Component {
|
||||
this.props.onDrop(e);
|
||||
}
|
||||
|
||||
handleMouseEnter = (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.setState({ isOver: true });
|
||||
}
|
||||
|
||||
handleMouseLeave = (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.setState({ isOver: false });
|
||||
}
|
||||
|
||||
// TODO change logic to depend on the type
|
||||
isPictureType = (fileName) => /\.(jpe?g|png|gif)$/i.test(fileName);
|
||||
|
||||
@ -188,12 +176,10 @@ class ImgPreview extends React.Component {
|
||||
)}
|
||||
onDragOver={this.handleDragOver}
|
||||
onDragEnter={this.handleDragEnter}
|
||||
onMouseEnter={this.handleMouseEnter}
|
||||
onMouseLeave={this.handleMouseLeave}
|
||||
style={containerStyle}
|
||||
>
|
||||
<div
|
||||
className={cn(this.state.isDraging && styles.overlay || this.state.isOver && !this.state.isOverArrow && styles.overlay)}
|
||||
className={cn(this.state.isDraging && styles.overlay)}
|
||||
onDragLeave={this.handleDragLeave}
|
||||
onDragOver={this.handleDragOver}
|
||||
onDrop={this.handleDrop}
|
||||
@ -203,13 +189,13 @@ class ImgPreview extends React.Component {
|
||||
displayHint={isEmpty(files)}
|
||||
onClick={onBrowseClick}
|
||||
onDrop={this.handleDrop}
|
||||
showWhiteHint={this.state.isDraging || this.state.isOver && !this.state.isOverArrow || isEmpty(files)}
|
||||
showWhiteHint={this.state.isDraging || isEmpty(files)}
|
||||
/>
|
||||
|
||||
{ !isEmpty(imgURL) && this.renderContent() }
|
||||
|
||||
<ImgPreviewArrow
|
||||
enable={this.state.isOver && isArray(files) && size(files) > 1}
|
||||
enable={isArray(files) && size(files) > 1}
|
||||
onClick={this.handleClick}
|
||||
onMouseEnter={(e) => this.setState({ isOverArrow: true })}
|
||||
onMouseLeave={(e) => this.setState({ isOverArrow: false })}
|
||||
@ -218,7 +204,7 @@ class ImgPreview extends React.Component {
|
||||
/>
|
||||
|
||||
<ImgPreviewArrow
|
||||
enable={this.state.isOver && isArray(files) && size(files) > 1}
|
||||
enable={isArray(files) && size(files) > 1}
|
||||
onClick={this.handleClick}
|
||||
onMouseEnter={(e) => this.setState({ isOverArrow: true })}
|
||||
onMouseLeave={(e) => this.setState({ isOverArrow: false })}
|
||||
|
||||
@ -198,13 +198,19 @@ module.exports = {
|
||||
case 'oneToManyMorph':
|
||||
case 'manyToManyMorph':
|
||||
const transformToArrayID = (array) => {
|
||||
return _.isArray(array) ? array.map(value => {
|
||||
if (_.isPlainObject(value)) {
|
||||
return value._id || value.id;
|
||||
}
|
||||
if(_.isArray(array)) {
|
||||
return array.map(value => {
|
||||
if (_.isPlainObject(value)) {
|
||||
return value._id || value.id;
|
||||
}
|
||||
|
||||
return value;
|
||||
}) : transformToArrayID(_.isEmpty(array) ? [] : [array]);
|
||||
return value;
|
||||
})
|
||||
}
|
||||
|
||||
if (_.isPlainObject(array)) {
|
||||
return _.isEmpty(array) ? [] : transformToArrayID([array]);
|
||||
}
|
||||
};
|
||||
|
||||
// Compare array of ID to find deleted files.
|
||||
|
||||
@ -190,13 +190,19 @@ module.exports = {
|
||||
case 'oneToManyMorph':
|
||||
case 'manyToManyMorph':
|
||||
const transformToArrayID = (array) => {
|
||||
return _.isArray(array) ? array.map(value => {
|
||||
if (_.isPlainObject(value)) {
|
||||
return value._id || value.id;
|
||||
}
|
||||
if (_.isArray(array)) {
|
||||
return array.map(value => {
|
||||
if (_.isPlainObject(value)) {
|
||||
return value._id || value.id;
|
||||
}
|
||||
|
||||
return value;
|
||||
}) : transformToArrayID(_.isEmpty(array) ? [] : [array]);
|
||||
return value;
|
||||
})
|
||||
}
|
||||
|
||||
if (_.isPlainObject(array)) {
|
||||
return _.isEmpty(array) ? [] : transformToArrayID([array]);
|
||||
}
|
||||
};
|
||||
|
||||
// Compare array of ID to find deleted files.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user