2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 13:36:50 +00:00

Navigate "up" the category path to the parent category

This commit is contained in:
Oliver Walters 2020-04-05 22:06:56 +10:00
parent 683f1e8efd
commit 15d5bf3fb5

View File

@ -110,12 +110,18 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
title: Text("Parent Category"), title: Text("Parent Category"),
subtitle: Text("${category.parentpathstring}"), subtitle: Text("${category.parentpathstring}"),
onTap: () { onTap: () {
// TODO - Refactor this code into the InvenTreePart class if (category.parentId < 0) {
InvenTreePartCategory().get(category.parentId).then((var cat) { Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
if (cat is InvenTreePartCategory) { } else {
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(cat))); // 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)));
}
});
}
}, },
) )
] ]
@ -158,6 +164,7 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
headerBuilder: (BuildContext context, bool isExpanded) { headerBuilder: (BuildContext context, bool isExpanded) {
return ListTile( return ListTile(
title: Text("Subcategories"), title: Text("Subcategories"),
leading: FaIcon(FontAwesomeIcons.stream),
trailing: Text("${_subcategories.length}"), trailing: Text("${_subcategories.length}"),
onTap: () { onTap: () {
setState(() { setState(() {
@ -173,6 +180,7 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
headerBuilder: (BuildContext context, bool isExpanded) { headerBuilder: (BuildContext context, bool isExpanded) {
return ListTile( return ListTile(
title: Text("Parts"), title: Text("Parts"),
leading: FaIcon(FontAwesomeIcons.shapes),
trailing: Text("${_parts.length}"), trailing: Text("${_parts.length}"),
onTap: () { onTap: () {
setState(() { setState(() {