mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-29 14:06:47 +00:00
Link to parent part category
This commit is contained in:
parent
0f2c88e630
commit
683f1e8efd
@ -14,6 +14,22 @@ class InvenTreePartCategory extends InvenTreeModel {
|
|||||||
|
|
||||||
String get pathstring => jsondata['pathstring'] ?? '';
|
String get pathstring => jsondata['pathstring'] ?? '';
|
||||||
|
|
||||||
|
String get parentpathstring {
|
||||||
|
List<String> psplit = pathstring.split("/");
|
||||||
|
|
||||||
|
if (psplit.length > 0) {
|
||||||
|
psplit.removeLast();
|
||||||
|
}
|
||||||
|
|
||||||
|
String p = psplit.join("/");
|
||||||
|
|
||||||
|
if (p.isEmpty) {
|
||||||
|
p = "Top level parts category";
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
int get partcount => jsondata['parts'] ?? 0;
|
int get partcount => jsondata['parts'] ?? 0;
|
||||||
|
|
||||||
InvenTreePartCategory() : super();
|
InvenTreePartCategory() : super();
|
||||||
|
@ -96,14 +96,30 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Card(
|
return Card(
|
||||||
child: ListTile(
|
child: Column(
|
||||||
title: Text("${category.name}"),
|
children: <Widget>[
|
||||||
subtitle: Text("${category.description}"),
|
ListTile(
|
||||||
trailing: IconButton(
|
title: Text("${category.name}"),
|
||||||
icon: FaIcon(FontAwesomeIcons.edit),
|
subtitle: Text("${category.description}"),
|
||||||
onPressed: null,
|
trailing: IconButton(
|
||||||
|
icon: FaIcon(FontAwesomeIcons.edit),
|
||||||
|
onPressed: null,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
ListTile(
|
||||||
|
title: Text("Parent Category"),
|
||||||
|
subtitle: Text("${category.parentpathstring}"),
|
||||||
|
onTap: () {
|
||||||
|
// TODO - Refactor this code into the InvenTreePart class
|
||||||
|
InvenTreePartCategory().get(category.parentId).then((var cat) {
|
||||||
|
if (cat is InvenTreePartCategory) {
|
||||||
|
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(cat)));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user