Skip to content

Commit

Permalink
Refactor search widget (#578)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
SchrodingersGat authored Dec 14, 2024
1 parent 524c546 commit 665de2b
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 92 deletions.
5 changes: 3 additions & 2 deletions assets/credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ Thanks to the following contributors, for their work building this app!
- [GoryMoon](https://github.com/GoryMoon)
- [simonkuehling](https://github.com/simonkuehling)
- [Bobbe](https://github.com/30350n)

- [awnz](https://github.com/awnz)
- [joaomnuno](https://github.com/joaomnuno)
--------

## Assets

The InvenTree App makes use of the following third party assets

- Icons are provided by [fontawesome](https://fontawesome.com)
- Icons are provided by [tabler.io](https://tabler.io/icons)
- Sound files have been sourced from [zapsplat](https://www.zapsplat.com)

--------
1 change: 1 addition & 0 deletions assets/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

- Add support for ManufacturerPart model
- Support barcode scanning for ManufacturerPart
- Fix bugs in global search view
- Fixes barcode scanning bug which prevents scanning of DataMatrix codes
- Display "destination" information in PurchaseOrder detail view
- Pre-fill "location" field when receiving items against PurchaseOrder
Expand Down
2 changes: 1 addition & 1 deletion lib/app_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Color get COLOR_ACTION {

// Return an "app bar" color based on the current theme
Color get COLOR_APP_BAR {
return Colors.blueGrey;
return Color.fromRGBO(55, 150, 175, 1);
}

const Color COLOR_WARNING = Color.fromRGBO(250, 150, 50, 1);
Expand Down
8 changes: 1 addition & 7 deletions lib/inventree/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
17 changes: 14 additions & 3 deletions lib/inventree/part.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "dart:io";
import "dart:math";

import "package:flutter/material.dart";

Expand Down Expand Up @@ -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);
Expand Down
10 changes: 4 additions & 6 deletions lib/widget/part/part_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -703,12 +703,10 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
@override
List<Widget> getTabs(BuildContext context) {
List<Widget> tabs = [
Center(
child: ListView(
children: ListTile.divideTiles(
context: context,
tiles: partTiles()
).toList()
SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: Column(
children: partTiles(),
)
),
PaginatedStockItemList({"part": part.pk.toString()})
Expand Down
Loading

0 comments on commit 665de2b

Please sign in to comment.