2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-17 12:45:26 +00:00

Refactor search widget (#578)

* Refactor search widget

* Cleanup

* Fix for unallocated stock count

* Fix race condition

- Only upate results which match the current search term
- Prevents issues with multiple "competing" queries

* Fix for stock quantity

* Fix icon credits

* Tweak app bar color

* Cleanup visual stylinh
This commit is contained in:
Oliver
2024-12-14 17:29:35 +11:00
committed by GitHub
parent 524c5469f1
commit 665de2bd5a
7 changed files with 168 additions and 105 deletions

View File

@ -301,13 +301,7 @@ class InvenTreeModel {
/*
* Attempt to extract a custom icon for this model.
* If icon data is provided, attempt to convert to a FontAwesome icon
*
* Icon data *should* be presented something like "fas fa-boxes" / "fab fa-github" (etc):
*
* - First part specifies the *style*
* - Second part specifies the icon
*
* If icon data is provided, attempt to convert to a TablerIcon icon
*/
IconData? get customIcon {
String icon = (jsondata["icon"] ?? "").toString().trim();

View File

@ -1,4 +1,5 @@
import "dart:io";
import "dart:math";
import "package:flutter/material.dart";
@ -311,19 +312,29 @@ class InvenTreePart extends InvenTreeModel {
String get onOrderString => simpleNumberString(onOrder);
double get inStock => getDouble("in_stock");
double get inStock {
if (jsondata.containsKey("total_in_stock")) {
return getDouble("total_in_stock");
} else {
return getDouble("in_stock");
}
}
String get inStockString => simpleNumberString(inStock);
// Get the 'available stock' for this Part
double get unallocatedStock {
double unallocated = 0;
// Note that the 'available_stock' was not added until API v35
if (jsondata.containsKey("unallocated_stock")) {
return double.tryParse(jsondata["unallocated_stock"].toString()) ?? 0;
unallocated = double.tryParse(jsondata["unallocated_stock"].toString()) ?? 0;
} else {
return inStock;
unallocated = inStock;
}
return max(0, unallocated);
}
String get unallocatedStockString => simpleNumberString(unallocatedStock);