From f47a41513f39c207dc82e0a07e42428ff67cd03c Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle <patrizio@bekerle.com> Date: Wed, 31 Mar 2021 10:22:11 +0200 Subject: [PATCH] Remove obsolete code (#37) --- src/dbp-official-signature-pdf-upload.js | 46 ------------------------ src/dbp-signature-lit-element.js | 33 ----------------- src/utils.js | 27 -------------- 3 files changed, 106 deletions(-) diff --git a/src/dbp-official-signature-pdf-upload.js b/src/dbp-official-signature-pdf-upload.js index 4ecb5c3..6c24376 100644 --- a/src/dbp-official-signature-pdf-upload.js +++ b/src/dbp-official-signature-pdf-upload.js @@ -734,14 +734,6 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem ${i18n.t('label-manual-positioning-missing')} ` : '' } </div> - <div class="annotation-line ${classMap({hidden: !this.allowAnnotating})}" - ?disabled="${this.signingProcessEnabled}"> - <button class="button" - title="${i18n.t('official-pdf-upload.add-annotation-title')}" - @click="${() => { this.addAnnotation(id); }}"> - <dbp-icon name="plus"></dbp-icon></button> - ${this.getAnnotationsHtml(id)} - </div> </div> `); }); @@ -813,44 +805,6 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem return results; } - /** - * Returns the list of files of annotations of a queued file - * - * @param key - * @returns {*[]} Array of html templates - */ - getAnnotationsHtml(key) { - // console.log("getAnnotationsHtml(key)", key); - - const annotations = this.queuedFilesAnnotations[key] || []; - const ids = Object.keys(annotations); - let results = []; - - ids.forEach((id) => { - const data = this.queuedFilesAnnotations[key][id] || []; - - results.push(html` - <div class="annotation-block" class="annotation-block-${key}-${id}"> - <select class="select" @change=${e => { this.updateAnnotation(key, id, 'annotationType', e.target.value); }}> - <option value="">${i18n.t('official-pdf-upload.annotation-type-please-select')}</option> - ${utils.getAnnotationTypeSelectOptionsHtml(data.annotationType, this.lang)} - </select> - <dbp-organization-select subscribe="lang:lang,entry-point-url:entry-point-url,auth:auth" - value="${data.organizationNumber}" - @change=${e => { this.updateAnnotation(key, id, 'organizationNumber', JSON.parse(e.target.getAttribute("data-object")).alternateName); }}></dbp-organization-select> - <input type="text" .value="${data.value}" @change=${e => { this.updateAnnotation(key, id, 'value', e.target.value); }} placeholder="value" /> - <button class="button" - title="Remove annotation" - @click="${() => { this.removeAnnotation(key, id); }}"> - <dbp-icon name="trash"></dbp-icon></button> - </div> - </div> - `); - }); - - return results; - } - hasSignaturePermissions() { return this._hasSignaturePermissions('ROLE_SCOPE_OFFICIAL-SIGNATURE'); } diff --git a/src/dbp-signature-lit-element.js b/src/dbp-signature-lit-element.js index a7113db..02558c2 100644 --- a/src/dbp-signature-lit-element.js +++ b/src/dbp-signature-lit-element.js @@ -255,39 +255,6 @@ export default class DBPSignatureLitElement extends DBPSignatureBaseLitElement { } } - /** - * Add an annotation to a file on the queue - * - * @param key - */ - async addAnnotationToPDF(key) { - const annotationKey = prompt("Please enter a key"); - - if (annotationKey === null || annotationKey === "") { - return; - } - - const annotationValue = prompt("Please enter a value"); - - if (annotationValue === null || annotationValue === "") { - return; - } - - let file = this.queuedFiles[key]; - - // console.log("file before annotation", file); - - // annotate the pdf with the key and value - file = await utils.addKeyValuePdfAnnotation(file, 'AppNameDE', 'AppNameEN', this.auth['user-full-name'], annotationKey, annotationValue); - - // console.log("file after annotation", file); - - // overwrite the current pdf - this.queuedFiles[key] = file; - - return file; - } - getQueuedFile(key) { return this.queuedFiles[key]; } diff --git a/src/utils.js b/src/utils.js index 252ad1e..3a3ad8e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -144,33 +144,6 @@ export const getPDFSignatureCount = async (file) => { return matches; }; -/** - * Adds an annotation to a PDF file - * - * @param file - * @param activityNameDE - * @param activityNameEN - * @param personName - * @param key - * @param value - * @returns {File} file given as parameter, but with annotations - */ -export const addKeyValuePdfAnnotation = async (file, activityNameDE, activityNameEN, personName, key, value) => { - key = key.trim(); - value = value.trim(); - - // don't annotate if key or value are empty - if (key === '' || value === '') { - return file; - } - - let annotationFactory = await getAnnotationFactoryFromFile(file); - annotationFactory = addKeyValuePdfAnnotationsToAnnotationFactory(annotationFactory, activityNameDE, activityNameEN, - personName, key, 'Name DE', 'Name EN', 'organizationNumber', value); - - return writeAnnotationFactoryToFile(annotationFactory, file); -}; - /** * Returns a File from an AnnotationFactory * -- GitLab