Browse Source
Merge pull request #193 from CatalystCode/enhancement/delete-document
Enhancement/Add button to delete documents on dataset page
pull/219/head
Hiroki Nakayama
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
23 additions and
0 deletions
-
app/server/static/js/dataset.js
-
app/server/templates/dataset.html
-
app/server/views.py
-
app/server/webpack.config.js
|
|
@ -0,0 +1,8 @@ |
|
|
|
import HTTP from './http'; |
|
|
|
|
|
|
|
document.querySelectorAll('.delete-document-button').forEach((deleteButton) => { |
|
|
|
deleteButton.addEventListener('click', () => { |
|
|
|
const documentId = deleteButton.getAttribute('data-delete-document-id'); |
|
|
|
HTTP.delete(`docs/${documentId}`).then(() => window.location.reload()); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -17,6 +17,7 @@ |
|
|
|
<tr> |
|
|
|
<th>#</th> |
|
|
|
<th>Text</th> |
|
|
|
<th></th> |
|
|
|
</tr> |
|
|
|
</thead> |
|
|
|
<tbody> |
|
|
@ -24,6 +25,16 @@ |
|
|
|
<tr> |
|
|
|
<td>{{ forloop.counter0|add:page_obj.start_index }}</td> |
|
|
|
<td>{{ doc.text|truncatechars:200 }}</td> |
|
|
|
<td> |
|
|
|
<p class="control"> |
|
|
|
<button class="button is-text delete-document-button" data-delete-document-id="{{ doc.id }}"> |
|
|
|
<span class="icon is-small"> |
|
|
|
<i class="fas fa-trash"></i> |
|
|
|
</span> |
|
|
|
<span>Delete</span> |
|
|
|
</button> |
|
|
|
</p> |
|
|
|
</td> |
|
|
|
</tr> |
|
|
|
{% endfor %} |
|
|
|
</tbody> |
|
|
|
|
|
@ -34,6 +34,9 @@ class ProjectsView(LoginRequiredMixin, TemplateView): |
|
|
|
class DatasetView(SuperUserMixin, LoginRequiredMixin, ListView): |
|
|
|
template_name = 'dataset.html' |
|
|
|
paginate_by = 5 |
|
|
|
extra_context = { |
|
|
|
'bundle_name': 'dataset' |
|
|
|
} |
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
project = get_object_or_404(Project, pk=self.kwargs['project_id']) |
|
|
|
|
|
@ -19,6 +19,7 @@ module.exports = { |
|
|
|
'stats': './static/js/stats.js', |
|
|
|
'label': './static/js/label.js', |
|
|
|
'guideline': './static/js/guideline.js', |
|
|
|
'dataset': './static/js/dataset.js', |
|
|
|
'demo_text_classification': './static/js/demo/demo_text_classification.js', |
|
|
|
'demo_named_entity': './static/js/demo/demo_named_entity.js', |
|
|
|
'demo_translation': './static/js/demo/demo_translation.js', |
|
|
|