Merge pull request #469 from ONLYOFFICE/feature/make-form

Feature/make form
This commit is contained in:
Alexey Safronov 2021-11-30 11:36:23 +03:00 committed by GitHub
commit 626ad87077
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 76 additions and 17 deletions

View File

@ -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,
},
});
}

View File

@ -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));

View File

@ -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",

View File

@ -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,

View File

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 2C0 0.895431 0.895431 0 2 0H14C15.1046 0 16 0.895431 16 2V7H14H7H2V10H7V16H2C0.895431 16 0 15.1046 0 14V2ZM2 2H14V5H2V2ZM11 9H13V11H15V13H13V15H11V13H9V11H11V9Z" fill="#657077"/>
</svg>

After

Width:  |  Height:  |  Size: 334 B

View File

@ -52,6 +52,7 @@
"LoadingDescription": "Please wait...",
"LoadingProcessing": "Loading...",
"Mail": "Mail",
"MakeForm": "Make form",
"MeLabel": "Me",
"More": "More",
"Next": "Next",