Skip to content

Commit

Permalink
Merge pull request #1401 from OpenSignLabs/validation
Browse files Browse the repository at this point in the history
fix: drattemplate ui changes, signers not visible in list, alert message
  • Loading branch information
nxglabs authored Oct 31, 2024
2 parents 45c0cd4 + b8fb626 commit 26fece7
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 33 deletions.
14 changes: 3 additions & 11 deletions apps/OpenSign/src/components/pdf/EditTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import { isEnableSubscription } from "../../constant/const";
import { useTranslation } from "react-i18next";
import { Tooltip } from "react-tooltip";

// import SelectFolder from "../../premitives/SelectFolder";

const EditTemplate = ({ template, onSuccess }) => {
const EditTemplate = ({ template, onSuccess, jwttoken }) => {
const { t } = useTranslation();
// const [folder, setFolder] = useState({ ObjectId: "", Name: "" });
const [formData, setFormData] = useState({
Name: template?.Name || "",
Note: template?.Note || "",
Expand All @@ -29,17 +26,13 @@ const EditTemplate = ({ template, onSuccess }) => {
}, []);
const fetchSubscription = async () => {
if (isEnableSubscription) {
const subscribe = await checkIsSubscribed();
const subscribe = await checkIsSubscribed(jwttoken);
setIsSubscribe(subscribe.isValid);
}
};
const handleStrInput = (e) => {
setFormData({ ...formData, [e.target.name]: e.target.value });
};
// const handleFolder = (data) => {
// console.log("handleFolder ", data)
// setFolder(data);
// };

// Define a function to handle form submission
const handleSubmit = async (e) => {
Expand Down Expand Up @@ -85,7 +78,7 @@ const EditTemplate = ({ template, onSuccess }) => {
</div>
<div className="mb-[0.35rem]">
<label htmlFor="name" className="text-[13px]">
{t("name")}
{t("Title")}
<span className="text-[13px] text-[red]"> *</span>
</label>
<input
Expand Down Expand Up @@ -158,7 +151,6 @@ const EditTemplate = ({ template, onSuccess }) => {
}
>
{t("auto-reminder")}
{" "}
{!isSubscribe && isEnableSubscription && <Upgrade />}
</span>
<label
Expand Down
20 changes: 12 additions & 8 deletions apps/OpenSign/src/components/pdf/PdfHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ function Header({
handleRotationFun,
isDisableRotate,
templateId,
setIsDownloadModal
setIsDownloadModal,
disabledBackBtn
}) {
const { t } = useTranslation();
const filterPrefill =
signerPos && signerPos?.filter((data) => data.Role !== "prefill");
const isMobile = window.innerWidth < 767;
const [isDownloading, setIsDownloading] = useState("");
const isGuestSigner = localStorage.getItem("isGuestSigner");
const enabledBackBtn = disabledBackBtn === true ? false : true;

//function for show decline alert
const handleDeclinePdfAlert = async () => {
Expand Down Expand Up @@ -332,13 +334,15 @@ function Header({
<i className="fa-light fa-gear fa-lg"></i>
</button>
)}
<button
onClick={() => window.history.go(-2)}
type="button"
className="op-btn op-btn-ghost op-btn-sm mr-[3px]"
>
{t("back")}
</button>
{enabledBackBtn && (
<button
onClick={() => window.history.go(-2)}
type="button"
className="op-btn op-btn-ghost op-btn-sm mr-[3px]"
>
{t("back")}
</button>
)}
<button
disabled={isMailSend && true}
data-tut="headerArea"
Expand Down
8 changes: 4 additions & 4 deletions apps/OpenSign/src/components/shared/fields/SelectSigners.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ const SelectSigners = (props) => {
try {
const baseURL = localStorage.getItem("baseUrl");
const url = `${baseURL}functions/getsigners`;
const token = props?.jwttoken
? { jwttoken: props?.jwttoken }
const token = props.jwttoken
? { jwttoken: props.jwttoken }
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
const headers = {
"Content-Type": "application/json",
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
...token
};
const search = inputValue;
const axiosRes = await axios.post(url, { search }, { headers });
const searchEmail = inputValue;
const axiosRes = await axios.post(url, { searchEmail }, { headers });
const contactRes = axiosRes?.data?.result || [];
if (contactRes) {
const res = JSON.parse(JSON.stringify(contactRes));
Expand Down
4 changes: 2 additions & 2 deletions apps/OpenSign/src/constant/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ export async function fetchSubscriptionInfo() {
}
}
//function to get subcripition details from subscription class
export async function checkIsSubscribed() {
export async function checkIsSubscribed(jwttoken) {
try {
const res = await fetchSubscription();
const res = await fetchSubscription("", "", false, false, jwttoken);
if (res.plan === "freeplan") {
return { plan: res.plan, isValid: false, adminId: res?.adminId };
} else if (res.billingDate) {
Expand Down
6 changes: 4 additions & 2 deletions apps/OpenSign/src/pages/DraftTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ const DraftTemplate = () => {
} else {
// setIsPublicError(true);
alert(
"Only one signer without a role is allowed, and it should be at the first index."
"To make your template public, it must either contain a single role, or, if it includes multiple roles, all additional roles must already be assigned to signers. The unassigned public role should remain empty and must be placed in the first position. \nVisit below link to know more - \nhttps://docs.opensignlabs.com/docs/help/Templates/make-template-public"
);
}
} else {
Expand Down Expand Up @@ -1302,7 +1302,7 @@ const DraftTemplate = () => {
} else {
// setIsPublicError(true);
alert(
"Only one signer without a role is allowed, and it should be at the first index."
"To make your template public, it must either contain a single role, or, if it includes multiple roles, all additional roles must already be assigned to signers. The unassigned public role should remain empty and must be placed in the first position. \nVisit below link to know more - \nhttps://docs.opensignlabs.com/docs/help/Templates/make-template-public"
);
}
};
Expand Down Expand Up @@ -1614,6 +1614,7 @@ const DraftTemplate = () => {
{/* pdf header which contain funish back button */}
<Header
completeBtnTitle={t("send")}
disabledBackBtn={true}
isPlaceholder={true}
pageNumber={pageNumber}
allPages={allPages}
Expand Down Expand Up @@ -1800,6 +1801,7 @@ const DraftTemplate = () => {
<EditTemplate
template={pdfDetails?.[0]}
onSuccess={handleEditTemplateForm}
jwttoken={jwttoken}
/>
</ModalUi>
<WidgetNameModal
Expand Down
21 changes: 17 additions & 4 deletions apps/OpenSignServer/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,12 @@ export const updateMailCount = async (extUserId, plan, monthchange) => {
};

export function formatWidgetOptions(type, options) {
const colorsArr = ['red', 'black', 'blue', 'yellow'];
const status = options?.required === true ? 'required' : 'optional' || 'required';
const defaultValue = options?.default || '';
const values = options?.values || [];
const color = options?.color ? options.color : 'black';
const fontColor = colorsArr.includes(color) ? color : 'black';
switch (type) {
case 'signature':
return { name: 'signature', status: 'required' };
Expand All @@ -140,13 +143,18 @@ export function formatWidgetOptions(type, options) {
case 'image':
return { status: status, name: options.name || 'image' };
case 'email':
return { status: status, name: options.name || 'email', validation: { type: 'email' } };
return {
status: status,
name: options.name || 'email',
validation: { type: 'email' },
fontColor: fontColor,
};
case 'name':
return { status: status, name: options.name || 'name' };
return { status: status, name: options.name || 'name', fontColor: fontColor };
case 'job title':
return { status: status, name: options.name || 'job title' };
return { status: status, name: options.name || 'job title', fontColor: fontColor };
case 'company':
return { status: status, name: options.name || 'company' };
return { status: status, name: options.name || 'company', fontColor: fontColor };
case 'date': {
let today = new Date();
let dd = String(today.getDate()).padStart(2, '0');
Expand All @@ -160,6 +168,7 @@ export function formatWidgetOptions(type, options) {
name: options.name || 'date',
response: defaultValue || today,
validation: { format: dateFormat || 'dd-MM-yyyy', type: 'date-format' },
fontColor: fontColor,
};
}
case 'textbox':
Expand All @@ -169,6 +178,7 @@ export function formatWidgetOptions(type, options) {
defaultValue: defaultValue,
hint: options.hint,
validation: { type: 'regex', pattern: options?.regularexpression || '/^[a-zA-Z0-9s]+$/' },
fontColor: fontColor,
};
case 'checkbox': {
const arr = options?.values;
Expand All @@ -188,6 +198,7 @@ export function formatWidgetOptions(type, options) {
maxRequiredCount: options?.validation?.maxselections || 0,
},
defaultValue: selectedvalues || [],
fontColor: fontColor,
};
}
case 'radio button': {
Expand All @@ -198,6 +209,7 @@ export function formatWidgetOptions(type, options) {
isReadOnly: options?.readonly || false,
isHideLabel: options?.hidelabel || false,
defaultValue: defaultValue,
fontColor: fontColor,
};
}
case 'dropdown':
Expand All @@ -206,6 +218,7 @@ export function formatWidgetOptions(type, options) {
name: options.name || 'dropdown',
values: values,
defaultValue: defaultValue,
fontColor: fontColor,
};
default:
break;
Expand Down
3 changes: 1 addition & 2 deletions apps/OpenSignServer/cloud/parsefunction/getSigners.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ export default async function getSigners(request) {
className: '_User',
objectId: request?.user?.id,
});

if (search) {
contactbook.matches('Name', new RegExp(search, 'i'));
} else if (searchEmail) {
contactbook.matches('Email', new RegExp(searchEmail, 'i'));
}
contactbook.notEqualTo('IsDeleted', true);
const contactRes = await contactbook.find();
const contactRes = await contactbook.find({ sessionToken: request.user.getSessionToken() });
const _contactRes = JSON.parse(JSON.stringify(contactRes));
return _contactRes;
} else if (jwttoken) {
Expand Down

0 comments on commit 26fece7

Please sign in to comment.