mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 10:54:18 +00:00
Remove unused function in utils
This commit is contained in:
parent
21819bfd9b
commit
c589fd1f78
@ -69,62 +69,6 @@ class Utils {
|
|||||||
return Utils.mergeObjectsDeep(mergedObject, ...objects.slice(2));
|
return Utils.mergeObjectsDeep(mergedObject, ...objects.slice(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static deleteCorpusFileRequest(userId, corpusId, corpusFileId) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
let corpusFile;
|
|
||||||
try {
|
|
||||||
corpusFile = app.data.users[userId].corpora[corpusId].files[corpusFileId];
|
|
||||||
} catch (error) {
|
|
||||||
corpusFile = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
let modalElement = Utils.HTMLToElement(
|
|
||||||
`
|
|
||||||
<div class="modal">
|
|
||||||
<div class="modal-content">
|
|
||||||
<h4>Confirm Corpus File deletion</h4>
|
|
||||||
<p>Do you really want to delete the Corpus File <b>${corpusFile?.title}</b>? All files will be permanently deleted!</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<a class="action-button btn modal-close waves-effect waves-light" data-action="cancel">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) => {
|
|
||||||
let corpusFileTitle = corpusFile?.title;
|
|
||||||
fetch(`/corpora/${corpusId}/files/${corpusFileId}`, {method: 'DELETE', headers: {Accept: 'application/json'}})
|
|
||||||
.then(
|
|
||||||
(response) => {
|
|
||||||
if (response.status === 403) {app.flash('Forbidden', 'error'); reject(response);}
|
|
||||||
if (response.status === 404) {app.flash('Not Found', 'error'); reject(response);}
|
|
||||||
app.flash(`Corpus File "${corpusFileTitle}" deleted`, 'corpus');
|
|
||||||
resolve(response);
|
|
||||||
},
|
|
||||||
(response) => {
|
|
||||||
app.flash('Something went wrong', 'error');
|
|
||||||
reject(response);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
modal.open();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static deleteProfileAvatarRequest(userId) {
|
static deleteProfileAvatarRequest(userId) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let modalElement = Utils.HTMLToElement(
|
let modalElement = Utils.HTMLToElement(
|
||||||
|
Loading…
Reference in New Issue
Block a user