Skip to content

Commit 8f273d6

Browse files
committed
wip
1 parent 200cbf8 commit 8f273d6

5 files changed

+132
-19
lines changed

package-lock.json

+11-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dbp-official-signature-pdf-upload.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import metadata from './dbp-official-signature-pdf-upload.metadata.json';
1818
import {Activity} from './activity.js';
1919
import {PdfAnnotationView} from './dbp-pdf-annotation-view';
2020
import * as SignatureStyles from './styles';
21-
import {TabulatorTable} from '@dbp-toolkit/tabulator-table';
21+
import { CustomTabulatorTable } from './table-components.js';
2222

2323
class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElement) {
2424
constructor() {
@@ -54,7 +54,7 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem
5454
'dbp-icon-button': IconButton,
5555
'dbp-loading-button': LoadingButton,
5656
'dbp-pdf-annotation-view': PdfAnnotationView,
57-
'dbp-tabulator-table': TabulatorTable,
57+
'dbp-tabulator-table': CustomTabulatorTable,
5858
'dbp-tooltip': TooltipElement,
5959
'dbp-modal': Modal,
6060
};
@@ -106,9 +106,9 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem
106106

107107
firstUpdated(changedProperties) {
108108
super.firstUpdated(changedProperties);
109-
this.tableQueuedFilesTable = /** @type {TabulatorTable} */ (this._('#table-queued-files'));
110-
this.tableSignedFilesTable = /** @type {TabulatorTable} */ (this._('#table-signed-files'));
111-
this.tableFailedFilesTable = /** @type {TabulatorTable} */ (this._('#table-failed-files'));
109+
this.tableQueuedFilesTable = /** @type {CustomTabulatorTable} */ (this._('#table-queued-files'));
110+
this.tableSignedFilesTable = /** @type {CustomTabulatorTable} */ (this._('#table-signed-files'));
111+
this.tableFailedFilesTable = /** @type {CustomTabulatorTable} */ (this._('#table-failed-files'));
112112
}
113113

114114
async queueFile(file) {

src/dbp-signature-lit-element.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {getPDFSignatureCount} from './utils';
88
import { send } from '@dbp-toolkit/common/notification';
99
import { humanFileSize } from '@dbp-toolkit/common/i18next';
1010

11-
1211
export default class DBPSignatureLitElement extends BaseLitElement {
1312
constructor() {
1413
super();
@@ -1571,11 +1570,20 @@ export default class DBPSignatureLitElement extends BaseLitElement {
15711570
if(this.tableSignedFilesTable) {
15721571
ids.forEach((id) => {
15731572
const file = this.signedFiles[id];
1573+
1574+
let downloadButton = this.tableSignedFilesTable.shadowRoot.createElement('dbp-esign-download-button');
1575+
downloadButton.setAttribute('subscribe', 'lang');
1576+
downloadButton.file = file;
1577+
1578+
let filenameLabel = this.tableSignedFilesTable.shadowRoot.createElement('dbp-esign-filename-label');
1579+
filenameLabel.setAttribute('subscribe', 'lang');
1580+
filenameLabel.file = file;
1581+
15741582
let fileData = {
15751583
index: id,
1576-
fileName: `<span id="file-download-${id}">${file.name}</span>`,
1584+
fileName: filenameLabel,
15771585
fileSize: humanFileSize(file.contentSize),
1578-
downloadButton: this.getDownloadButtonHtml(id, file),
1586+
downloadButton: downloadButton,
15791587
};
15801588
tableFiles.push(fileData);
15811589
});

src/table-components.js

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { LitElement, html, css } from 'lit';
2+
import { createInstance } from './i18n.js';
3+
import { ScopedElementsMixin, IconButton } from '@dbp-toolkit/common';
4+
import { TabulatorTable } from '@dbp-toolkit/tabulator-table';
5+
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element';
6+
7+
8+
export class CustomTabulatorTable extends TabulatorTable {
9+
static get scopedElements() {
10+
return {
11+
'dbp-esign-download-button': DownloadButton,
12+
'dbp-esign-filename-label': FilenameLabel,
13+
};
14+
}
15+
}
16+
17+
export class FilenameLabel extends ScopedElementsMixin(DBPLitElement) {
18+
constructor() {
19+
super();
20+
this._i18n = createInstance();
21+
this.lang = this._i18n.language;
22+
this.file = null;
23+
}
24+
25+
static get properties() {
26+
return {
27+
...super.properties,
28+
lang: { type: String },
29+
file: { type: Object, attribute: false },
30+
};
31+
}
32+
33+
static get scopedElements() {
34+
return {
35+
};
36+
}
37+
38+
update(changedProperties) {
39+
changedProperties.forEach((oldValue, propName) => {
40+
switch (propName) {
41+
case 'lang':
42+
this._i18n.changeLanguage(this.lang);
43+
break;
44+
}
45+
});
46+
47+
super.update(changedProperties);
48+
}
49+
50+
render() {
51+
return html`
52+
${this.file ? this.file.name : ``}
53+
`;
54+
}
55+
}
56+
57+
export class DownloadButton extends ScopedElementsMixin(DBPLitElement) {
58+
constructor() {
59+
super();
60+
this._i18n = createInstance();
61+
this.lang = this._i18n.language;
62+
this.file = null;
63+
}
64+
65+
static get properties() {
66+
return {
67+
...super.properties,
68+
lang: { type: String },
69+
};
70+
}
71+
72+
static get scopedElements() {
73+
return {
74+
'dbp-icon-button': IconButton,
75+
};
76+
}
77+
78+
update(changedProperties) {
79+
changedProperties.forEach((oldValue, propName) => {
80+
switch (propName) {
81+
case 'lang':
82+
this._i18n.changeLanguage(this.lang);
83+
break;
84+
}
85+
});
86+
87+
super.update(changedProperties);
88+
}
89+
90+
_handleDownloadClick(event) {
91+
console.log(this.file);
92+
}
93+
94+
render() {
95+
return html`
96+
<dbp-icon-button
97+
icon-name="download"
98+
class="download-button"
99+
aria-label="${this._i18n.t('download-file-button-title')}"
100+
title="${this._i18n.t('download-file-button-title')}"
101+
@click="${this._handleDownloadClick}"></dbp-icon-button>
102+
`;
103+
}
104+
}

0 commit comments

Comments
 (0)