mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Cascading list display working
This commit is contained in:
parent
bee04e2cd8
commit
ce4338f244
@ -21,6 +21,8 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
|||||||
|
|
||||||
bool barcodeSounds = true;
|
bool barcodeSounds = true;
|
||||||
bool serverSounds = true;
|
bool serverSounds = true;
|
||||||
|
bool partSubcategory = false;
|
||||||
|
bool stockSublocation = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -33,6 +35,9 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
|||||||
barcodeSounds = await InvenTreeSettingsManager().getValue("barcodeSounds", true) as bool;
|
barcodeSounds = await InvenTreeSettingsManager().getValue("barcodeSounds", true) as bool;
|
||||||
serverSounds = await InvenTreeSettingsManager().getValue("serverSounds", true) as bool;
|
serverSounds = await InvenTreeSettingsManager().getValue("serverSounds", true) as bool;
|
||||||
|
|
||||||
|
partSubcategory = await InvenTreeSettingsManager().getValue("partSubcategory", false) as bool;
|
||||||
|
stockSublocation = await InvenTreeSettingsManager().getValue("stockSublocation", false) as bool;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -55,6 +60,22 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPartSubcategory(bool en) async {
|
||||||
|
await InvenTreeSettingsManager().setValue("partSubcategory", en);
|
||||||
|
partSubcategory = await InvenTreeSettingsManager().getValue("partSubcategory", false);
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void setStockSublocation(bool en) async {
|
||||||
|
await InvenTreeSettingsManager().setValue("stockSublocation", en);
|
||||||
|
stockSublocation = await InvenTreeSettingsManager().getValue("stockSublocation", false);
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
@ -66,6 +87,39 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
|||||||
body: Container(
|
body: Container(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: [
|
children: [
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
I18N.of(context).parts,
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.shapes),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text("Include Subcategories"),
|
||||||
|
subtitle: Text("Display subcategory parts in list view"),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.sitemap),
|
||||||
|
trailing: Switch(
|
||||||
|
value: partSubcategory,
|
||||||
|
onChanged: setPartSubcategory,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Divider(height: 3),
|
||||||
|
ListTile(
|
||||||
|
title: Text(I18N.of(context).stock,
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.boxes),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text("Include Sublocations"),
|
||||||
|
subtitle: Text("Display sublocation items in list view"),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.sitemap),
|
||||||
|
trailing: Switch(
|
||||||
|
value: stockSublocation,
|
||||||
|
onChanged: setStockSublocation,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Divider(height: 3),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
I18N.of(context).sounds,
|
I18N.of(context).sounds,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
import 'package:InvenTree/api.dart';
|
import 'package:InvenTree/api.dart';
|
||||||
|
import 'package:InvenTree/app_settings.dart';
|
||||||
import 'package:InvenTree/inventree/part.dart';
|
import 'package:InvenTree/inventree/part.dart';
|
||||||
import 'package:InvenTree/preferences.dart';
|
import 'package:InvenTree/preferences.dart';
|
||||||
import 'package:InvenTree/widget/progress.dart';
|
import 'package:InvenTree/widget/progress.dart';
|
||||||
@ -418,6 +419,9 @@ class _PaginatedPartListState extends State<PaginatedPartList> {
|
|||||||
params["search"] = _searchTerm;
|
params["search"] = _searchTerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final bool cascade = await InvenTreeSettingsManager().getValue("partSubcategory", false);
|
||||||
|
params["cascade"] = "${cascade}";
|
||||||
|
|
||||||
final page = await InvenTreePart().listPaginated(_pageSize, pageKey, filters: params);
|
final page = await InvenTreePart().listPaginated(_pageSize, pageKey, filters: params);
|
||||||
final isLastPage = page.length < _pageSize;
|
final isLastPage = page.length < _pageSize;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:InvenTree/api.dart';
|
import 'package:InvenTree/api.dart';
|
||||||
|
import 'package:InvenTree/app_settings.dart';
|
||||||
import 'package:InvenTree/barcode.dart';
|
import 'package:InvenTree/barcode.dart';
|
||||||
import 'package:InvenTree/inventree/stock.dart';
|
import 'package:InvenTree/inventree/stock.dart';
|
||||||
import 'package:InvenTree/preferences.dart';
|
import 'package:InvenTree/preferences.dart';
|
||||||
@ -232,6 +233,14 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
|||||||
int stockItemCount = 0;
|
int stockItemCount = 0;
|
||||||
|
|
||||||
Widget getSelectedWidget(int index) {
|
Widget getSelectedWidget(int index) {
|
||||||
|
|
||||||
|
// Construct filters for paginated stock list
|
||||||
|
Map<String, String> filters = {};
|
||||||
|
|
||||||
|
if (location != null) {
|
||||||
|
filters["location"] = "${location.pk}";
|
||||||
|
}
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
return ListView(
|
return ListView(
|
||||||
@ -252,7 +261,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
|||||||
Divider(height: 3),
|
Divider(height: 3),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: PaginatedStockList(
|
child: PaginatedStockList(
|
||||||
{"location": "${location?.pk ?? -1}"},
|
filters,
|
||||||
onTotalChanged: (int total) {
|
onTotalChanged: (int total) {
|
||||||
setState(() {
|
setState(() {
|
||||||
stockItemCount = total;
|
stockItemCount = total;
|
||||||
@ -452,6 +461,10 @@ class _PaginatedStockListState extends State<PaginatedStockList> {
|
|||||||
params["search"] = "${_searchTerm}";
|
params["search"] = "${_searchTerm}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do we include stock items from sub-locations?
|
||||||
|
final bool cascade = await InvenTreeSettingsManager().getValue("stockSublocation", false);
|
||||||
|
params["cascade"] = "${cascade}";
|
||||||
|
|
||||||
final page = await InvenTreeStockItem().listPaginated(_pageSize, pageKey, filters: params);
|
final page = await InvenTreeStockItem().listPaginated(_pageSize, pageKey, filters: params);
|
||||||
final isLastPage = page.length < _pageSize;
|
final isLastPage = page.length < _pageSize;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user