From c30597f0e2214c9bc18c1f5bb23e40a4724edadd Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Mon, 8 Nov 2021 13:39:19 +0300 Subject: [PATCH 01/11] Web: Files: Removed empty page when deleted all files at last page. --- .../Client/src/store/FilesActionsStore.js | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/products/ASC.Files/Client/src/store/FilesActionsStore.js b/products/ASC.Files/Client/src/store/FilesActionsStore.js index 38223ae131a..8442dce5b02 100644 --- a/products/ASC.Files/Client/src/store/FilesActionsStore.js +++ b/products/ASC.Files/Client/src/store/FilesActionsStore.js @@ -56,15 +56,39 @@ class FilesActionStore { } }; - updateCurrentFolder = () => { + isEmptyLastPageAfterOperation = (selectionLength) => { + const { filter, files, folders } = this.filesStore; + + return ( + filter.page > 0 && + !filter.hasNext() && + selectionLength === files.length + folders.length + ); + }; + + updateCurrentFolder = (selectionLength) => { const { clearSecondaryProgressData, } = this.uploadDataStore.secondaryProgressDataStore; const { filter, fetchFiles } = this.filesStore; - fetchFiles(this.selectedFolderStore.id, filter, true, true).finally(() => - setTimeout(() => clearSecondaryProgressData(), TIMEOUT) - ); + + let newFilter; + + if ( + selectionLength && + this.isEmptyLastPageAfterOperation(selectionLength) + ) { + newFilter = filter.clone(); + newFilter.page--; + } + + fetchFiles( + this.selectedFolderStore.id, + newFilter ? newFilter : filter, + true, + true + ).finally(() => setTimeout(() => clearSecondaryProgressData(), TIMEOUT)); }; deleteAction = async (translations, newSelection = null) => { @@ -113,7 +137,7 @@ class FilesActionStore { label: translations.deleteOperation, }; await this.uploadDataStore.loopFilesOperations(data, pbData); - this.updateCurrentFolder(); + this.updateCurrentFolder(selection.length); } ); } catch (err) { @@ -312,7 +336,7 @@ class FilesActionStore { label: translations.deleteOperation, alert: false, }); - + debugger; try { await this.deleteItemOperation(isFile, itemId, translations); } catch (err) { @@ -331,7 +355,7 @@ class FilesActionStore { icon: "trash", label: translations.deleteOperation, }; - + console.log("deleteItemOperation"); if (isFile) { this.isMediaOpen(); return deleteFile(itemId) From 57f65b437addf725aa57e64af590638f0a7ec78a Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 9 Nov 2021 10:27:09 +0300 Subject: [PATCH 02/11] Web: files: Function transfer. --- .../Client/src/store/FilesActionsStore.js | 27 +++++++------------ .../ASC.Files/Client/src/store/FilesStore.js | 18 ++++++++++++- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/products/ASC.Files/Client/src/store/FilesActionsStore.js b/products/ASC.Files/Client/src/store/FilesActionsStore.js index 8442dce5b02..969ec1320b6 100644 --- a/products/ASC.Files/Client/src/store/FilesActionsStore.js +++ b/products/ASC.Files/Client/src/store/FilesActionsStore.js @@ -56,31 +56,22 @@ class FilesActionStore { } }; - isEmptyLastPageAfterOperation = (selectionLength) => { - const { filter, files, folders } = this.filesStore; - - return ( - filter.page > 0 && - !filter.hasNext() && - selectionLength === files.length + folders.length - ); - }; - updateCurrentFolder = (selectionLength) => { const { clearSecondaryProgressData, } = this.uploadDataStore.secondaryProgressDataStore; - const { filter, fetchFiles } = this.filesStore; + const { + filter, + fetchFiles, + isEmptyLastPageAfterOperation, + resetFilterPage, + } = this.filesStore; let newFilter; - if ( - selectionLength && - this.isEmptyLastPageAfterOperation(selectionLength) - ) { - newFilter = filter.clone(); - newFilter.page--; + if (selectionLength && isEmptyLastPageAfterOperation(selectionLength)) { + newFilter = resetFilterPage(); } fetchFiles( @@ -336,7 +327,7 @@ class FilesActionStore { label: translations.deleteOperation, alert: false, }); - debugger; + try { await this.deleteItemOperation(isFile, itemId, translations); } catch (err) { diff --git a/products/ASC.Files/Client/src/store/FilesStore.js b/products/ASC.Files/Client/src/store/FilesStore.js index 75acc4d1b83..58240101e9e 100644 --- a/products/ASC.Files/Client/src/store/FilesStore.js +++ b/products/ASC.Files/Client/src/store/FilesStore.js @@ -269,6 +269,22 @@ class FilesStore { ); }; + isEmptyLastPageAfterOperation = (selectionLength) => { + return ( + this.filter.page > 0 && + !this.filter.hasNext() && + selectionLength === this.files.length + this.folders.length + ); + }; + + resetFilterPage = () => { + let newFilter; + newFilter = this.filter.clone(); + newFilter.page--; + + return newFilter; + }; + fetchFiles = ( folderId, filter, @@ -287,7 +303,7 @@ class FilesStore { const filterStorageItem = localStorage.getItem( `UserFilter=${this.userStore.user.id}` ); - + console.log("FETCH"); if (filterStorageItem && !filter) { const splitFilter = filterStorageItem.split(","); From aa3aff1516fe016985f3f2a8629548eb56dd7407 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 9 Nov 2021 10:29:34 +0300 Subject: [PATCH 03/11] Web: files: Removed a blank page when restoring files from the recycle bin. --- .../Client/src/store/UploadDataStore.js | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/products/ASC.Files/Client/src/store/UploadDataStore.js b/products/ASC.Files/Client/src/store/UploadDataStore.js index c64ad3e77f2..862e205ce3b 100644 --- a/products/ASC.Files/Client/src/store/UploadDataStore.js +++ b/products/ASC.Files/Client/src/store/UploadDataStore.js @@ -897,7 +897,14 @@ class UploadDataStore { moveToCopyTo = (destFolderId, pbData, isCopy) => { const { treeFolders, setTreeFolders } = this.treeFoldersStore; - const { fetchFiles, filter } = this.filesStore; + const { + fetchFiles, + filter, + selection, + isEmptyLastPageAfterOperation, + resetFilterPage, + } = this.filesStore; + const { clearSecondaryProgressData, setSecondaryProgressBarData, @@ -912,11 +919,20 @@ class UploadDataStore { loopTreeFolders(path, newTreeFolders, folders, foldersCount); if (!isCopy || destFolderId === this.selectedFolderStore.id) { - fetchFiles(this.selectedFolderStore.id, filter, true, true).finally( - () => { - setTimeout(() => clearSecondaryProgressData(), TIMEOUT); - } - ); + let newFilter; + + if (selection && isEmptyLastPageAfterOperation(selection.length)) { + newFilter = resetFilterPage(); + } + + fetchFiles( + this.selectedFolderStore.id, + newFilter ? newFilter : filter, + true, + true + ).finally(() => { + setTimeout(() => clearSecondaryProgressData(), TIMEOUT); + }); } else { setSecondaryProgressBarData({ icon: pbData.icon, From 1a8e0156fe59b05e7c8cbfd5f42e91dd35ee192c Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 9 Nov 2021 10:32:32 +0300 Subject: [PATCH 04/11] WebL Files: Deleted useless code. --- products/ASC.Files/Client/src/store/FilesStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/products/ASC.Files/Client/src/store/FilesStore.js b/products/ASC.Files/Client/src/store/FilesStore.js index 58240101e9e..85cf8f1740f 100644 --- a/products/ASC.Files/Client/src/store/FilesStore.js +++ b/products/ASC.Files/Client/src/store/FilesStore.js @@ -303,7 +303,7 @@ class FilesStore { const filterStorageItem = localStorage.getItem( `UserFilter=${this.userStore.user.id}` ); - console.log("FETCH"); + if (filterStorageItem && !filter) { const splitFilter = filterStorageItem.split(","); From b7053a84ebe381ed39248f935a4042a83a79be6c Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 9 Nov 2021 10:43:46 +0300 Subject: [PATCH 05/11] Web: Files: Deleted useless code. --- products/ASC.Files/Client/src/store/FilesActionsStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/products/ASC.Files/Client/src/store/FilesActionsStore.js b/products/ASC.Files/Client/src/store/FilesActionsStore.js index fc1315577c4..467c27efcb6 100644 --- a/products/ASC.Files/Client/src/store/FilesActionsStore.js +++ b/products/ASC.Files/Client/src/store/FilesActionsStore.js @@ -346,7 +346,7 @@ class FilesActionStore { icon: "trash", label: translations.deleteOperation, }; - console.log("deleteItemOperation"); + if (isFile) { this.isMediaOpen(); return deleteFile(itemId) From 3af660cc098dbd6af6cc69a5a479db6375681085 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 9 Nov 2021 12:58:35 +0300 Subject: [PATCH 06/11] Web: Files: Fixed moving through the context menu. --- products/ASC.Files/Client/src/store/UploadDataStore.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/products/ASC.Files/Client/src/store/UploadDataStore.js b/products/ASC.Files/Client/src/store/UploadDataStore.js index e94ec1f6d12..67aecc3c4f9 100644 --- a/products/ASC.Files/Client/src/store/UploadDataStore.js +++ b/products/ASC.Files/Client/src/store/UploadDataStore.js @@ -40,6 +40,7 @@ class UploadDataStore { converted = true; uploadPanelVisible = false; selectedUploadFile = []; + selectedFilesLength = null; constructor( formatsStore, @@ -877,6 +878,10 @@ class UploadDataStore { setSecondaryProgressBarData, clearSecondaryProgressData, } = this.secondaryProgressDataStore; + const { selection } = this.filesStore; + + this.selectedFilesLength = + selection?.length || folderIds.length + fileIds.length; return moveToFolder( destFolderId, @@ -1003,7 +1008,10 @@ class UploadDataStore { if (!isCopy || destFolderId === this.selectedFolderStore.id) { let newFilter; - if (selection && isEmptyLastPageAfterOperation(selection.length)) { + if ( + this.selectedFilesLength && + isEmptyLastPageAfterOperation(this.selectedFilesLength) + ) { newFilter = resetFilterPage(); } From 44a101beae18bf888133d3f9041c4f5bb0ae80fc Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 9 Nov 2021 13:47:55 +0300 Subject: [PATCH 07/11] Web: Refactoring, added bufferSelection. --- .../Client/src/store/FilesActionsStore.js | 2 +- products/ASC.Files/Client/src/store/FilesStore.js | 7 +++++-- .../ASC.Files/Client/src/store/UploadDataStore.js | 15 ++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/products/ASC.Files/Client/src/store/FilesActionsStore.js b/products/ASC.Files/Client/src/store/FilesActionsStore.js index 467c27efcb6..d808c8c6f95 100644 --- a/products/ASC.Files/Client/src/store/FilesActionsStore.js +++ b/products/ASC.Files/Client/src/store/FilesActionsStore.js @@ -70,7 +70,7 @@ class FilesActionStore { let newFilter; - if (selectionLength && isEmptyLastPageAfterOperation(selectionLength)) { + if (selectionLength && isEmptyLastPageAfterOperation()) { newFilter = resetFilterPage(); } diff --git a/products/ASC.Files/Client/src/store/FilesStore.js b/products/ASC.Files/Client/src/store/FilesStore.js index 14f494c3aa3..dc98cf11be9 100644 --- a/products/ASC.Files/Client/src/store/FilesStore.js +++ b/products/ASC.Files/Client/src/store/FilesStore.js @@ -272,11 +272,14 @@ class FilesStore { ); }; - isEmptyLastPageAfterOperation = (selectionLength) => { + isEmptyLastPageAfterOperation = () => { + const selection = this.selection?.length || [this.bufferSelection].length; + return ( + selection && this.filter.page > 0 && !this.filter.hasNext() && - selectionLength === this.files.length + this.folders.length + selection === this.files.length + this.folders.length ); }; diff --git a/products/ASC.Files/Client/src/store/UploadDataStore.js b/products/ASC.Files/Client/src/store/UploadDataStore.js index 67aecc3c4f9..f1f140c716c 100644 --- a/products/ASC.Files/Client/src/store/UploadDataStore.js +++ b/products/ASC.Files/Client/src/store/UploadDataStore.js @@ -878,10 +878,10 @@ class UploadDataStore { setSecondaryProgressBarData, clearSecondaryProgressData, } = this.secondaryProgressDataStore; - const { selection } = this.filesStore; + const { selection, setBufferSelection } = this.filesStore; - this.selectedFilesLength = - selection?.length || folderIds.length + fileIds.length; + (!selection || selection?.length === 0) && + setBufferSelection(folderIds.length + fileIds.length); return moveToFolder( destFolderId, @@ -905,7 +905,8 @@ class UploadDataStore { setTimeout(() => clearPrimaryProgressData(), TIMEOUT); setTimeout(() => clearSecondaryProgressData(), TIMEOUT); return Promise.reject(err); - }); + }) + .finally(() => setBufferSelection(null)); }; itemOperationToFolder = (data) => { @@ -987,7 +988,6 @@ class UploadDataStore { const { fetchFiles, filter, - selection, isEmptyLastPageAfterOperation, resetFilterPage, } = this.filesStore; @@ -1008,10 +1008,7 @@ class UploadDataStore { if (!isCopy || destFolderId === this.selectedFolderStore.id) { let newFilter; - if ( - this.selectedFilesLength && - isEmptyLastPageAfterOperation(this.selectedFilesLength) - ) { + if (isEmptyLastPageAfterOperation()) { newFilter = resetFilterPage(); } From 4d5aef216308a0814dcfbe0dc2a04dc52e9b97a7 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 9 Nov 2021 13:49:30 +0300 Subject: [PATCH 08/11] Web: Files: Deleted useless code. --- products/ASC.Files/Client/src/store/UploadDataStore.js | 1 - 1 file changed, 1 deletion(-) diff --git a/products/ASC.Files/Client/src/store/UploadDataStore.js b/products/ASC.Files/Client/src/store/UploadDataStore.js index f1f140c716c..855f1525266 100644 --- a/products/ASC.Files/Client/src/store/UploadDataStore.js +++ b/products/ASC.Files/Client/src/store/UploadDataStore.js @@ -40,7 +40,6 @@ class UploadDataStore { converted = true; uploadPanelVisible = false; selectedUploadFile = []; - selectedFilesLength = null; constructor( formatsStore, From 1d8fa34930721103991204ad1fa00c1d5526ec8c Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 9 Nov 2021 15:13:37 +0300 Subject: [PATCH 09/11] Web: Deleted useless code. --- products/ASC.Files/Client/src/store/UploadDataStore.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/products/ASC.Files/Client/src/store/UploadDataStore.js b/products/ASC.Files/Client/src/store/UploadDataStore.js index 855f1525266..15551111eb7 100644 --- a/products/ASC.Files/Client/src/store/UploadDataStore.js +++ b/products/ASC.Files/Client/src/store/UploadDataStore.js @@ -877,10 +877,6 @@ class UploadDataStore { setSecondaryProgressBarData, clearSecondaryProgressData, } = this.secondaryProgressDataStore; - const { selection, setBufferSelection } = this.filesStore; - - (!selection || selection?.length === 0) && - setBufferSelection(folderIds.length + fileIds.length); return moveToFolder( destFolderId, @@ -904,8 +900,7 @@ class UploadDataStore { setTimeout(() => clearPrimaryProgressData(), TIMEOUT); setTimeout(() => clearSecondaryProgressData(), TIMEOUT); return Promise.reject(err); - }) - .finally(() => setBufferSelection(null)); + }); }; itemOperationToFolder = (data) => { From 86269ab98404fff4ff50d383ff08f0b6eb3b7d13 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 9 Nov 2021 15:23:42 +0300 Subject: [PATCH 10/11] Web: files: Added new selection for delete operation. --- products/ASC.Files/Client/src/store/FilesActionsStore.js | 2 +- products/ASC.Files/Client/src/store/FilesStore.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/products/ASC.Files/Client/src/store/FilesActionsStore.js b/products/ASC.Files/Client/src/store/FilesActionsStore.js index d808c8c6f95..467c27efcb6 100644 --- a/products/ASC.Files/Client/src/store/FilesActionsStore.js +++ b/products/ASC.Files/Client/src/store/FilesActionsStore.js @@ -70,7 +70,7 @@ class FilesActionStore { let newFilter; - if (selectionLength && isEmptyLastPageAfterOperation()) { + if (selectionLength && isEmptyLastPageAfterOperation(selectionLength)) { newFilter = resetFilterPage(); } diff --git a/products/ASC.Files/Client/src/store/FilesStore.js b/products/ASC.Files/Client/src/store/FilesStore.js index dc98cf11be9..62cb4f514c4 100644 --- a/products/ASC.Files/Client/src/store/FilesStore.js +++ b/products/ASC.Files/Client/src/store/FilesStore.js @@ -272,8 +272,9 @@ class FilesStore { ); }; - isEmptyLastPageAfterOperation = () => { - const selection = this.selection?.length || [this.bufferSelection].length; + isEmptyLastPageAfterOperation = (newSelection) => { + const selection = + newSelection || this.selection?.length || [this.bufferSelection].length; return ( selection && From 33944ccb3e68bea6f6b3e63fc5d267075dc30df7 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 9 Nov 2021 15:52:17 +0300 Subject: [PATCH 11/11] Web: Files: Fixed delete operation without modal dialog. --- products/ASC.Files/Client/src/store/FilesActionsStore.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/products/ASC.Files/Client/src/store/FilesActionsStore.js b/products/ASC.Files/Client/src/store/FilesActionsStore.js index 467c27efcb6..c1989f2cdcf 100644 --- a/products/ASC.Files/Client/src/store/FilesActionsStore.js +++ b/products/ASC.Files/Client/src/store/FilesActionsStore.js @@ -347,13 +347,15 @@ class FilesActionStore { label: translations.deleteOperation, }; + const selectionFilesLength = 1; + if (isFile) { this.isMediaOpen(); return deleteFile(itemId) .then(async (res) => { const data = res[0] ? res[0] : null; await this.uploadDataStore.loopFilesOperations(data, pbData); - this.updateCurrentFolder(); + this.updateCurrentFolder(selectionFilesLength); }) .then(() => toastr.success(translations.successRemoveFile)); } else { @@ -361,7 +363,7 @@ class FilesActionStore { .then(async (res) => { const data = res[0] ? res[0] : null; await this.uploadDataStore.loopFilesOperations(data, pbData); - this.updateCurrentFolder(); + this.updateCurrentFolder(selectionFilesLength); }) .then(() => toastr.success(translations.successRemoveFolder)); }