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:
@ -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();
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user