This commit is contained in:
Frank Knoll
2024-07-17 10:11:52 +02:00
parent c6f0ba2dc8
commit 99fad75f54
2 changed files with 3 additions and 28 deletions

View File

@@ -1,47 +1,21 @@
class PrrByKeyTableView { class PrrByKeyTableView {
#prrByKeyTable; #prrByKeyTable;
#downloadPrrByKeyTableButton;
#text;
#valueName;
#prrByKeyProvider; #prrByKeyProvider;
// FK-TODO: remove downloadPrrByKeyTableButton and valueName
constructor(prrByKeyTable, downloadPrrByKeyTableButton, valueName, prrByKeyProvider) { constructor(prrByKeyTable, downloadPrrByKeyTableButton, valueName, prrByKeyProvider) {
this.#prrByKeyTable = prrByKeyTable; this.#prrByKeyTable = prrByKeyTable;
this.#prrByKeyTable.initialize(); this.#prrByKeyTable.initialize();
this.#initializeButton(downloadPrrByKeyTableButton);
this.#valueName = valueName;
this.#prrByKeyProvider = prrByKeyProvider; this.#prrByKeyProvider = prrByKeyProvider;
} }
displayPrrByKeyTable4Value(id, text) { displayPrrByKeyTable4Value(id, text) {
UIUtils.disableButton(this.#downloadPrrByKeyTableButton);
this.#prrByKeyProvider(id) this.#prrByKeyProvider(id)
.then(prrByKey => { .then(prrByKey => this.#prrByKeyTable.display(prrByKey));
this.#text = text;
this.#prrByKeyTable.display(prrByKey);
UIUtils.enableButton(this.#downloadPrrByKeyTableButton);
});
} }
getTable() { getTable() {
return this.#prrByKeyTable.getTable(); return this.#prrByKeyTable.getTable();
} }
#initializeButton(downloadPrrByKeyTableButton) {
this.#downloadPrrByKeyTableButton = downloadPrrByKeyTableButton;
UIUtils.disableButton(downloadPrrByKeyTableButton);
downloadPrrByKeyTableButton.addEventListener(
'click',
() => this.#downloadPrrByKey())
}
#downloadPrrByKey() {
UrlUtils.downloadUrlAsFilename(
window.URL.createObjectURL(
new Blob(
[this.#prrByKeyTable.getDisplayedTableAsCsv(`# ${this.#valueName}: ${this.#text}`)],
{ type: 'text/csv' })),
this.#text);
}
} }

View File

@@ -4932,6 +4932,7 @@ table.dataTable.display tbody tr.prrTooHigh {
max-width: 100%; max-width: 100%;
} }
/* FK-TODO: remove this class: */
.downloadButton { .downloadButton {
margin-top: 10px; margin-top: 10px;
display: none; display: none;