Merge pull request #937 from nxglabs/tenant_mailtemplate

fix: if user not provide default value use it from template in createdocument from template API
This commit is contained in:
nxglabs
2025-07-03 16:04:35 +00:00
parent 4a5b35e147
commit 71b9bd6367
45 changed files with 2147 additions and 1067 deletions
@@ -59,6 +59,7 @@ export default async function saveAsTemplate(request) {
options: {
...p.options,
status: 'required',
...(p?.options?.defaultValue ? { defaultValue: '' } : {}),
},
})),
}));
@@ -73,10 +74,28 @@ export default async function saveAsTemplate(request) {
};
templateCls.set('Placeholders', [placeHolders]);
} else {
const placeHolders = _docRes?.Placeholders?.map((x, i) => {
const email = x.email ? { email: '' } : {};
return { ...x, signerObjId: '', signerPtr: {}, Role: 'Role ' + (i + 1), ...email };
});
const placeHolders = _docRes?.Placeholders.map((signer, signerIndex) => ({
// copy everything else, then overwrite these fields:
...signer,
signerObjId: '',
signerPtr: {},
Role: `Role ${signerIndex + 1}`,
email: '',
// rebuild placeHolder/pages
placeHolder: (signer.placeHolder || []).map(page => ({
...page,
pos: (page.pos || []).map(widget => {
// if there is a defaultValue in options, zero it out
if (widget.options && widget.options.defaultValue !== undefined) {
return { ...widget, options: { ...widget.options, defaultValue: '' } }; // reset only the value
}
// otherwise, return the widget unchanged
return widget;
}),
})),
}));
templateCls.set('Placeholders', placeHolders);
}
}