mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Modal form for company-delete
This commit is contained in:
		| @@ -1,17 +1,13 @@ | |||||||
| {% extends "delete_obj.html" %} |  | ||||||
|  |  | ||||||
| {% block del_title %} |  | ||||||
| Are you sure you want to delete company '{{ company.name }}'? | Are you sure you want to delete company '{{ company.name }}'? | ||||||
| {% endblock %} |  | ||||||
|  |  | ||||||
| {% block del_body %} | <br> | ||||||
|  |  | ||||||
| {% if company.part_count > 0 %} | {% if company.part_count > 0 %} | ||||||
| <p>There are {{ company.part_count }} parts sourced from this company.<br> | <p>There are {{ company.part_count }} parts sourced from this company.<br> | ||||||
| If this supplier is deleted, these supplier part entries will also be deleted.</p> | If this supplier is deleted, these supplier part entries will also be deleted.</p> | ||||||
| <ul class='list-group'> | <ul class='list-group'> | ||||||
| {% for part in company.parts.all %} | {% for part in company.parts.all %} | ||||||
| <li class='list-group-item'><b>{{ part.SKU }}</b><br><i>Part - {{ part.part.name }}</i></li> | <li class='list-group-item'><b>{{ part.SKU }}</b> - <i>{{ part.part.name }}</i></li> | ||||||
| {% endfor %} | {% endfor %} | ||||||
| </ul> | </ul> | ||||||
| {% endif %} | {% endif %} | ||||||
| {% endblock %} |  | ||||||
| @@ -1,5 +1,5 @@ | |||||||
| {% extends "company/company_base.html" %} | {% extends "company/company_base.html" %} | ||||||
|  | {% load static %} | ||||||
| {% block details %} | {% block details %} | ||||||
|  |  | ||||||
| {% include 'company/tabs.html' with tab='details' %} | {% include 'company/tabs.html' with tab='details' %} | ||||||
| @@ -25,8 +25,36 @@ | |||||||
| {% endif %} | {% endif %} | ||||||
|  |  | ||||||
| <div class='container-fluid'> | <div class='container-fluid'> | ||||||
| <a href="{% url 'company-edit' company.id %}"><button class="btn btn-info">Edit Company</button></a> | <button class="btn btn-info" id='edit-company'>Edit Company</button> | ||||||
| <a href="{% url 'company-delete' company.id %}"><button class="btn btn-danger">Delete Company</button></a> | <button class="btn btn-danger" id='delete-company'>Delete Company</button> | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
|  | {% include 'modals.html' %} | ||||||
|  |  | ||||||
|  | {% endblock %} | ||||||
|  |  | ||||||
|  | {% block javascript %} | ||||||
|  | <script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script> | ||||||
|  |  | ||||||
|  | <script type='text/javascript'> | ||||||
|  | $(document).ready(function() { | ||||||
|  |     $('#edit-company').click(function() { | ||||||
|  |         launchModalForm("#modal-form", | ||||||
|  |                         "{% url 'company-edit' company.id %}", | ||||||
|  |                         { | ||||||
|  |                             reload: true | ||||||
|  |                         }); | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |     $('#delete-company').click(function() { | ||||||
|  |         launchDeleteForm("#modal-delete", | ||||||
|  |                          "{% url 'company-delete' company.id %}", | ||||||
|  |                          { | ||||||
|  |                              redirect: "{% url 'company-index' %}" | ||||||
|  |                          }); | ||||||
|  |     }) | ||||||
|  | }); | ||||||
|  | </script> | ||||||
|  |  | ||||||
|  |  | ||||||
| {% endblock %} | {% endblock %} | ||||||
| @@ -42,6 +42,7 @@ | |||||||
| <script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script> | <script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script> | ||||||
|  |  | ||||||
| <script type='text/javascript'> | <script type='text/javascript'> | ||||||
|  | $(document).ready(function() { | ||||||
|     $('#company-table').footable(); |     $('#company-table').footable(); | ||||||
|  |  | ||||||
|     $('#new-company').click(function () { |     $('#new-company').click(function () { | ||||||
| @@ -51,6 +52,7 @@ | |||||||
|                             follow: true |                             follow: true | ||||||
|                         }); |                         }); | ||||||
|     }); |     }); | ||||||
|  | }); | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| {% endblock %} | {% endblock %} | ||||||
| @@ -38,11 +38,13 @@ class CompanyDetail(DetailView): | |||||||
|     model = Company |     model = Company | ||||||
|  |  | ||||||
|  |  | ||||||
| class CompanyEdit(UpdateView): | class CompanyEdit(AjaxUpdateView): | ||||||
|     model = Company |     model = Company | ||||||
|     form_class = EditCompanyForm |     form_class = EditCompanyForm | ||||||
|     template_name = 'company/edit.html' |     template_name = 'company/edit.html' | ||||||
|     context_object_name = 'company' |     context_object_name = 'company' | ||||||
|  |     ajax_template_name = 'modal_form.html' | ||||||
|  |     ajax_form_title = 'Edit Company' | ||||||
|  |  | ||||||
|  |  | ||||||
| class CompanyCreate(AjaxCreateView): | class CompanyCreate(AjaxCreateView): | ||||||
| @@ -54,13 +56,8 @@ class CompanyCreate(AjaxCreateView): | |||||||
|     ajax_form_title = "Create new Company" |     ajax_form_title = "Create new Company" | ||||||
|  |  | ||||||
|  |  | ||||||
| class CompanyDelete(DeleteView): | class CompanyDelete(AjaxDeleteView): | ||||||
|     model = Company |     model = Company | ||||||
|     success_url = '/company/' |     success_url = '/company/' | ||||||
|     template_name = 'company/delete.html' |     template_name = 'company/delete.html' | ||||||
|  |     ajax_form_title = 'Delete Company' | ||||||
|     def post(self, request, *args, **kwargs): |  | ||||||
|         if 'confirm' in request.POST: |  | ||||||
|             return super(CompanyDelete, self).post(request, *args, **kwargs) |  | ||||||
|         else: |  | ||||||
|             return HttpResponseRedirect(self.get_object().get_absolute_url()) |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user