mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-01-18 14:00:33 +00:00
Add delete function for services
This commit is contained in:
parent
db16cbf7d6
commit
6f0fd5bc73
@ -127,9 +127,9 @@ def delete_query_result(query_result_id):
|
|||||||
if not (query_result.creator == current_user
|
if not (query_result.creator == current_user
|
||||||
or current_user.is_administrator()):
|
or current_user.is_administrator()):
|
||||||
abort(403)
|
abort(403)
|
||||||
tasks.delete_result(query_result_id)
|
tasks.delete_query_result(query_result_id)
|
||||||
flash('Query result deleted!', 'result')
|
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')
|
@query_results.route('/<int:query_result_id>/download')
|
||||||
|
@ -118,6 +118,7 @@ RessourceList.dataMapper = {
|
|||||||
// Mapping for imported result entities from corpus analysis.
|
// Mapping for imported result entities from corpus analysis.
|
||||||
// Shown in imported results table
|
// Shown in imported results table
|
||||||
QueryResult: query_result => ({corpus_name: query_result.query_metadata.corpus_name,
|
QueryResult: query_result => ({corpus_name: query_result.query_metadata.corpus_name,
|
||||||
|
"delete-link": `prepareQueryResultModal(${query_result.id})`,
|
||||||
description: query_result.description,
|
description: query_result.description,
|
||||||
id: query_result.id,
|
id: query_result.id,
|
||||||
"inspect-link": `/query_results/${query_result.id}/inspect`,
|
"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">
|
<a class="btn-floating tooltipped waves-effect waves-light inspect-link" data-position="top" data-tooltip="View Results">
|
||||||
<i class="material-icons">search</i>
|
<i class="material-icons">search</i>
|
||||||
</a>
|
</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">
|
<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>
|
<i class="material-icons">send</i>
|
||||||
</a>
|
</a>
|
||||||
@ -265,6 +269,7 @@ RessourceList.options = {
|
|||||||
"query",
|
"query",
|
||||||
"title",
|
"title",
|
||||||
{data: ["id"]},
|
{data: ["id"]},
|
||||||
|
{name: "delete-link", attr: "onclick"},
|
||||||
{name: "inspect-link", attr: "href"},
|
{name: "inspect-link", attr: "href"},
|
||||||
{name: "link", attr: "href"}]},
|
{name: "link", attr: "href"}]},
|
||||||
// User entity blueprint setting html strucuture per entity per row
|
// User entity blueprint setting html strucuture per entity per row
|
||||||
|
@ -83,11 +83,42 @@
|
|||||||
</div>
|
</div>
|
||||||
</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>
|
<script>
|
||||||
var corpusList = new RessourceList("corpora", nopaque.corporaSubscribers,
|
var corpusList = new RessourceList("corpora", nopaque.corporaSubscribers,
|
||||||
"Corpus", {page: 10});
|
"Corpus", {page: 10});
|
||||||
var queryResultList = new RessourceList("query-results",
|
var queryResultList = new RessourceList("query-results",
|
||||||
nopaque.queryResultsSubscribers,
|
nopaque.queryResultsSubscribers,
|
||||||
"QueryResult", {page: 10});
|
"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>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user