From 4c8b205ae2c1a7b519055431c5cc9fb614e45e1f Mon Sep 17 00:00:00 2001
From: Patrizio Bekerle <patrizio@bekerle.com>
Date: Wed, 31 Mar 2021 11:31:18 +0200
Subject: [PATCH] Fix adding annotations without organization to PDFs (#37)

---
 src/dbp-signature-lit-element.js | 2 +-
 src/utils.js                     | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/dbp-signature-lit-element.js b/src/dbp-signature-lit-element.js
index 1fe6400..223a2ec 100644
--- a/src/dbp-signature-lit-element.js
+++ b/src/dbp-signature-lit-element.js
@@ -200,7 +200,7 @@ export default class DBPSignatureLitElement extends DBPSignatureBaseLitElement {
             const organizationNumber = (annotation.organizationNumber || '').trim();
             const value = (annotation.value || '').trim();
 
-            if (annotationType === '' || organizationNumber === '' || value === '') {
+            if (annotationType === '' || value === '') {
                 return;
             }
 
diff --git a/src/utils.js b/src/utils.js
index 3a3ad8e..16dc508 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -192,7 +192,7 @@ export const addKeyValuePdfAnnotationsToAnnotationFactory = (annotationFactory,
     value = value.trim();
 
     // don't annotate if key or value are empty
-    if (annotationType === '' || organizationNumber === '' || value === '') {
+    if (annotationType === '' || value === '') {
         return annotationFactory;
     }
 
@@ -202,8 +202,9 @@ export const addKeyValuePdfAnnotationsToAnnotationFactory = (annotationFactory,
     annotationFactory = addPdfAnnotationToAnnotationFactory(annotationFactory, author, content);
 
     // add machine readable annotation
+    const organizationNumberContent = organizationNumber !== '' ? '_' + organizationNumber : '';
     author = 'Maschinell aufgebracht, bitte nicht entfernen / Applied automatically, please do not remove';
-    content = 'dbp_annotation_' + annotationType + '_' + organizationNumber + '=' + value;
+    content = 'dbp_annotation_' + annotationType + organizationNumberContent + '=' + value;
     annotationFactory = addPdfAnnotationToAnnotationFactory(annotationFactory, author, content);
 
     return annotationFactory;
-- 
GitLab