Skip to content

Commit

Permalink
Merge pull request #469 from ONLYOFFICE/feature/make-form
Browse files Browse the repository at this point in the history
Feature/make form
  • Loading branch information
AlexeySafronov authored Nov 30, 2021
2 parents a032b83 + 1551a48 commit 626ad87
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 15 deletions.
12 changes: 12 additions & 0 deletions packages/asc-web-common/api/files/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
}
53 changes: 38 additions & 15 deletions products/ASC.Files/Client/src/HOCs/withContextOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
setDeleteDialogVisible,
setDeleteThirdPartyDialogVisible,
setDownloadDialogVisible,
setMoveToPanelVisible,
setRemoveItem,
setDeleteThirdPartyDialogVisible,
setSharingPanelVisible,
setDeleteDialogVisible,
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);
Expand Down Expand Up @@ -610,6 +631,8 @@ export default function withContextOptions(WrappedComponent) {
setDeleteDialogVisible,
setUnsubscribe,
isDesktop: isDesktopClient,
copyAsAction,
formfillingDocs,
};
}
)(observer(WithContextOptions));
Expand Down
7 changes: 7 additions & 0 deletions products/ASC.Files/Client/src/store/FilesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -525,6 +528,9 @@ class FilesStore {
"delete",
];

if (!isMasterForm)
fileOptions = this.removeOptions(fileOptions, ["make-form"]);

if (!shouldFillForm)
fileOptions = this.removeOptions(fileOptions, ["fill-form"]);

Expand Down Expand Up @@ -637,6 +643,7 @@ class FilesStore {
"view",
"preview",
"edit",
"make-form",
"link-for-portal-users",
"sharing-settings",
"external-link",
Expand Down
13 changes: 13 additions & 0 deletions products/ASC.Files/Client/src/store/UploadDataStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
getFileConversationProgress,
copyToFolder,
moveToFolder,
fileCopyAs,
} from "@appserver/common/api/files";

class UploadDataStore {
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions public/images/form.plus.react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/locales/en/Common.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"LoadingDescription": "Please wait...",
"LoadingProcessing": "Loading...",
"Mail": "Mail",
"MakeForm": "Make form",
"MeLabel": "Me",
"More": "More",
"Next": "Next",
Expand Down

0 comments on commit 626ad87

Please sign in to comment.