2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +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"),
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)));
}
});
if (category.parentId < 0) {
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
} else {
// 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) {
return ListTile(
title: Text("Subcategories"),
leading: FaIcon(FontAwesomeIcons.stream),
trailing: Text("${_subcategories.length}"),
onTap: () {
setState(() {
@ -173,6 +180,7 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
headerBuilder: (BuildContext context, bool isExpanded) {
return ListTile(
title: Text("Parts"),
leading: FaIcon(FontAwesomeIcons.shapes),
trailing: Text("${_parts.length}"),
onTap: () {
setState(() {