refactor(annotations.js): move generateId method to outsite of createAnnotations method
This commit is contained in:
parent
7d85d59ace
commit
b72ac68daf
@ -1,4 +1,10 @@
|
|||||||
async function createAnnotations(document, envelopeId, receiverId) {
|
let __elementIndex = 0;
|
||||||
|
|
||||||
|
function generateId(envelopeId, receiverId, annotationType) {
|
||||||
|
return `${envelopeId}#${receiverId}#${__elementIndex++}#${annotationType}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createAnnotations(document, envelopeId, receiverId) {
|
||||||
const signatures = [];
|
const signatures = [];
|
||||||
|
|
||||||
for (let element of document.elements) {
|
for (let element of document.elements) {
|
||||||
@ -6,19 +12,13 @@
|
|||||||
const page = element.page - 1
|
const page = element.page - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
let elementIndex = 0;
|
|
||||||
|
|
||||||
function generateId(annotationType) {
|
|
||||||
return `${envelopeId}#${receiverId}#${elementIndex++}#${annotationType}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let element of document.elements) {
|
for (let element of document.elements) {
|
||||||
const annotParams = await getAnnotationParams(element.left, element.top);
|
const annotParams = await getAnnotationParams(element.left, element.top);
|
||||||
const page = element.page - 1
|
const page = element.page - 1
|
||||||
|
|
||||||
//#region signatures
|
//#region signatures
|
||||||
const annotation = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: generateId('signature'),
|
id: generateId(envelopeId, receiverId, 'signature'),
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
formFieldName: id,
|
formFieldName: id,
|
||||||
backgroundColor: PSPDFKit.Color.LIGHT_YELLOW,
|
backgroundColor: PSPDFKit.Color.LIGHT_YELLOW,
|
||||||
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
//#region position
|
//#region position
|
||||||
const annotation_position = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation_position = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: generateId('position'),
|
id: generateId(envelopeId, receiverId, 'position'),
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
formFieldName: id_position,
|
formFieldName: id_position,
|
||||||
backgroundColor: PSPDFKit.Color.DarkBlue,
|
backgroundColor: PSPDFKit.Color.DarkBlue,
|
||||||
@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
//#region city
|
//#region city
|
||||||
const annotation_city = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation_city = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: generateId('city'),
|
id: generateId(envelopeId, receiverId, 'city'),
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
formFieldName: id_city,
|
formFieldName: id_city,
|
||||||
backgroundColor: PSPDFKit.Color.DarkBlue,
|
backgroundColor: PSPDFKit.Color.DarkBlue,
|
||||||
@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
//#region date
|
//#region date
|
||||||
const annotation_date = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation_date = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: generateId('date'),
|
id: generateId(envelopeId, receiverId, 'date'),
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
formFieldName: id_date,
|
formFieldName: id_date,
|
||||||
backgroundColor: PSPDFKit.Color.DarkBlue,
|
backgroundColor: PSPDFKit.Color.DarkBlue,
|
||||||
@ -99,7 +99,7 @@
|
|||||||
|
|
||||||
//#region date label
|
//#region date label
|
||||||
const annotation_date_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation_date_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: generateId('date_label'),
|
id: generateId(envelopeId, receiverId, 'date_label'),
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
formFieldName: id_date_label,
|
formFieldName: id_date_label,
|
||||||
blendMode: 'normal',
|
blendMode: 'normal',
|
||||||
@ -121,7 +121,7 @@
|
|||||||
|
|
||||||
//#region city label
|
//#region city label
|
||||||
const annotation_city_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation_city_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: generateId('city_label'),
|
id: generateId(envelopeId, receiverId, 'city_label'),
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
formFieldName: id_city_label,
|
formFieldName: id_city_label,
|
||||||
blendMode: 'normal',
|
blendMode: 'normal',
|
||||||
@ -143,7 +143,7 @@
|
|||||||
|
|
||||||
//#region position label
|
//#region position label
|
||||||
const annotation_position_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation_position_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: generateId('position_label'),
|
id: generateId(envelopeId, receiverId, 'position_label'),
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
formFieldName: id_position_label,
|
formFieldName: id_position_label,
|
||||||
blendMode: 'normal',
|
blendMode: 'normal',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user