Skip to content
Snippets Groups Projects
Commit 39e8aee5 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Add a SignatureEntry class as item type in the queue

This way we can store metadata directly in the queue
parent 3f871743
Branches
No related tags found
No related merge requests found
...@@ -120,8 +120,8 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem ...@@ -120,8 +120,8 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem
} }
async _updateNeedsPlacementStatus(id) { async _updateNeedsPlacementStatus(id) {
let file = this.queuedFiles[id]; let entry = this.queuedFiles[id];
let sigCount = await utils.getPDFSignatureCount(file); let sigCount = await utils.getPDFSignatureCount(entry.file);
this.queuedFilesNeedsPlacement.delete(id); this.queuedFilesNeedsPlacement.delete(id);
if (sigCount > 0) if (sigCount > 0)
this.queuedFilesNeedsPlacement.set(id, true); this.queuedFilesNeedsPlacement.set(id, true);
...@@ -161,7 +161,8 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem ...@@ -161,7 +161,8 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem
// take the file off the queue // take the file off the queue
const key = Object.keys(this.queuedFiles)[0]; const key = Object.keys(this.queuedFiles)[0];
const file = this.takeFileFromQueue(key); const entry = this.takeFileFromQueue(key);
const file = entry.file;
this.currentFile = file; this.currentFile = file;
// set placement mode and parameters to restore them when canceled // set placement mode and parameters to restore them when canceled
...@@ -368,16 +369,16 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem ...@@ -368,16 +369,16 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem
return; return;
} }
const file = this.getQueuedFile(key); const entry = this.getQueuedFile(key);
this.currentFile = file; this.currentFile = entry.file;
this.currentPreviewQueueKey = key; this.currentPreviewQueueKey = key;
console.log(file); console.log(entry);
// start signature placement process // start signature placement process
this.signaturePlacementInProgress = true; this.signaturePlacementInProgress = true;
this.withSigBlock = withSigBlock; this.withSigBlock = withSigBlock;
const previewTag = this.getScopedTagName("dbp-pdf-preview"); const previewTag = this.getScopedTagName("dbp-pdf-preview");
await this._(previewTag).showPDF( await this._(previewTag).showPDF(
file, entry.file,
withSigBlock, //this.queuedFilesPlacementModes[key] === "manual", withSigBlock, //this.queuedFilesPlacementModes[key] === "manual",
this.queuedFilesSignaturePlacements[key]); this.queuedFilesSignaturePlacements[key]);
} }
...@@ -700,7 +701,7 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem ...@@ -700,7 +701,7 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem
let results = []; let results = [];
ids.forEach((id) => { ids.forEach((id) => {
const file = this.queuedFiles[id]; const file = this.queuedFiles[id].file;
const isManual = this.queuedFilesPlacementModes[id] === 'manual'; const isManual = this.queuedFilesPlacementModes[id] === 'manual';
const placementMissing = this.queuedFilesNeedsPlacement.get(id) && !isManual; const placementMissing = this.queuedFilesNeedsPlacement.get(id) && !isManual;
......
...@@ -138,8 +138,8 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle ...@@ -138,8 +138,8 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle
} }
async _updateNeedsPlacementStatus(id) { async _updateNeedsPlacementStatus(id) {
let file = this.queuedFiles[id]; let entry = this.queuedFiles[id];
let sigCount = await getPDFSignatureCount(file); let sigCount = await getPDFSignatureCount(entry.file);
this.queuedFilesNeedsPlacement.delete(id); this.queuedFilesNeedsPlacement.delete(id);
if (sigCount > 0) if (sigCount > 0)
this.queuedFilesNeedsPlacement.set(id, true); this.queuedFilesNeedsPlacement.set(id, true);
...@@ -179,7 +179,8 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle ...@@ -179,7 +179,8 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle
// take the file off the queue // take the file off the queue
const key = Object.keys(this.queuedFiles)[0]; const key = Object.keys(this.queuedFiles)[0];
const file = this.takeFileFromQueue(key); const entry = this.takeFileFromQueue(key);
const file = entry.file;
this.currentFile = file; this.currentFile = file;
// set placement mode and parameters to restore them when canceled // set placement mode and parameters to restore them when canceled
...@@ -490,16 +491,16 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle ...@@ -490,16 +491,16 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle
return; return;
} }
const file = this.getQueuedFile(key); const entry = this.getQueuedFile(key);
this.currentFile = file; this.currentFile = entry.file;
this.currentPreviewQueueKey = key; this.currentPreviewQueueKey = key;
console.log(file); console.log(entry);
// start signature placement process // start signature placement process
this.signaturePlacementInProgress = true; this.signaturePlacementInProgress = true;
this.withSigBlock = withSigBlock; this.withSigBlock = withSigBlock;
const previewTag = this.getScopedTagName("dbp-pdf-preview"); const previewTag = this.getScopedTagName("dbp-pdf-preview");
await this._(previewTag).showPDF( await this._(previewTag).showPDF(
file, entry.file,
withSigBlock, //this.queuedFilesPlacementModes[key] === "manual", withSigBlock, //this.queuedFilesPlacementModes[key] === "manual",
this.queuedFilesSignaturePlacements[key]); this.queuedFilesSignaturePlacements[key]);
} }
...@@ -843,7 +844,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle ...@@ -843,7 +844,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle
let results = []; let results = [];
ids.forEach((id) => { ids.forEach((id) => {
const file = this.queuedFiles[id]; const file = this.queuedFiles[id].file;
const isManual = this.queuedFilesPlacementModes[id] === 'manual'; const isManual = this.queuedFilesPlacementModes[id] === 'manual';
const placementMissing = this.queuedFilesNeedsPlacement.get(id) && !isManual; const placementMissing = this.queuedFilesNeedsPlacement.get(id) && !isManual;
......
import * as utils from "./utils"; import * as utils from "./utils";
import * as commonUtils from "@dbp-toolkit/common/utils"; import * as commonUtils from "@dbp-toolkit/common/utils";
import {BaseLitElement} from './base-element.js'; import {BaseLitElement} from './base-element.js';
import {SignatureEntry} from './signature-entry.js';
export default class DBPSignatureLitElement extends BaseLitElement { export default class DBPSignatureLitElement extends BaseLitElement {
constructor() { constructor() {
...@@ -32,23 +33,24 @@ export default class DBPSignatureLitElement extends BaseLitElement { ...@@ -32,23 +33,24 @@ export default class DBPSignatureLitElement extends BaseLitElement {
*/ */
queueFile(file) { queueFile(file) {
this._queueKey++; this._queueKey++;
const key = this._queueKey; const key = String(this._queueKey);
this.queuedFiles[key] = file; this.queuedFiles[key] = new SignatureEntry(key, file);
this.updateQueuedFilesCount(); this.updateQueuedFilesCount();
return String(key); return key;
} }
/** /**
* Takes a file off of the queue * Takes a file off of the queue
* *
* @param key * @param key
* @returns {SignatureEntry} entry
*/ */
takeFileFromQueue(key) { takeFileFromQueue(key) {
const file = this.queuedFiles[key]; const entry = this.queuedFiles[key];
delete this.queuedFiles[key]; delete this.queuedFiles[key];
this.updateQueuedFilesCount(); this.updateQueuedFilesCount();
return file; return entry;
} }
/** /**
...@@ -257,10 +259,6 @@ export default class DBPSignatureLitElement extends BaseLitElement { ...@@ -257,10 +259,6 @@ export default class DBPSignatureLitElement extends BaseLitElement {
return this.queuedFiles[key]; return this.queuedFiles[key];
} }
getQueuedFiles() {
return this.queuedFiles;
}
clearQueuedFiles() { clearQueuedFiles() {
this.queuedFilesAnnotations = []; this.queuedFilesAnnotations = [];
this.queuedFilesAnnotationsCount = 0; this.queuedFilesAnnotationsCount = 0;
...@@ -278,10 +276,6 @@ export default class DBPSignatureLitElement extends BaseLitElement { ...@@ -278,10 +276,6 @@ export default class DBPSignatureLitElement extends BaseLitElement {
return this.queuedFilesCount; return this.queuedFilesCount;
} }
getQueuedFilesCount() {
return this.queuedFilesCount;
}
/** /**
* @param file * @param file
* @param params * @param params
......
export class SignatureEntry {
constructor(key, file) {
this.key = key;
this.file = file;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment