Fix JobList delete function

This commit is contained in:
Patrick Jentsch 2023-03-21 09:14:16 +01:00
parent f2bbcdc441
commit a676475b55
2 changed files with 33 additions and 3 deletions

View File

@ -56,7 +56,7 @@ class CorpusList extends ResourceList {
<div class="input-field">
<i class="material-icons prefix">search</i>
<input id="${listSearchElementId}" class="search" type="text"></input>
<label for="${listSearchElementId}">Search corpus</label>
<label for="${listSearchElementId}">Search Corpus</label>
</div>
<table>
<thead>

View File

@ -56,7 +56,7 @@ class JobList extends ResourceList {
<div class="input-field">
<i class="material-icons prefix">search</i>
<input id="${listSearchElementId}" class="search" type="text"></input>
<label for="${listSearchElementId}">Search job</label>
<label for="${listSearchElementId}">Search Job</label>
</div>
<table>
<thead>
@ -96,7 +96,37 @@ class JobList extends ResourceList {
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
switch (listAction) {
case 'delete-request': {
let values = this.listjs.get('id', itemId)[0].values();
let modalElement = Utils.HTMLToElement(
`
<div class="modal">
<div class="modal-content">
<h4>Confirm Job deletion</h4>
<p>Do you really want to delete the Job <b>${values.title}</b>? All files will be permanently deleted!</p>
</div>
<div class="modal-footer">
<a class="btn modal-close waves-effect waves-light">Cancel</a>
<a class="action-button btn modal-close red waves-effect waves-light" data-action="confirm">Delete</a>
</div>
</div>
`
);
document.querySelector('#modals').appendChild(modalElement);
let modal = M.Modal.init(
modalElement,
{
dismissible: false,
onCloseEnd: () => {
modal.destroy();
modalElement.remove();
}
}
);
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
confirmElement.addEventListener('click', (event) => {
Requests.jobs.entity.delete(itemId);
});
modal.open();
break;
}
case 'view': {