2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-04 20:51:00 +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:
Oliver
2021-06-29 21:17:48 +10:00
parent cf0feffe26
commit c25967eff6
5 changed files with 67 additions and 79 deletions

View File

@ -111,11 +111,7 @@
});
$('#company-edit').click(function() {
launchModalForm(
"{% url 'company-edit' company.id %}",
{
reload: true
});
editCompany({{ company.id }});
});
$("#company-order-2").click(function() {

View File

@ -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' %}",

View File

@ -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