mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Replace CompanyCreate and CompanyEdit forms with AJAX form
- Adds the ability to specify an "icon" for each field
This commit is contained in:
		| @@ -111,11 +111,7 @@ | ||||
|     }); | ||||
|  | ||||
|     $('#company-edit').click(function() { | ||||
|         launchModalForm( | ||||
|             "{% url 'company-edit' company.id %}", | ||||
|             { | ||||
|                 reload: true | ||||
|             }); | ||||
|         editCompany({{ company.id }}); | ||||
|     }); | ||||
|  | ||||
|     $("#company-order-2").click(function() { | ||||
|   | ||||
| @@ -32,49 +32,16 @@ | ||||
|  | ||||
|     $('#new-company').click(function() { | ||||
|  | ||||
|         var fields = companyFormFields(); | ||||
|  | ||||
|         // Field overrides | ||||
|         fields.is_supplier.value = {% if pagetype == 'suppliers' %}true{% else %}false{% endif %}; | ||||
|         fields.is_manufacturer.value = {% if pagetype == 'manufacturers' %}true{% else %}false{% endif %}; | ||||
|         fields.is_customer.value = {% if pagetype == 'customers' %}true{% else %}false{% endif %}; | ||||
|  | ||||
|         createCompany({ | ||||
|             fields: { | ||||
|                 is_supplier: { | ||||
|                     value: {% if pagetype == 'suppliers' %}true{% else %}false{% endif %}, | ||||
|                 }, | ||||
|                 is_manufacturer: { | ||||
|                     value: {% if pagetype == 'manufacturers' %}true{% else %}false{% endif %}, | ||||
|                 }, | ||||
|                 is_customer: { | ||||
|                     value: {% if pagetype == 'customers' %}true{% else %}false{% endif %}, | ||||
|                 }, | ||||
|             } | ||||
|             fields: fields, | ||||
|         }); | ||||
|  | ||||
|         return; | ||||
|  | ||||
|         constructForm( | ||||
|             '{% url "api-company-list" %}', | ||||
|             { | ||||
|                 method: 'POST', | ||||
|                 title: '{% trans "Create new Company" %}', | ||||
|                 follow: true, | ||||
|                 fields: { | ||||
|                     name: {}, | ||||
|                     description: {}, | ||||
|                     website: {}, | ||||
|                     address: {}, | ||||
|                     currency: {}, | ||||
|                     phone: {}, | ||||
|                     email: {}, | ||||
|                     contact: {}, | ||||
|                     is_supplier: { | ||||
|                         value: {% if pagetype == 'suppliers' %}true{% else %}false{% endif %}, | ||||
|                     }, | ||||
|                     is_manufacturer: { | ||||
|                         value: {% if pagetype == 'manufacturers' %}true{% else %}false{% endif %}, | ||||
|                     }, | ||||
|                     is_customer: { | ||||
|                         value: {% if pagetype == 'customers' %}true{% else %}false{% endif %}, | ||||
|                     }, | ||||
|                 } | ||||
|             } | ||||
|         ); | ||||
|     }); | ||||
|  | ||||
|     loadCompanyTable("#company-table", "{% url 'api-company-list' %}", | ||||
|   | ||||
| @@ -246,23 +246,11 @@ class CompanyImage(AjaxUpdateView): | ||||
|         } | ||||
|  | ||||
|  | ||||
| class CompanyEdit(AjaxUpdateView): | ||||
|     """ View for editing a Company object """ | ||||
|     model = Company | ||||
|     form_class = EditCompanyForm | ||||
|     context_object_name = 'company' | ||||
|     ajax_template_name = 'modal_form.html' | ||||
|     ajax_form_title = _('Edit Company') | ||||
|     permission_required = 'company.change_company' | ||||
|  | ||||
|     def get_data(self): | ||||
|         return { | ||||
|             'info': _('Edited company information'), | ||||
|         } | ||||
|  | ||||
|  | ||||
| class CompanyCreate(AjaxCreateView): | ||||
|     """ View for creating a new Company object """ | ||||
|     """ | ||||
|     View for creating a new Company object | ||||
|     """ | ||||
|      | ||||
|     model = Company | ||||
|     context_object_name = 'company' | ||||
|     form_class = EditCompanyForm | ||||
|   | ||||
		Reference in New Issue
	
	Block a user