Skip to content
Snippets Groups Projects
Unverified Commit 0135a4de authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Implement enabling/disabling of pdf annotations (#37)

parent d5b95468
Branches
No related tags found
No related merge requests found
Pipeline #19081 passed
...@@ -52,6 +52,7 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem ...@@ -52,6 +52,7 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem
this.currentPreviewQueueKey = ''; this.currentPreviewQueueKey = '';
this.allowAnnotating = false; this.allowAnnotating = false;
this.queuedFilesAnnotations = []; this.queuedFilesAnnotations = [];
this.queuedFilesEnabledAnnotations = [];
this.queuedFilesAnnotationsCount = 0; this.queuedFilesAnnotationsCount = 0;
this.isAnnotationViewVisible = false; this.isAnnotationViewVisible = false;
this.activity = new Activity(metadata); this.activity = new Activity(metadata);
...@@ -176,8 +177,9 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem ...@@ -176,8 +177,9 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem
fileSize: humanFileSize(file.size, false), fileSize: humanFileSize(file.size, false),
}); });
const annotationsEnabled = this.isAnnotationsEnabledForKey(key);
const annotations = this.takeAnnotationsFromQueue(key); const annotations = this.takeAnnotationsFromQueue(key);
await this.uploadFile(file, params, annotations); await this.uploadFile(file, params, annotationsEnabled ? annotations : []);
this.uploadInProgress = false; this.uploadInProgress = false;
} }
......
...@@ -134,11 +134,15 @@ export default class DBPSignatureLitElement extends DBPSignatureBaseLitElement { ...@@ -134,11 +134,15 @@ export default class DBPSignatureLitElement extends DBPSignatureBaseLitElement {
this._(viewTag).setAnnotationRows(this.queuedFilesAnnotations[key]); this._(viewTag).setAnnotationRows(this.queuedFilesAnnotations[key]);
this.isAnnotationViewVisible = true; this.isAnnotationViewVisible = true;
this.enableAnnotationsForKey(key);
} else {
this.disableAnnotationsForKey(key);
} else if (this.currentPreviewQueueKey === key) { if (this.currentPreviewQueueKey === key) {
this.isAnnotationViewVisible = false; this.isAnnotationViewVisible = false;
} }
} }
}
/** /**
* *
...@@ -219,10 +223,50 @@ export default class DBPSignatureLitElement extends DBPSignatureBaseLitElement { ...@@ -219,10 +223,50 @@ export default class DBPSignatureLitElement extends DBPSignatureBaseLitElement {
takeAnnotationsFromQueue(key) { takeAnnotationsFromQueue(key) {
const annotations = this.queuedFilesAnnotations[key]; const annotations = this.queuedFilesAnnotations[key];
delete this.queuedFilesAnnotations[key]; delete this.queuedFilesAnnotations[key];
this.disableAnnotationsForKey(key);
return annotations; return annotations;
} }
/**
* Checks if annotations are enabled for an annotation key
*
* @param key
* @returns {boolean}
*/
isAnnotationsEnabledForKey(key) {
return this.queuedFilesEnabledAnnotations.includes(key);
}
/**
* Enables annotations for an annotation key
*
* @param key
*/
enableAnnotationsForKey(key) {
if (!this.isAnnotationsEnabledForKey(key)) {
this.queuedFilesEnabledAnnotations.push(key);
}
}
/**
* Disables annotations for an annotation key
*
* @param key
*/
disableAnnotationsForKey(key) {
let i = 0;
// remove all occurrences of the value "key" in array this.queuedFilesEnabledAnnotations
while (i < this.queuedFilesEnabledAnnotations.length) {
if (this.queuedFilesEnabledAnnotations[i] === key) {
this.queuedFilesEnabledAnnotations.splice(i, 1);
} else {
++i;
}
}
}
/** /**
* Update an annotation of a file on the queue * Update an annotation of a file on the queue
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment