diff --git a/apps/OpenSign/src/constant/Utils.js b/apps/OpenSign/src/constant/Utils.js index 4a1e72065..16d8a556b 100644 --- a/apps/OpenSign/src/constant/Utils.js +++ b/apps/OpenSign/src/constant/Utils.js @@ -2462,3 +2462,45 @@ export const handleRotateWarning = (signerPos, pageNumber) => { return false; } }; + +// `generateTitleFromFilename` to generate Title of document from file name +export function generateTitleFromFilename(filename) { + try { + // Step 1: Trim whitespace + let title = filename.trim(); + + // Step 2: Remove the file extension (everything after the last '.') + const lastDotIndex = title.lastIndexOf("."); + if (lastDotIndex > 0) { + title = title.substring(0, lastDotIndex); + } + + // Step 3: Replace special characters (except Unicode letters, digits, spaces, and hyphens) + title = title.replace(/[^\p{L}\p{N}\s-]/gu, " "); + + // Step 4: Replace multiple spaces with a single space + title = title.replace(/\s+/g, " "); + + // Step 5: Capitalize first letter of each word (Title Case), handling Unicode characters + title = title.replace( + /\p{L}\S*/gu, + (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase() + ); + + // Step 6: Restrict length of title (optional, let's say 100 characters) + if (title.length > 100) { + title = title.substring(0, 100).trim(); + } + + // Step 7: Handle empty or invalid title by falling back to "Untitled Document" + if (!title || title.length === 0) { + return "Untitled Document"; + } + + return title; + } catch (error) { + // Handle unexpected errors gracefully by returning a default title + console.error("Error generating title from filename:", error); + return "Untitled Document"; + } +} diff --git a/apps/OpenSign/src/json/ReportJson.js b/apps/OpenSign/src/json/ReportJson.js index c1d5cc0d6..52dee8fd2 100644 --- a/apps/OpenSign/src/json/ReportJson.js +++ b/apps/OpenSign/src/json/ReportJson.js @@ -16,7 +16,7 @@ export default function reportJson(id) { "Note", "Folder", "File", - "Logs", + "Status", "Signers" ]; const contactbook = ["Sr.No", "Name", "Email", "Phone"]; diff --git a/apps/OpenSign/src/pages/Form.js b/apps/OpenSign/src/pages/Form.js index bfd145ffa..2b15080ba 100644 --- a/apps/OpenSign/src/pages/Form.js +++ b/apps/OpenSign/src/pages/Form.js @@ -9,7 +9,12 @@ import SignersInput from "../components/shared/fields/SignersInput"; import Title from "../components/Title"; import PageNotFound from "./PageNotFound"; import { SaveFileSize } from "../constant/saveFileSize"; -import { checkIsSubscribed, getFileName, toDataUrl } from "../constant/Utils"; +import { + checkIsSubscribed, + generateTitleFromFilename, + getFileName, + toDataUrl +} from "../constant/Utils"; import { PDFDocument } from "pdf-lib"; import axios from "axios"; import { isEnableSubscription } from "../constant/const"; @@ -330,6 +335,8 @@ const Forms = (props) => { setfileload(false); if (response.url()) { const tenantId = localStorage.getItem("TenantId"); + const title = generateTitleFromFilename(file.name); + setFormData((obj) => ({ ...obj, Name: title })); SaveFileSize(size, response.url(), tenantId); return response.url(); } @@ -367,9 +374,10 @@ const Forms = (props) => { }); setFileUpload(response.url()); setfileload(false); - if (response.url()) { const tenantId = localStorage.getItem("TenantId"); + const title = generateTitleFromFilename(file.name); + setFormData((obj) => ({ ...obj, Name: title })); SaveFileSize(size, response.url(), tenantId); return response.url(); } diff --git a/apps/OpenSignServer/cloud/parsefunction/reportsJson.js b/apps/OpenSignServer/cloud/parsefunction/reportsJson.js index b3b4f599c..3a31f4a5c 100644 --- a/apps/OpenSignServer/cloud/parsefunction/reportsJson.js +++ b/apps/OpenSignServer/cloud/parsefunction/reportsJson.js @@ -65,6 +65,7 @@ export default function reportJson(id, userId) { 'Folder.Name', 'URL', 'ExtUserPtr.Name', + 'ExtUserPtr.Email', 'ExtUserPtr.active_mail_adapter', 'Signers.Name', 'Signers.Email', @@ -101,6 +102,7 @@ export default function reportJson(id, userId) { 'Folder.Name', 'URL', 'ExtUserPtr.Name', + 'ExtUserPtr.Email', 'ExtUserPtr.active_mail_adapter', 'Signers.Name', 'Signers.Email', @@ -229,6 +231,7 @@ export default function reportJson(id, userId) { 'Folder.Name', 'URL', 'ExtUserPtr.Name', + 'ExtUserPtr.Email', 'ExtUserPtr.active_mail_adapter', 'Signers.Name', 'Signers.Email', @@ -271,6 +274,7 @@ export default function reportJson(id, userId) { 'Name', 'URL', 'ExtUserPtr.Name', + 'ExtUserPtr.Email', 'ExtUserPtr.active_mail_adapter', 'Signers.Name', 'Signers.UserId',