diff --git a/packages/asc-web-common/api/files/index.js b/packages/asc-web-common/api/files/index.js index 8bab7fcbc8..4969a9040b 100644 --- a/packages/asc-web-common/api/files/index.js +++ b/packages/asc-web-common/api/files/index.js @@ -797,3 +797,15 @@ export function checkFillFormDraft(fileId) { data: { fileId }, }); } + +export function fileCopyAs(fileId, destTitle, destFolderId, enableExternalExt) { + return request({ + method: "post", + url: `files/file/${fileId}/copyas`, + data: { + destTitle, + destFolderId, + enableExternalExt, + }, + }); +} diff --git a/products/ASC.Files/Client/src/HOCs/withContextOptions.js b/products/ASC.Files/Client/src/HOCs/withContextOptions.js index 2d8c485af1..77c6aac94f 100644 --- a/products/ASC.Files/Client/src/HOCs/withContextOptions.js +++ b/products/ASC.Files/Client/src/HOCs/withContextOptions.js @@ -20,6 +20,16 @@ export default function withContextOptions(WrappedComponent) { return this.gotoDocEditor(false); }; + onClickMakeForm = () => { + const { copyAsAction, item, formfillingDocs } = this.props; + const { title, id, folderId, fileExst } = item; + + const newTitle = + title.substring(0, title.length - fileExst.length) + formfillingDocs[0]; + + copyAsAction(id, newTitle, folderId).catch((err) => toastr.error(err)); + }; + onOpenLocation = () => { const { item, openLocationAction } = this.props; const { parentId, folderId, fileExst } = item; @@ -376,6 +386,14 @@ export default function withContextOptions(WrappedComponent) { onClick: this.onClickLinkFillForm, disabled: false, }; + case "make-form": + return { + key: option, + label: t("Common:MakeForm"), + icon: "/static/images/form.plus.react.svg", + onClick: this.onClickMakeForm, + disabled: false, + }; case "edit": return { key: option, @@ -533,45 +551,48 @@ export default function withContextOptions(WrappedComponent) { return inject( ( { - filesStore, - filesActionsStore, auth, - versionHistoryStore, - mediaViewerDataStore, dialogsStore, + filesActionsStore, + filesStore, + mediaViewerDataStore, treeFoldersStore, + uploadDataStore, + versionHistoryStore, }, { item } ) => { - const { openDocEditor, fileActionStore } = filesStore; + const { openDocEditor, fileActionStore, formatsStore } = filesStore; const { - openLocationAction, - finalizeVersionAction, - setFavoriteAction, - lockFileAction, + deleteItemAction, downloadAction, duplicateAction, - setThirdpartyInfo, - onSelectItem, - deleteItemAction, + finalizeVersionAction, + lockFileAction, markAsRead, + onSelectItem, + openLocationAction, + setFavoriteAction, + setThirdpartyInfo, unsubscribeAction, } = filesActionsStore; const { setChangeOwnerPanelVisible, - setMoveToPanelVisible, setCopyPanelVisible, - setDownloadDialogVisible, - setRemoveItem, - setDeleteThirdPartyDialogVisible, - setSharingPanelVisible, setDeleteDialogVisible, + setDeleteThirdPartyDialogVisible, + setDownloadDialogVisible, + setMoveToPanelVisible, + setRemoveItem, + setSharingPanelVisible, setUnsubscribe, } = dialogsStore; const { isTabletView, isDesktopClient } = auth.settingsStore; const { setIsVerHistoryPanel, fetchFileVersions } = versionHistoryStore; const { setAction, type, extension, id } = fileActionStore; const { setMediaViewerData } = mediaViewerDataStore; + const { copyAsAction } = uploadDataStore; + const { formfillingDocs } = formatsStore.docserviceStore; const { isRecycleBinFolder, isShare } = treeFoldersStore; const isShareFolder = isShare(item.rootFolderType); @@ -610,6 +631,8 @@ export default function withContextOptions(WrappedComponent) { setDeleteDialogVisible, setUnsubscribe, isDesktop: isDesktopClient, + copyAsAction, + formfillingDocs, }; } )(observer(WithContextOptions)); diff --git a/products/ASC.Files/Client/src/store/FilesStore.js b/products/ASC.Files/Client/src/store/FilesStore.js index 500228f73d..050356c5ac 100644 --- a/products/ASC.Files/Client/src/store/FilesStore.js +++ b/products/ASC.Files/Client/src/store/FilesStore.js @@ -489,12 +489,15 @@ class FilesStore { const shouldFillForm = canFormFillingDocs(item.fileExst); const shouldEdit = !shouldFillForm && canWebEdit(item.fileExst); const shouldView = canViewedDocs(item.fileExst); + const isMasterForm = item.fileExst === ".docxf"; + let fileOptions = [ //"open", "fill-form", "edit", "preview", "view", + "make-form", "separator0", "sharing-settings", "external-link", @@ -525,6 +528,9 @@ class FilesStore { "delete", ]; + if (!isMasterForm) + fileOptions = this.removeOptions(fileOptions, ["make-form"]); + if (!shouldFillForm) fileOptions = this.removeOptions(fileOptions, ["fill-form"]); @@ -637,6 +643,7 @@ class FilesStore { "view", "preview", "edit", + "make-form", "link-for-portal-users", "sharing-settings", "external-link", diff --git a/products/ASC.Files/Client/src/store/UploadDataStore.js b/products/ASC.Files/Client/src/store/UploadDataStore.js index 43e307fef4..00bb0aa76d 100644 --- a/products/ASC.Files/Client/src/store/UploadDataStore.js +++ b/products/ASC.Files/Client/src/store/UploadDataStore.js @@ -15,6 +15,7 @@ import { getFileConversationProgress, copyToFolder, moveToFolder, + fileCopyAs, } from "@appserver/common/api/files"; class UploadDataStore { @@ -919,6 +920,18 @@ class UploadDataStore { }); }; + copyAsAction = (fileId, title, folderId, enableExternalExt) => { + const { fetchFiles, filter } = this.filesStore; + + return fileCopyAs(fileId, title, folderId, enableExternalExt) + .then(() => { + fetchFiles(folderId, filter, true, true); + }) + .catch((err) => { + return Promise.reject(err); + }); + }; + itemOperationToFolder = (data) => { const { destFolderId, diff --git a/public/images/form.plus.react.svg b/public/images/form.plus.react.svg new file mode 100644 index 0000000000..c570b642bf --- /dev/null +++ b/public/images/form.plus.react.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/locales/en/Common.json b/public/locales/en/Common.json index 1d22a397c6..50998cc737 100644 --- a/public/locales/en/Common.json +++ b/public/locales/en/Common.json @@ -52,6 +52,7 @@ "LoadingDescription": "Please wait...", "LoadingProcessing": "Loading...", "Mail": "Mail", + "MakeForm": "Make form", "MeLabel": "Me", "More": "More", "Next": "Next",