mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Simplify onclick code for ressource lists
This commit is contained in:
parent
0891176fd7
commit
900ef1ad6d
@ -84,15 +84,11 @@ class AdminUserList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
let listItemElement = event.target.closest('.list-item');
|
let listItemElement = event.target.closest('.list-item[data-id]');
|
||||||
if (listItemElement === null) {return;}
|
if (listItemElement === null) {return;}
|
||||||
if (!('id' in listItemElement.dataset)) {return;}
|
|
||||||
let itemId = listItemElement.dataset.id;
|
let itemId = listItemElement.dataset.id;
|
||||||
if (itemId === undefined) {return;}
|
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||||
let listActionElement = event.target.closest('.list-item .list-action-trigger');
|
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
||||||
let listAction =
|
|
||||||
listActionElement === null || !('listAction' in listActionElement.dataset)
|
|
||||||
? 'view' : listActionElement.dataset.listAction;
|
|
||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'delete': {
|
case 'delete': {
|
||||||
console.log('delete', itemId);
|
console.log('delete', itemId);
|
||||||
|
@ -92,15 +92,11 @@ class CorpusFileList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
let listItemElement = event.target.closest('.list-item');
|
let listItemElement = event.target.closest('.list-item[data-id]');
|
||||||
if (listItemElement === null) {return;}
|
if (listItemElement === null) {return;}
|
||||||
if (!('id' in listItemElement.dataset)) {return;}
|
|
||||||
let itemId = listItemElement.dataset.id;
|
let itemId = listItemElement.dataset.id;
|
||||||
if (itemId === undefined) {return;}
|
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||||
let listActionElement = event.target.closest('.list-item .list-action-trigger');
|
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
||||||
let listAction =
|
|
||||||
listActionElement === null || !('listAction' in listActionElement.dataset)
|
|
||||||
? 'view' : listActionElement.dataset.listAction;
|
|
||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'delete': {
|
case 'delete': {
|
||||||
Utils.deleteCorpusFileRequest(this.userId, this.corpusId, itemId);
|
Utils.deleteCorpusFileRequest(this.userId, this.corpusId, itemId);
|
||||||
|
@ -87,15 +87,11 @@ class CorpusList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
let listItemElement = event.target.closest('.list-item');
|
let listItemElement = event.target.closest('.list-item[data-id]');
|
||||||
if (listItemElement === null) {return;}
|
if (listItemElement === null) {return;}
|
||||||
if (!('id' in listItemElement.dataset)) {return;}
|
|
||||||
let itemId = listItemElement.dataset.id;
|
let itemId = listItemElement.dataset.id;
|
||||||
if (itemId === undefined) {return;}
|
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||||
let listActionElement = event.target.closest('.list-item .list-action-trigger');
|
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
||||||
let listAction =
|
|
||||||
listActionElement === null || !('listAction' in listActionElement.dataset)
|
|
||||||
? 'view' : listActionElement.dataset.listAction;
|
|
||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'delete-request': {
|
case 'delete-request': {
|
||||||
Utils.deleteCorpusRequest(this.userId, itemId);
|
Utils.deleteCorpusRequest(this.userId, itemId);
|
||||||
|
@ -78,15 +78,11 @@ class JobInputList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
let listItemElement = event.target.closest('.list-item');
|
let listItemElement = event.target.closest('.list-item[data-id]');
|
||||||
if (listItemElement === null) {return;}
|
if (listItemElement === null) {return;}
|
||||||
if (!('id' in listItemElement.dataset)) {return;}
|
|
||||||
let itemId = listItemElement.dataset.id;
|
let itemId = listItemElement.dataset.id;
|
||||||
if (itemId === undefined) {return;}
|
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||||
let listActionElement = event.target.closest('.list-item .list-action-trigger');
|
let listAction = listActionElement === null ? 'download' : listActionElement.dataset.listAction;
|
||||||
let listAction =
|
|
||||||
listActionElement === null || !('listAction' in listActionElement.dataset)
|
|
||||||
? 'download' : listActionElement.dataset.listAction;
|
|
||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'download': {
|
case 'download': {
|
||||||
window.location.href = `/jobs/${this.jobId}/inputs/${itemId}/download`;
|
window.location.href = `/jobs/${this.jobId}/inputs/${itemId}/download`;
|
||||||
|
@ -88,15 +88,11 @@ class JobList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
let listItemElement = event.target.closest('.list-item');
|
let listItemElement = event.target.closest('.list-item[data-id]');
|
||||||
if (listItemElement === null) {return;}
|
if (listItemElement === null) {return;}
|
||||||
if (!('id' in listItemElement.dataset)) {return;}
|
|
||||||
let itemId = listItemElement.dataset.id;
|
let itemId = listItemElement.dataset.id;
|
||||||
if (itemId === undefined) {return;}
|
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||||
let listActionElement = event.target.closest('.list-item .list-action-trigger');
|
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
||||||
let listAction =
|
|
||||||
listActionElement === null || !('listAction' in listActionElement.dataset)
|
|
||||||
? 'view' : listActionElement.dataset.listAction;
|
|
||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'delete-request': {
|
case 'delete-request': {
|
||||||
Utils.deleteJobRequest(this.userId, itemId);
|
Utils.deleteJobRequest(this.userId, itemId);
|
||||||
|
@ -82,15 +82,11 @@ class JobResultList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
let listItemElement = event.target.closest('.list-item');
|
let listItemElement = event.target.closest('.list-item[data-id]');
|
||||||
if (listItemElement === null) {return;}
|
if (listItemElement === null) {return;}
|
||||||
if (!('id' in listItemElement.dataset)) {return;}
|
|
||||||
let itemId = listItemElement.dataset.id;
|
let itemId = listItemElement.dataset.id;
|
||||||
if (itemId === undefined) {return;}
|
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||||
let listActionElement = event.target.closest('.list-item .list-action-trigger');
|
let listAction = listActionElement === null ? 'download' : listActionElement.dataset.listAction;
|
||||||
let listAction =
|
|
||||||
listActionElement === null || !('listAction' in listActionElement.dataset)
|
|
||||||
? 'download' : listActionElement.dataset.listAction;
|
|
||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'download': {
|
case 'download': {
|
||||||
window.location.href = `/jobs/${this.jobId}/results/${itemId}/download`;
|
window.location.href = `/jobs/${this.jobId}/results/${itemId}/download`;
|
||||||
|
@ -86,15 +86,11 @@ class PublicUserList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
let listItemElement = event.target.closest('.list-item');
|
let listItemElement = event.target.closest('.list-item[data-id]');
|
||||||
if (listItemElement === null) {return;}
|
if (listItemElement === null) {return;}
|
||||||
if (!('id' in listItemElement.dataset)) {return;}
|
|
||||||
let itemId = listItemElement.dataset.id;
|
let itemId = listItemElement.dataset.id;
|
||||||
if (itemId === undefined) {return;}
|
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||||
let listActionElement = event.target.closest('.list-item .list-action-trigger');
|
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
||||||
let listAction =
|
|
||||||
listActionElement === null || !('listAction' in listActionElement.dataset)
|
|
||||||
? 'view' : listActionElement.dataset.listAction;
|
|
||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'view': {
|
case 'view': {
|
||||||
window.location.href = `/users/${itemId}`;
|
window.location.href = `/users/${itemId}`;
|
||||||
|
Loading…
Reference in New Issue
Block a user