2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00

Include category detail when requesting part information

This commit is contained in:
Oliver Walters 2021-01-20 22:58:04 +11:00
parent b4710b56e3
commit 153bb1c077
3 changed files with 13 additions and 2 deletions

View File

@ -132,6 +132,13 @@ class InvenTreePart extends InvenTreeModel {
@override
String URL = "part/";
@override
Map<String, String> defaultGetFilters() {
return {
"category_detail": "1", // Include category detail information
};
}
List<InvenTreePartTestTemplate> testingTemplates = List<InvenTreePartTestTemplate>();
int get testTemplateCount => testingTemplates.length;
@ -195,7 +202,10 @@ class InvenTreePart extends InvenTreeModel {
int get categoryId => jsondata['category'] as int ?? null;
// Get the category name for the Part instance
String get categoryName => jsondata['category_name'] ?? '';
String get categoryName => jsondata['category_detail']['name'] as String ?? '';
// Get the category description for the Part instance
String get categoryDescription => jsondata['category_detail']['description'] as String ?? '';
// Get the image URL for the Part instance
String get _image => jsondata['image'] ?? '';

View File

@ -102,6 +102,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
ListTile(
title: Text("Parent Category"),
subtitle: Text("${category.parentpathstring}"),
leading: FaIcon(FontAwesomeIcons.sitemap),
onTap: () {
if (category.parentId < 0) {
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));

View File

@ -36,7 +36,7 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
// Function to construct an appbar (override if needed)
AppBar getAppBar(BuildContext context) {
return AppBar(
title: Text(getAppBarTitle(context))
title: Text(getAppBarTitle(context)),
);
}