From eed752d1eb8c2f56e8d3fcf43f33145c8eee559b Mon Sep 17 00:00:00 2001 From: gopienkonikita Date: Wed, 20 Apr 2022 14:47:21 +0300 Subject: [PATCH] Web: Files: fixed creating forms from the gallery --- .../TilesView/sub-components/Tile.js | 17 ++-------- .../ASC.Files/Client/src/pages/Home/index.js | 33 +++++++++++++++---- .../ASC.Files/Client/src/store/FilesStore.js | 5 +-- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/products/ASC.Files/Client/src/pages/FormGallery/TilesView/sub-components/Tile.js b/products/ASC.Files/Client/src/pages/FormGallery/TilesView/sub-components/Tile.js index 909bafee73..3f62e253d8 100644 --- a/products/ASC.Files/Client/src/pages/FormGallery/TilesView/sub-components/Tile.js +++ b/products/ASC.Files/Client/src/pages/FormGallery/TilesView/sub-components/Tile.js @@ -84,8 +84,8 @@ class Tile extends React.PureComponent { }; onCreateForm = () => { - const { match, history, item } = this.props; - const { setInfoPanelIsVisible, setAction } = this.props; + const { match, history } = this.props; + const { setInfoPanelIsVisible } = this.props; const filter = FilesFilter.getDefault(); filter.folder = match.params.fileId; @@ -93,16 +93,6 @@ class Tile extends React.PureComponent { setInfoPanelIsVisible(false); - setTimeout(() => { - setAction({ - type: FileAction.Create, - extension: "docxf", - fromTemplate: true, - title: item.attributes.name_form, - id: -1, - }); - }, 100); - history.push( combineUrl( AppServerConfig.proxyURL, @@ -216,7 +206,7 @@ Tile.defaultProps = { export default inject( ({ filesStore, settingsStore, infoPanelStore }, { item }) => { - const { gallerySelected, setGallerySelected, fileActionStore } = filesStore; + const { gallerySelected, setGallerySelected } = filesStore; const { getIcon } = settingsStore; const { setInfoPanelIsVisible, isVisible } = infoPanelStore; @@ -228,7 +218,6 @@ export default inject( getIcon, setInfoPanelIsVisible, isInfoPanelVisible: isVisible, - setAction: fileActionStore.setAction, }; } )(withTranslation(["FormGallery", "Common"])(withRouter(observer(Tile)))); diff --git a/products/ASC.Files/Client/src/pages/Home/index.js b/products/ASC.Files/Client/src/pages/Home/index.js index ba88d51227..cf2a4b6aaf 100644 --- a/products/ASC.Files/Client/src/pages/Home/index.js +++ b/products/ASC.Files/Client/src/pages/Home/index.js @@ -32,6 +32,7 @@ import DragTooltip from "../../components/DragTooltip"; import { observer, inject } from "mobx-react"; import config from "../../../package.json"; import { Consumer } from "@appserver/components/utils/context"; +import { FileAction } from "@appserver/common/constants"; class PureHome extends React.Component { componentDidMount() { @@ -48,6 +49,8 @@ class PureHome extends React.Component { getFileInfo, setIsPrevSettingsModule, isPrevSettingsModule, + gallerySelected, + setAction, } = this.props; if (!window.location.href.includes("#preview")) { @@ -158,11 +161,26 @@ class PureHome extends React.Component { const folderId = filter.folder; //console.log("filter", filter); - return fetchFiles(folderId, filter).then((data) => { - const pathParts = data.selectedFolder.pathParts; - const newExpandedKeys = createTreeFolders(pathParts, expandedKeys); - setExpandedKeys(newExpandedKeys); - }); + return fetchFiles(folderId, filter) + .then((data) => { + const pathParts = data.selectedFolder.pathParts; + const newExpandedKeys = createTreeFolders( + pathParts, + expandedKeys + ); + setExpandedKeys(newExpandedKeys); + }) + .then(() => { + if (gallerySelected) { + setAction({ + type: FileAction.Create, + extension: "docxf", + fromTemplate: true, + title: gallerySelected.attributes.name_form, + id: -1, + }); + } + }); } return Promise.resolve(); @@ -394,9 +412,10 @@ export default inject( getFileInfo, setIsPrevSettingsModule, isPrevSettingsModule, + gallerySelected, } = filesStore; - const { id } = fileActionStore; + const { id, setAction } = fileActionStore; const { isRecycleBinFolder, isPrivacyFolder, @@ -490,6 +509,8 @@ export default inject( setIsPrevSettingsModule, isPrevSettingsModule, + gallerySelected, + setAction, }; } )(withRouter(observer(Home))); diff --git a/products/ASC.Files/Client/src/store/FilesStore.js b/products/ASC.Files/Client/src/store/FilesStore.js index 0d479fe702..5c2c01b9a7 100644 --- a/products/ASC.Files/Client/src/store/FilesStore.js +++ b/products/ASC.Files/Client/src/store/FilesStore.js @@ -1206,10 +1206,7 @@ class FilesStore { createFormFromTemplate = (folderId, formId, title) => { return api.files .createFormFromTemplate(folderId, formId, title) - .then((file) => Promise.resolve(file)) - .finally(() => { - this.setGallerySelected(null); - }); + .then((file) => Promise.resolve(file)); }; setFile = (file) => {