Skip to content
Snippets Groups Projects
Commit 6f0fd5bc authored by Patrick Jentsch's avatar Patrick Jentsch
Browse files

Add delete function for services

parent db16cbf7
No related branches found
No related tags found
No related merge requests found
......@@ -127,9 +127,9 @@ def delete_query_result(query_result_id):
if not (query_result.creator == current_user
or current_user.is_administrator()):
abort(403)
tasks.delete_result(query_result_id)
tasks.delete_query_result(query_result_id)
flash('Query result deleted!', 'result')
return redirect(url_for('main.dashboard'))
return redirect(url_for('services.service', service="corpus_analysis"))
@query_results.route('/<int:query_result_id>/download')
......
......@@ -118,6 +118,7 @@ RessourceList.dataMapper = {
// Mapping for imported result entities from corpus analysis.
// Shown in imported results table
QueryResult: query_result => ({corpus_name: query_result.query_metadata.corpus_name,
"delete-link": `prepareQueryResultModal(${query_result.id})`,
description: query_result.description,
id: query_result.id,
"inspect-link": `/query_results/${query_result.id}/inspect`,
......@@ -255,6 +256,9 @@ RessourceList.options = {
<a class="btn-floating tooltipped waves-effect waves-light inspect-link" data-position="top" data-tooltip="View Results">
<i class="material-icons">search</i>
</a>
<a class="btn-floating modal-trigger red tooltipped waves-effect waves-light delete-link" data-position="top" data-tooltip="Delete">
<i class="material-icons">delete</i>
</a>
<a class="btn-floating tooltipped link waves-effect waves-light" data-position="top" data-tooltip="Go to query result">
<i class="material-icons">send</i>
</a>
......@@ -265,6 +269,7 @@ RessourceList.options = {
"query",
"title",
{data: ["id"]},
{name: "delete-link", attr: "onclick"},
{name: "inspect-link", attr: "href"},
{name: "link", attr: "href"}]},
// User entity blueprint setting html strucuture per entity per row
......
......@@ -83,11 +83,42 @@
</div>
</div>
<!-- Modals -->
<div id="delete-query-result-modal" class="modal no-autoinit">
<div class="modal-content">
<h4>Confirm deletion</h4>
<p>Do you really want to delete the query result <b id="selected-query-result-title"></b>? It will be permanently deleted.</p>
</div>
<div class="modal-footer">
<a href="#!" class="btn modal-close waves-effect waves-light">Cancel</a>
<a class="btn modal-close red waves-effect waves-light" id="selected-query-result-delete-link"><i class="material-icons left">delete</i>Delete</a>
</div>
</div>
<script>
var corpusList = new RessourceList("corpora", nopaque.corporaSubscribers,
"Corpus", {page: 10});
var queryResultList = new RessourceList("query-results",
nopaque.queryResultsSubscribers,
"QueryResult", {page: 10});
var deleteQueryResultModalElement = document.getElementById("delete-query-result-modal");
var deleteQueryResultModal;
var selectedQueryResultTitleElement = document.getElementById("selected-query-result-title");
var selectedQueryResultDeleteLinkElement = document.getElementById("selected-query-result-delete-link");
document.addEventListener("DOMContentLoaded", () => {
deleteQueryResultModal = M.Modal.init(deleteQueryResultModalElement);
});
function prepareQueryResultModal(selectedQueryResultId) {
if (selectedQueryResultId in nopaque.user.query_results) {
selectedQueryResult = nopaque.user.query_results[selectedQueryResultId];
selectedQueryResultTitleElement.innerText = selectedQueryResult.title;
selectedQueryResultDeleteLinkElement.href = `/query_results/${selectedQueryResult.id}/delete`;
} else {
selectedQueryResult = None;
selectedQueryResultTitleElement.innerText = "";
selectedQueryResultDeleteLinkElement.href = "";
}
deleteQueryResultModal.open();
}
</script>
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment