Part Edit view now ajaxified

This commit is contained in:
Oliver 2018-04-26 23:28:27 +10:00
parent c0902626f4
commit 9fd275ed3e
2 changed files with 30 additions and 5 deletions

View File

@ -1,11 +1,14 @@
{% extends "part/part_base.html" %}
{% load static %}
{% block details %}
{% include 'part/tabs.html' with tab='detail' %}
<h3>Part Details</h3>
{% include 'modal.html' %}
{% include 'modal_delete.html' %}
<table class='table table-striped'>
<tr>
<td>Part name</td>
@ -15,6 +18,12 @@
<td>Description</td>
<td>{{ part.decription }}</td>
</tr>
{% if part.IPN %}
<tr>
<td>IPN</td>
<td>{{ part.IPN }}</td>
</tr>
{% endif %}
<tr>
<td>Category</td>
<td>
@ -73,8 +82,22 @@
{% endif %}
<div class='container-fluid'>
<a href="{% url 'part-edit' part.id %}"><button class="btn btn-info">Edit Part</button></a>
<a href="{% url 'part-delete' part.id %}"><button class="btn btn-danger">Delete Part</button></a>
<button class="btn btn-info" id='edit-part'>Edit Part</button>
<button class="btn btn-danger" id='delete-part'>Delete Part</button>
</div>
{% endblock %}
{% endblock %}
{% block javascript %}
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#edit-part").click(function() {
launchModalForm("#modal-form", "{% url 'part-edit' part.id %}");
});
});
</script>
{% endblock %}

View File

@ -84,10 +84,12 @@ class PartDetail(DetailView):
template_name = 'part/detail.html'
class PartEdit(UpdateView):
class PartEdit(AjaxUpdateView):
model = Part
form_class = EditPartForm
template_name = 'part/edit.html'
ajax_template_name = 'modal_form.html'
ajax_form_title = 'Edit Part Properties'
class PartDelete(DeleteView):