Add modals for editing or deleting part parameters

This commit is contained in:
Oliver Walters 2019-08-28 19:39:47 +10:00
parent 51e4bdd821
commit 586a46175d
4 changed files with 32 additions and 2 deletions

View File

@ -0,0 +1,5 @@
{% extends "modal_delete_form.html" %}
{% block pre_form_content %}
Are you sure you want to remove this parameter?
{% endblock %}

View File

@ -29,8 +29,8 @@
<td>
{{ param.template.units }}
<div class='btn-group' style='float: right;'>
<button title='Edit' class='btn btn-default btn-glyph' type='button'><span class='glyphicon glyphicon-edit'/></button>
<button title='Delete' class='btn btn-default btn-glyph' type='button'><span class='glyphicon glyphicon-trash'/></button>
<button title='Edit' class='btn btn-default btn-glyph param-edit' url="{% url 'part-param-edit' param.id %}" type='button'><span class='glyphicon glyphicon-edit'/></button>
<button title='Delete' class='btn btn-default btn-glyph param-delete' url="{% url 'part-param-delete' param.id %}" type='button'><span class='glyphicon glyphicon-trash'/></button>
</div>
</td>
</tr>
@ -61,4 +61,20 @@
});
});
$('.param-edit').click(function() {
var button = $(this);
launchModalForm(button.attr('url'), {
reload: true,
});
});
$('.param-delete').click(function() {
var button = $(this);
launchModalForm(button.attr('url'), {
reload: true,
});
});
{% endblock %}

View File

@ -24,6 +24,7 @@ part_parameter_urls = [
url('^new/', views.PartParameterCreate.as_view(), name='part-param-create'),
url('^(?P<pk>\d+)/edit/', views.PartParameterEdit.as_view(), name='part-param-edit'),
url('^(?P<pk>\d+)/delete/', views.PartParameterDelete.as_view(), name='part-param-delete'),
]

View File

@ -1469,6 +1469,14 @@ class PartParameterEdit(AjaxUpdateView):
return form
class PartParameterDelete(AjaxDeleteView):
""" View for deleting a PartParameter """
model = PartParameter
ajax_template_name = 'part/param_delete.html'
ajax_form_title = 'Delete Part Parameter'
class CategoryDetail(DetailView):
""" Detail view for PartCategory """
model = PartCategory