Doceditor: Fixed share PDF form

This commit is contained in:
Akmal Isomadinov 2024-06-18 12:02:21 +05:00
parent a12aa30a47
commit 181f412e8c
7 changed files with 47 additions and 28 deletions

View File

@ -296,7 +296,8 @@ const Editor = ({
}
if (config?.startFilling) {
newConfig.events.onRequestStartFilling = onSDKRequestStartFilling;
newConfig.events.onRequestStartFilling = () =>
onSDKRequestStartFilling?.(t("Common:StartFilling"));
}
newConfig.events.onSubmit = () => {

View File

@ -125,12 +125,6 @@ const Root = ({
selectFileDialogFileTypeDetection,
selectFileDialogVisible,
} = useSelectFileDialog({ instanceId: instanceId ?? "" });
const {
isSharingDialogVisible,
onCloseSharingDialog,
onSDKRequestSharingSettings,
} = useShareDialog();
const {
getIsDisabledStartFillingSelectDialog,
@ -139,8 +133,16 @@ const Root = ({
onSubmitStartFillingSelectDialog,
onSDKRequestStartFilling,
conflictDataDialog,
headerLabelSFSDialog,
} = useStartFillingSelectDialog(fileInfo);
const {
isSharingDialogVisible,
onCloseSharingDialog,
onSDKRequestSharingSettings,
} = useShareDialog(config, onSDKRequestStartFilling);
useUpdateSearchParamId(fileId, hash);
React.useEffect(() => {
@ -254,11 +256,12 @@ const Root = ({
<StartFillingSelectorDialog
fileInfo={fileInfo}
socketHelper={socketHelper}
filesSettings={filesSettings}
headerLabel={headerLabelSFSDialog}
isVisible={isVisibleStartFillingSelectDialog}
onClose={onCloseStartFillingSelectDialog}
onSubmit={onSubmitStartFillingSelectDialog}
getIsDisabled={getIsDisabledStartFillingSelectDialog}
filesSettings={filesSettings}
/>
)}
{conflictDataDialog.visible && (

View File

@ -40,6 +40,7 @@ function StartFillingSelectorDialog({
onClose,
onSubmit,
filesSettings,
headerLabel,
}: StartFillingSelectorDialogPprops) {
const { t } = useTranslation(["Common", "Editor"]);
@ -67,7 +68,7 @@ function StartFillingSelectorDialog({
filesSettings={filesSettings}
currentDeviceType={DeviceType.desktop}
socketSubscribers={socketHelper.socketSubscribers}
headerLabel={t("Common:StartFilling")}
headerLabel={headerLabel}
submitButtonLabel={t("Common:CopyHere")}
onSubmit={onSubmit}
getIsDisabled={getIsDisabled}

View File

@ -25,13 +25,23 @@
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
import React from "react";
import { useTranslation } from "react-i18next";
const useShareDialog = () => {
import type { IInitialConfig } from "@/types";
const useShareDialog = (
config: IInitialConfig | undefined,
onSDKRequestStartFilling: (headerLabel: string) => void,
) => {
const { t } = useTranslation(["Common"]);
const [isVisible, setIsVisible] = React.useState(false);
const onSDKRequestSharingSettings = React.useCallback(() => {
if (config?.startFilling)
return onSDKRequestStartFilling(t("Common:ShareToFillOut"));
setIsVisible(true);
}, []);
}, [config?.startFilling, onSDKRequestStartFilling, t]);
const onClose = React.useCallback(() => {
setIsVisible(false);
@ -45,4 +55,3 @@ const useShareDialog = () => {
};
export default useShareDialog;

View File

@ -41,7 +41,7 @@ import type { TRoomSecurity } from "@docspace/shared/api/rooms/types";
import type { TBreadCrumb } from "@docspace/shared/components/selector/Selector.types";
import type { TSelectedFileInfo } from "@docspace/shared/selectors/Files/FilesSelector.types";
import type { ConflictStateType } from "@/types";
import { useTranslation } from "react-i18next";
// import { useTranslation } from "react-i18next";
const DefaultConflictDataDialogState: ConflictStateType = {
visible: false,
@ -52,7 +52,8 @@ const DefaultConflictDataDialogState: ConflictStateType = {
};
const useStartFillingSelectDialog = (fileInfo: TFile | undefined) => {
const { t } = useTranslation(["Common"]);
// const { t } = useTranslation(["Common"]);
const [headerLabelSFSDialog, setHeaderLabelSFSDialog] = useState("");
const [isVisible, setIsVisible] = useState(false);
const [conflictDataDialog, setConflictDataDialog] = useState(
@ -61,7 +62,8 @@ const useStartFillingSelectDialog = (fileInfo: TFile | undefined) => {
const requestRunning = useRef(false);
const onSDKRequestStartFilling = useCallback((_: object) => {
const onSDKRequestStartFilling = useCallback((headerLabel: string) => {
setHeaderLabelSFSDialog(headerLabel);
setIsVisible(true);
}, []);
@ -180,6 +182,7 @@ const useStartFillingSelectDialog = (fileInfo: TFile | undefined) => {
getIsDisabledStartFillingSelectDialog: getIsDisabled,
isVisibleStartFillingSelectDialog: isVisible,
conflictDataDialog,
headerLabelSFSDialog,
};
};

View File

@ -233,7 +233,7 @@ export type EditorProps = {
onSDKRequestSelectSpreadsheet?: (event: object) => void;
onSDKRequestSelectDocument?: (event: object) => void;
onSDKRequestReferenceSource?: (event: object) => void;
onSDKRequestStartFilling?: (event: object) => void;
onSDKRequestStartFilling?: (haederLabel: string) => void;
};
export type TEventData = {
@ -405,6 +405,7 @@ export type StartFillingSelectorDialogPprops = {
fileInfo: TFile;
isVisible: boolean;
onClose: VoidFunction;
headerLabel: string;
getIsDisabled: (
isFirstLoad: boolean,

View File

@ -51,6 +51,10 @@
"CommonFiles": "Common files",
"CompanyName": "Company name",
"Confirmation": "Confirmation",
"ConflictResolveDescription": "The file with the name <1>{{file}}</1> already exists in the folder <1>{{folder}}</1>.",
"ConflictResolveDescriptionFiles": "{{filesCount}} documents with the same name already exist in the folder <1>{{folder}}</1>.",
"ConflictResolveSelectAction": "Please select the action:",
"ConflictResolveTitle": "Overwrite confirmation",
"Connect": "Connect",
"Content": "Content",
"Context": "Context",
@ -64,6 +68,7 @@
"Create": "Create",
"CreateAndCopy": "Create and copy",
"CreateCopy": "Create copy",
"CreateDescription": "There will be two different files in the folder.",
"CreateFileCopy": "Create file copy",
"CreateMasterFormFromFile": "Create Form Template from file",
"CreatePDFForm": "Create PDF Form",
@ -268,8 +273,8 @@
"Name": "Name",
"NeedPassword": "You need a password to access the room",
"NewDocument": "New document",
"NewFolder": "New folder",
"NewFillingFormRoom": "New Filling form room",
"NewFolder": "New folder",
"NewMasterForm": "New form template",
"NewPresentation": "New presentation",
"NewRoom": "New room",
@ -285,12 +290,14 @@
"NotFoundUsersDescription": "No users match your search. Please adjust your search parameters or clear the search field to view the full list of users.",
"NotSupportedFormat": "Sorry, this file format isn't supported",
"OFORMsGallery": "Form Gallery",
"OKButton": "OK",
"OkButton": "Ok",
"OKButton": "OK",
"Or": "or",
"orContinueWith": "or continue with",
"OtherLabel": "Other",
"OtherOperations": "Other operations",
"OverwriteDescription": "The new file will replace the existing one as a new version.",
"OverwriteTitle": "Overwrite with version update",
"Owner": "Owner",
"PageOfTotalPage": "{{page}} of {{totalPage}}",
"Pages": "Pages",
@ -395,6 +402,7 @@
"ShareDocument": "Share this document",
"ShareDocumentDescription": "Provide access to the document and set the permission levels.",
"SharedWithMe": "Shared with me",
"ShareToFillOut": "Share to fill out",
"ShareVia": "Share via",
"ShowMore": "Show more",
"SignInWithApple": "Sign in with Apple",
@ -415,6 +423,8 @@
"SignUpWithZoom": "Sign up with Zoom",
"Size": "Size",
"SizeImageLarge": "The image size is too large, please select another image.",
"SkipDescription": "No file will be copied. The original file will be retained in the destination folder.",
"SkipTitle": "Skip",
"SomethingWentWrong": "Something went wrong.",
"SortBy": "Sort by",
"SpaceManagement": "Space Management",
@ -472,14 +482,5 @@
"Website": "Website",
"Yes": "Yes",
"Yesterday": "Yesterday",
"You": "You",
"ConflictResolveDescription": "The file with the name <1>{{file}}</1> already exists in the folder <1>{{folder}}</1>.",
"ConflictResolveDescriptionFiles": "{{filesCount}} documents with the same name already exist in the folder <1>{{folder}}</1>.",
"ConflictResolveSelectAction": "Please select the action:",
"ConflictResolveTitle": "Overwrite confirmation",
"CreateDescription": "There will be two different files in the folder.",
"OverwriteDescription": "The new file will replace the existing one as a new version.",
"OverwriteTitle": "Overwrite with version update",
"SkipDescription": "No file will be copied. The original file will be retained in the destination folder.",
"SkipTitle": "Skip"
"You": "You"
}