2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-09 07:00:56 +00:00

Js forms updates (#4378)

* Refactor forms for creating and editing SalesOrder

- Common function for defining fields

* More visual improvements for forms

* Refactor fields for SupplierPartPriceBreak

* More refactoring

* Refactor for stockitemtestresult table

* Comment fields

* JS linting fix
This commit is contained in:
Oliver
2023-02-21 07:24:49 +11:00
committed by GitHub
parent 17bfea4428
commit 62455199f3
12 changed files with 267 additions and 172 deletions

View File

@ -13,11 +13,13 @@
createCompany,
createManufacturerPart,
createSupplierPart,
createSupplierPartPriceBreak,
deleteManufacturerParts,
deleteManufacturerPartParameters,
deleteSupplierParts,
duplicateSupplierPart,
editCompany,
editSupplierPartPriceBreak,
loadCompanyTable,
loadManufacturerPartTable,
loadManufacturerPartParameterTable,
@ -128,7 +130,7 @@ function supplierPartFields(options={}) {
icon: 'fa-link',
},
note: {
icon: 'fa-pencil-alt',
icon: 'fa-sticky-note',
},
packaging: {
icon: 'fa-box',
@ -321,6 +323,43 @@ function deleteSupplierParts(parts, options={}) {
}
/* Construct set of fields for SupplierPartPriceBreak form */
function supplierPartPriceBreakFields(options={}) {
let fields = {
part: {
hidden: true,
},
quantity: {},
price: {
icon: 'fa-dollar-sign',
},
price_currency: {
icon: 'fa-coins',
},
};
return fields;
}
/* Create a new SupplierPartPriceBreak instance */
function createSupplierPartPriceBreak(part_id, options={}) {
let fields = supplierPartPriceBreakFields(options);
fields.part.value = part_id;
constructForm('{% url "api-part-supplier-price-list" %}', {
fields: fields,
method: 'POST',
fields: fields,
title: '{% trans "Add Price Break" %}',
onSuccess: function(response) {
handleFormSuccess(response, options);
}
});
}
// Returns a default form-set for creating / editing a Company object
function companyFormFields() {
@ -1125,11 +1164,7 @@ function loadSupplierPriceBreakTable(options={}) {
var pk = $(this).attr('pk');
constructForm(`/api/company/price-break/${pk}/`, {
fields: {
quantity: {},
price: {},
price_currency: {},
},
fields: supplierPartPriceBreakFields(),
title: '{% trans "Edit Price Break" %}',
onSuccess: function() {
table.bootstrapTable('refresh');