Commit 58d22b72 authored by ibuler's avatar ibuler

[Feature] Label 删除修改

parent 6d552f46
...@@ -36,7 +36,7 @@ function initTable() { ...@@ -36,7 +36,7 @@ function initTable() {
{targets: 4, createdCell: function (td, cellData, rowData) { {targets: 4, createdCell: function (td, cellData, rowData) {
var update_btn = '<a href="{% url "assets:label-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'.replace('{{ DEFAULT_PK }}', cellData); var update_btn = '<a href="{% url "assets:label-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'.replace('{{ DEFAULT_PK }}', cellData);
var del_btn = '<a class="btn btn-xs btn-danger m-l-xs btn_cluster_delete" data-uid="{{ DEFAULT_PK }}">{% trans "Delete" %}</a>'.replace('{{ DEFAULT_PK }}', cellData); var del_btn = '<a class="btn btn-xs btn-danger m-l-xs btn-delete" data-uid="{{ DEFAULT_PK }}">{% trans "Delete" %}</a>'.replace('{{ DEFAULT_PK }}', cellData);
$(td).html(update_btn + del_btn) $(td).html(update_btn + del_btn)
}}], }}],
ajax_url: '{% url "api-assets:label-list" %}?sort=name', ajax_url: '{% url "api-assets:label-list" %}?sort=name',
...@@ -51,12 +51,12 @@ function initTable() { ...@@ -51,12 +51,12 @@ function initTable() {
$(document).ready(function(){ $(document).ready(function(){
initTable(); initTable();
}) })
.on('click', '.btn_cluster_delete', function () { .on('click', '.btn-delete', function () {
var $this = $(this); var $this = $(this);
var $data_table = $('#cluster_list_table').DataTable(); var $data_table = $('#label_list_table').DataTable();
var name = $(this).closest("tr").find(":nth-child(2)").children('a').html(); var name = $(this).closest("tr").find(":nth-child(2)").children('a').html();
var uid = $this.data('uid'); var uid = $this.data('uid');
var the_url = '{% url "api-assets:cluster-detail" pk=DEFAULT_PK %}'.replace('{{ DEFAULT_PK }}', uid); var the_url = '{% url "api-assets:label-detail" pk=DEFAULT_PK %}'.replace('{{ DEFAULT_PK }}', uid);
objectDelete($this, name, the_url); objectDelete($this, name, the_url);
setTimeout( function () { setTimeout( function () {
$data_table.ajax.reload(); $data_table.ajax.reload();
......
...@@ -56,5 +56,6 @@ urlpatterns = [ ...@@ -56,5 +56,6 @@ urlpatterns = [
url(r'^label/$', views.LabelListView.as_view(), name='label-list'), url(r'^label/$', views.LabelListView.as_view(), name='label-list'),
url(r'^label/create/$', views.LabelCreateView.as_view(), name='label-create'), url(r'^label/create/$', views.LabelCreateView.as_view(), name='label-create'),
url(r'^label/(?P<pk>[0-9a-zA-Z\-]{36})/update/$', views.LabelUpdateView.as_view(), name='label-update'), url(r'^label/(?P<pk>[0-9a-zA-Z\-]{36})/update/$', views.LabelUpdateView.as_view(), name='label-update'),
url(r'^label/(?P<pk>[0-9a-zA-Z\-]{36})/delete/$', views.LabelDeleteView.as_view(), name='label-delete'),
] ]
...@@ -67,4 +67,6 @@ class LabelDetailView(AdminUserRequiredMixin, DetailView): ...@@ -67,4 +67,6 @@ class LabelDetailView(AdminUserRequiredMixin, DetailView):
class LabelDeleteView(AdminUserRequiredMixin, DeleteView): class LabelDeleteView(AdminUserRequiredMixin, DeleteView):
pass model = Label
template_name = 'delete_confirm.html'
success_url = reverse_lazy('assets:label-list')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment