refactor(annotation): generate deterministic annotation IDs based on envelopeId, receiverId, and element index
This commit is contained in:
parent
41738bb36c
commit
3f116ce11a
@ -1,5 +1,4 @@
|
||||
|
||||
async function createAnnotations(document, envelopeId, receiverId) {
|
||||
async function createAnnotations(document, envelopeId, receiverId) {
|
||||
const signatures = [];
|
||||
|
||||
for (let element of document.elements) {
|
||||
@ -7,12 +6,18 @@ async function createAnnotations(document, envelopeId, receiverId) {
|
||||
const page = element.page - 1
|
||||
}
|
||||
|
||||
let elementIndex = 0;
|
||||
|
||||
function generateId(annotationType) {
|
||||
return `${envelopeId}_${receiverId}_${elementIndex++}_${annotationType}`;
|
||||
}
|
||||
|
||||
for (let element of document.elements) {
|
||||
const annotParams = await getAnnotationParams(element.left, element.top);
|
||||
const page = element.page - 1
|
||||
|
||||
//#region signatures
|
||||
const id = PSPDFKit.generateInstantId()
|
||||
const id = generateId('signature');
|
||||
const annotation = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||
id: id,
|
||||
pageIndex: page,
|
||||
@ -29,7 +34,7 @@ async function createAnnotations(document, envelopeId, receiverId) {
|
||||
//#endregion
|
||||
|
||||
//#region position
|
||||
const id_position = PSPDFKit.generateInstantId()
|
||||
const id_position = generateId('position');
|
||||
const annotation_position = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||
id: id_position,
|
||||
pageIndex: page,
|
||||
@ -49,7 +54,7 @@ async function createAnnotations(document, envelopeId, receiverId) {
|
||||
//#endregion
|
||||
|
||||
//#region city
|
||||
const id_city = PSPDFKit.generateInstantId()
|
||||
const id_city = generateId('city');
|
||||
const annotation_city = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||
id: id_city,
|
||||
pageIndex: page,
|
||||
@ -69,7 +74,7 @@ async function createAnnotations(document, envelopeId, receiverId) {
|
||||
//#endregion
|
||||
|
||||
//#region date
|
||||
const id_date = PSPDFKit.generateInstantId()
|
||||
const id_date = generateId('date');
|
||||
const annotation_date = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||
id: id_date,
|
||||
pageIndex: page,
|
||||
@ -97,7 +102,7 @@ async function createAnnotations(document, envelopeId, receiverId) {
|
||||
this.markFieldAsCity(formFieldCity);
|
||||
|
||||
//#region date label
|
||||
const id_date_label = PSPDFKit.generateInstantId()
|
||||
const id_date_label = generateId('date_label');
|
||||
const annotation_date_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||
id: id_date_label,
|
||||
pageIndex: page,
|
||||
@ -120,7 +125,7 @@ async function createAnnotations(document, envelopeId, receiverId) {
|
||||
//#endregion
|
||||
|
||||
//#region city label
|
||||
const id_city_label = PSPDFKit.generateInstantId()
|
||||
const id_city_label = generateId('city_label');
|
||||
const annotation_city_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||
id: id_city_label,
|
||||
pageIndex: page,
|
||||
@ -143,7 +148,7 @@ async function createAnnotations(document, envelopeId, receiverId) {
|
||||
//#endregion
|
||||
|
||||
//#region position label
|
||||
const id_position_label = PSPDFKit.generateInstantId()
|
||||
const id_position_label = generateId('position_label');
|
||||
const annotation_position_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||
id: id_position_label,
|
||||
pageIndex: page,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user