mirror of
https://github.com/inventree/inventree-app.git
synced 2025-05-01 06:56:50 +00:00
Improves search filtering of part results
This commit is contained in:
parent
ce4338f244
commit
fe2913529b
@ -283,32 +283,8 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
children: detailTiles()
|
||||
);
|
||||
case 1:
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
getCategoryDescriptionCard(extra: false),
|
||||
ListTile(
|
||||
title: Text(
|
||||
I18N.of(context).parts,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
trailing: Text(
|
||||
"${partCount}",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Divider(height: 3),
|
||||
Expanded(
|
||||
child: PaginatedPartList(
|
||||
return PaginatedPartList(
|
||||
{"category": "${category?.pk ?? null}"},
|
||||
onTotalChanged: (int total) {
|
||||
setState(() {
|
||||
partCount = total;
|
||||
});
|
||||
},
|
||||
)
|
||||
)
|
||||
],
|
||||
);
|
||||
case 2:
|
||||
return ListView(
|
||||
@ -410,6 +386,8 @@ class _PaginatedPartListState extends State<PaginatedPartList> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
int resultCount = 0;
|
||||
|
||||
Future<void> _fetchPage(int pageKey) async {
|
||||
try {
|
||||
|
||||
@ -445,6 +423,10 @@ class _PaginatedPartListState extends State<PaginatedPartList> {
|
||||
onTotalChanged(page.count);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
resultCount = page.count;
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
print("Error! - ${error.toString()}");
|
||||
_pagingController.error = error;
|
||||
@ -484,13 +466,43 @@ class _PaginatedPartListState extends State<PaginatedPartList> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
PaginatedSearch(
|
||||
callback: updateSearchTerm,
|
||||
results: resultCount
|
||||
),
|
||||
Expanded(
|
||||
child: CustomScrollView(
|
||||
shrinkWrap: true,
|
||||
physics: ClampingScrollPhysics(),
|
||||
scrollDirection: Axis.vertical,
|
||||
slivers: [
|
||||
PagedSliverList.separated(
|
||||
pagingController: _pagingController,
|
||||
builderDelegate: PagedChildBuilderDelegate<InvenTreePart>(
|
||||
itemBuilder: (context, item, index) {
|
||||
return _buildPart(context, item);
|
||||
},
|
||||
noItemsFoundIndicatorBuilder: (context) {
|
||||
return NoResultsWidget("No parts found");
|
||||
},
|
||||
),
|
||||
separatorBuilder: (context, index) => const Divider(height: 1),
|
||||
)
|
||||
],
|
||||
)
|
||||
)
|
||||
],
|
||||
);
|
||||
return CustomScrollView(
|
||||
shrinkWrap: true,
|
||||
physics: ClampingScrollPhysics(),
|
||||
scrollDirection: Axis.vertical,
|
||||
slivers: <Widget>[
|
||||
// TODO: Introduce searching within the list
|
||||
//PaginatedSearch(callback: updateSearchTerm),
|
||||
PaginatedSearch(callback: updateSearchTerm),
|
||||
PagedSliverList.separated(
|
||||
pagingController: _pagingController,
|
||||
builderDelegate: PagedChildBuilderDelegate<InvenTreePart>(
|
||||
|
@ -9,17 +9,28 @@ class PaginatedSearch extends StatelessWidget {
|
||||
|
||||
Function callback;
|
||||
|
||||
PaginatedSearch({this.callback});
|
||||
int results = 0;
|
||||
|
||||
PaginatedSearch({this.callback, this.results});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverToBoxAdapter(
|
||||
child: TextField(
|
||||
onChanged: callback,
|
||||
return ListTile(
|
||||
leading: FaIcon(FontAwesomeIcons.search),
|
||||
title: TextField(
|
||||
onChanged: (value) {
|
||||
if (callback != null) {
|
||||
callback(value);
|
||||
}
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText: "Search",
|
||||
hintText: "Search parts",
|
||||
),
|
||||
),
|
||||
trailing: Text(
|
||||
"${results}",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -41,4 +52,3 @@ class NoResultsWidget extends StatelessWidget {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user