mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 11:36:24 +00:00
Allow model class to be filtered
- Each subclass should provide a custom filtering function
This commit is contained in:
parent
ee7ab5308e
commit
728597fcdc
4 changed files with 50 additions and 2 deletions
|
|
@ -28,6 +28,17 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
|
|||
|
||||
List<InvenTreeStockLocation> _sublocations = List<InvenTreeStockLocation>();
|
||||
|
||||
String _locationFilter = '';
|
||||
|
||||
List<InvenTreeStockLocation> get sublocations {
|
||||
|
||||
if (_locationFilter.isEmpty || _sublocations.isEmpty) {
|
||||
return _sublocations;
|
||||
} else {
|
||||
return _sublocations.where((loc) => loc.filter(_locationFilter)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
List<InvenTreeStockItem> _items = List<InvenTreeStockItem>();
|
||||
|
||||
String get _title {
|
||||
|
|
@ -86,7 +97,17 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
|
|||
textAlign: TextAlign.left,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Expanded(child: SublocationList(_sublocations)),
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: "Filter locations",
|
||||
),
|
||||
onChanged: (text) {
|
||||
setState(() {
|
||||
_locationFilter = text.trim().toLowerCase();
|
||||
});
|
||||
},
|
||||
),
|
||||
Expanded(child: SublocationList(sublocations)),
|
||||
Divider(),
|
||||
Text(
|
||||
"Stock Items - ${_items.length}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue