mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 21:45:39 +00:00
Feature/location types (#5588)
* Added model changes for StockLocationTypes * Implement icon for CUI * Added location type to location table with filters * Fix ruleset * Added tests * Bump api version to v136 * trigger: ci * Bump api version variable too
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
renderReturnOrder,
|
||||
renderStockItem,
|
||||
renderStockLocation,
|
||||
renderStockLocationType,
|
||||
renderSupplierPart,
|
||||
renderUser,
|
||||
*/
|
||||
@ -59,6 +60,8 @@ function getModelRenderer(model) {
|
||||
return renderStockItem;
|
||||
case 'stocklocation':
|
||||
return renderStockLocation;
|
||||
case 'stocklocationtype':
|
||||
return renderStockLocationType;
|
||||
case 'part':
|
||||
return renderPart;
|
||||
case 'partcategory':
|
||||
@ -259,6 +262,16 @@ function renderStockLocation(data, parameters={}) {
|
||||
);
|
||||
}
|
||||
|
||||
// Renderer for "StockLocationType" model
|
||||
function renderStockLocationType(data, parameters={}) {
|
||||
return renderModel(
|
||||
{
|
||||
text: `<span class="${data.icon} me-1"></span>${data.name}`,
|
||||
},
|
||||
parameters
|
||||
);
|
||||
}
|
||||
|
||||
function renderBuild(data, parameters={}) {
|
||||
|
||||
var image = blankImage();
|
||||
|
@ -81,6 +81,7 @@
|
||||
serializeStockItem,
|
||||
stockItemFields,
|
||||
stockLocationFields,
|
||||
stockLocationTypeFields,
|
||||
uninstallStockItem,
|
||||
*/
|
||||
|
||||
@ -130,6 +131,20 @@ function serializeStockItem(pk, options={}) {
|
||||
constructForm(url, options);
|
||||
}
|
||||
|
||||
function stockLocationTypeFields() {
|
||||
const fields = {
|
||||
name: {},
|
||||
description: {},
|
||||
icon: {
|
||||
help_text: `{% trans "Default icon for all locations that have no icon set (optional) - Explore all available icons on" %} <a href="https://fontawesome.com/v5/search?s=solid" target="_blank" rel="noopener noreferrer">Font Awesome</a>.`,
|
||||
placeholder: 'fas fa-box',
|
||||
icon: "fa-icons",
|
||||
},
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
||||
function stockLocationFields(options={}) {
|
||||
var fields = {
|
||||
@ -146,9 +161,20 @@ function stockLocationFields(options={}) {
|
||||
owner: {},
|
||||
structural: {},
|
||||
external: {},
|
||||
icon: {
|
||||
location_type: {
|
||||
secondary: {
|
||||
title: '{% trans "Add Location type" %}',
|
||||
fields: function() {
|
||||
const fields = stockLocationTypeFields();
|
||||
|
||||
return fields;
|
||||
}
|
||||
},
|
||||
},
|
||||
custom_icon: {
|
||||
help_text: `{% trans "Icon (optional) - Explore all available icons on" %} <a href="https://fontawesome.com/v5/search?s=solid" target="_blank" rel="noopener noreferrer">Font Awesome</a>.`,
|
||||
placeholder: 'fas fa-box',
|
||||
icon: "fa-icons",
|
||||
},
|
||||
};
|
||||
|
||||
@ -2729,7 +2755,18 @@ function loadStockLocationTable(table, options) {
|
||||
formatter: function(value) {
|
||||
return yesNoLabel(value);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'location_type',
|
||||
title: '{% trans "Location type" %}',
|
||||
switchable: true,
|
||||
sortable: false,
|
||||
formatter: function(value, row) {
|
||||
if (row.location_type_detail) {
|
||||
return row.location_type_detail.name;
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
});
|
||||
}
|
||||
|
@ -242,6 +242,30 @@ function getStockLocationFilters() {
|
||||
type: 'bool',
|
||||
title: '{% trans "External" %}',
|
||||
},
|
||||
location_type: {
|
||||
title: '{% trans "Location type" %}',
|
||||
options: function() {
|
||||
const locationTypes = {};
|
||||
|
||||
inventreeGet('{% url "api-location-type-list" %}', {}, {
|
||||
async: false,
|
||||
success: function(response) {
|
||||
for(const locationType of response) {
|
||||
locationTypes[locationType.pk] = {
|
||||
key: locationType.pk,
|
||||
value: locationType.name,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return locationTypes;
|
||||
},
|
||||
},
|
||||
has_location_type: {
|
||||
type: 'bool',
|
||||
title: '{% trans "Has location type" %}'
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user