mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 08:53:14 +00:00
File move to list view and inaccurate refresh after moving
This commit is contained in:
@@ -65,6 +65,7 @@ class DirentListView extends React.Component {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
isMutipleOperation: true,
|
isMutipleOperation: true,
|
||||||
activeDirent: null,
|
activeDirent: null,
|
||||||
|
isListDropTipShow: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.isRepoOwner = props.currentRepoInfo.owner_email === username;
|
this.isRepoOwner = props.currentRepoInfo.owner_email === username;
|
||||||
@@ -525,6 +526,42 @@ class DirentListView extends React.Component {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onTableDragEnter = (e) => {
|
||||||
|
if (e.target.className === 'table-container ') {
|
||||||
|
this.setState({isListDropTipShow: true});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onTableDragOver = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.dataTransfer.dropEffect = 'move';
|
||||||
|
}
|
||||||
|
|
||||||
|
onTableDragLeave = (e) => {
|
||||||
|
if (e.target.className === 'table-container table-drop-active') {
|
||||||
|
this.setState({isListDropTipShow: false})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tableDrop = (e) => {
|
||||||
|
e.persist();
|
||||||
|
this.setState({isListDropTipShow: false});
|
||||||
|
if (e.dataTransfer.files.length) { // uploaded files
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let dragStartItemData = e.dataTransfer.getData('applicaiton/drag-item-info');
|
||||||
|
dragStartItemData = JSON.parse(dragStartItemData);
|
||||||
|
|
||||||
|
let {nodeDirent, nodeParentPath, nodeRootPath} = dragStartItemData;
|
||||||
|
|
||||||
|
if (e.target.className === 'table-container table-drop-active') {
|
||||||
|
if (nodeRootPath === this.props.path || nodeParentPath === this.props.path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.props.onItemMove(this.props.currentRepoInfo, nodeDirent, this.props.path, nodeParentPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { direntList, sortBy, sortOrder } = this.props;
|
const { direntList, sortBy, sortOrder } = this.props;
|
||||||
|
|
||||||
@@ -538,7 +575,16 @@ class DirentListView extends React.Component {
|
|||||||
const sortIcon = sortOrder == 'asc' ? <span className="fas fa-caret-up"></span> : <span className="fas fa-caret-down"></span>;
|
const sortIcon = sortOrder == 'asc' ? <span className="fas fa-caret-up"></span> : <span className="fas fa-caret-down"></span>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="table-container" onMouseDown={this.onContainerMouseDown} onContextMenu={this.onContainerContextMenu} onClick={this.onContainerClick}>
|
<div
|
||||||
|
className={`table-container ${this.state.isListDropTipShow ? 'table-drop-active' : ''}`}
|
||||||
|
onMouseDown={this.onContainerMouseDown}
|
||||||
|
onContextMenu={this.onContainerContextMenu}
|
||||||
|
onClick={this.onContainerClick}
|
||||||
|
onDragEnter={this.onTableDragEnter}
|
||||||
|
onDragOver={this.onTableDragOver}
|
||||||
|
onDragLeave={this.onTableDragLeave}
|
||||||
|
onDrop={this.tableDrop}
|
||||||
|
>
|
||||||
<table>
|
<table>
|
||||||
<thead onMouseDown={this.onThreadMouseDown} onContextMenu={this.onThreadContextMenu}>
|
<thead onMouseDown={this.onThreadMouseDown} onContextMenu={this.onThreadContextMenu}>
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -118,6 +118,18 @@
|
|||||||
.table-container {
|
.table-container {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 0 1rem 10rem;
|
padding: 0 1rem 10rem;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-drop-active::before {
|
||||||
|
border: 1px solid rgba(69,170,242);
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
left: 0;
|
||||||
|
z-index: -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cur-view-content .article {
|
.cur-view-content .article {
|
||||||
|
@@ -141,6 +141,11 @@ class LibContentContainer extends React.Component {
|
|||||||
|
|
||||||
onItemsScroll = (e) => {
|
onItemsScroll = (e) => {
|
||||||
let target = e.target;
|
let target = e.target;
|
||||||
|
|
||||||
|
if (target.scrollTop === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (target.scrollTop + target.clientHeight + 1 >= target.scrollHeight) {
|
if (target.scrollTop + target.clientHeight + 1 >= target.scrollHeight) {
|
||||||
this.props.onListContainerScroll();
|
this.props.onListContainerScroll();
|
||||||
}
|
}
|
||||||
|
@@ -306,6 +306,7 @@ class LibContentView extends React.Component {
|
|||||||
|
|
||||||
// update data
|
// update data
|
||||||
this.loadDirentList(path);
|
this.loadDirentList(path);
|
||||||
|
this.resetShowLength();
|
||||||
|
|
||||||
if (!this.isNeedUpdateHistoryState) {
|
if (!this.isNeedUpdateHistoryState) {
|
||||||
this.isNeedUpdateHistoryState = true;
|
this.isNeedUpdateHistoryState = true;
|
||||||
@@ -405,7 +406,6 @@ class LibContentView extends React.Component {
|
|||||||
if (!this.state.repoEncrypted && direntList.length) {
|
if (!this.state.repoEncrypted && direntList.length) {
|
||||||
this.getThumbnails(repoID, path, this.state.direntList);
|
this.getThumbnails(repoID, path, this.state.direntList);
|
||||||
}
|
}
|
||||||
this.resetShowLength();
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
isDirentListLoading: false,
|
isDirentListLoading: false,
|
||||||
@@ -729,12 +729,12 @@ class LibContentView extends React.Component {
|
|||||||
nodeParentPath = this.state.path;
|
nodeParentPath = this.state.path;
|
||||||
}
|
}
|
||||||
let direntPath = Utils.joinPath(nodeParentPath, dirName);
|
let direntPath = Utils.joinPath(nodeParentPath, dirName);
|
||||||
seafileAPI.moveDir(repoID, destRepo.repo_id,moveToDirentPath, nodeParentPath, dirName).then(res => {
|
seafileAPI.moveDir(repoID, destRepo.repo_id, moveToDirentPath, nodeParentPath, dirName).then(res => {
|
||||||
let nodeName = res.data[0].obj_name;
|
let nodeName = res.data[0].obj_name;
|
||||||
if (this.state.currentMode === 'column') {
|
if (this.state.currentMode === 'column') {
|
||||||
this.moveTreeNode(direntPath, moveToDirentPath, destRepo, nodeName);
|
this.moveTreeNode(direntPath, moveToDirentPath, destRepo, nodeName);
|
||||||
}
|
}
|
||||||
this.moveDirent(direntPath);
|
this.moveDirent(direntPath, moveToDirentPath);
|
||||||
|
|
||||||
let message = gettext('Successfully moved %(name)s.');
|
let message = gettext('Successfully moved %(name)s.');
|
||||||
message = message.replace('%(name)s', dirName);
|
message = message.replace('%(name)s', dirName);
|
||||||
@@ -996,8 +996,12 @@ class LibContentView extends React.Component {
|
|||||||
// else do nothing
|
// else do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
moveDirent = (direntPath) => {
|
moveDirent = (direntPath, moveToDirentPath=null) => {
|
||||||
let name = direntPath.slice(direntPath.lastIndexOf('/') + 1);
|
let name = direntPath.slice(direntPath.lastIndexOf('/') + 1);
|
||||||
|
if (moveToDirentPath === this.state.path) {
|
||||||
|
this.loadDirentList(this.state.path)
|
||||||
|
return;
|
||||||
|
}
|
||||||
let direntList = this.state.direntList.filter(item => {
|
let direntList = this.state.direntList.filter(item => {
|
||||||
return item.name !== name;
|
return item.name !== name;
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user