mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-07-05 20:23:17 +00:00
Enhance list onClick handling
This commit is contained in:
@ -24,10 +24,10 @@ class JobInputList extends ResourceList {
|
||||
|
||||
get item() {
|
||||
return `
|
||||
<tr class="clickable hoverable">
|
||||
<tr class="list-item clickable hoverable">
|
||||
<td><span class="filename"></span></td>
|
||||
<td class="right-align">
|
||||
<a class="action-button btn-floating waves-effect waves-light" data-action="download"><i class="material-icons">file_download</i></a>
|
||||
<a class="list-action-trigger btn-floating waves-effect waves-light" data-list-action="download"><i class="material-icons">file_download</i></a>
|
||||
</td>
|
||||
</tr>
|
||||
`.trim();
|
||||
@ -78,15 +78,18 @@ class JobInputList extends ResourceList {
|
||||
}
|
||||
|
||||
onClick(event) {
|
||||
let jobInputElement = event.target.closest('tr');
|
||||
if (jobInputElement === null) {return;}
|
||||
let jobInputId = jobInputElement.dataset.id;
|
||||
if (jobInputId === undefined) {return;}
|
||||
let actionButtonElement = event.target.closest('.action-button');
|
||||
let action = actionButtonElement === null ? 'download' : actionButtonElement.dataset.action;
|
||||
switch (action) {
|
||||
let listItemElement = event.target.closest('.list-item');
|
||||
if (listItemElement === null) {return;}
|
||||
if (!('id' in listItemElement.dataset)) {return;}
|
||||
let itemId = listItemElement.dataset.id;
|
||||
if (itemId === undefined) {return;}
|
||||
let listActionElement = event.target.closest('.list-item .list-action-trigger');
|
||||
let listAction =
|
||||
listActionElement === null || !('listAction' in listActionElement.dataset)
|
||||
? 'download' : listActionElement.dataset.listAction;
|
||||
switch (listAction) {
|
||||
case 'download': {
|
||||
window.location.href = `/jobs/${this.jobId}/inputs/${jobInputId}/download`;
|
||||
window.location.href = `/jobs/${this.jobId}/inputs/${itemId}/download`;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
Reference in New Issue
Block a user