mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-31 13:25:40 +00:00 
			
		
		
		
	Show supplier results
This commit is contained in:
		| @@ -186,7 +186,7 @@ class InvenTreeModel { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Return the number of results that would meet a particular "query" |   // Return the number of results that would meet a particular "query" | ||||||
|   Future<int> count({Map<String, String> filters = const {}, String search = ""} ) async { |   Future<int> count({Map<String, String> filters = const {}, String searchQuery = ""} ) async { | ||||||
|  |  | ||||||
|     var params = defaultListFilters(); |     var params = defaultListFilters(); | ||||||
|  |  | ||||||
| @@ -194,8 +194,8 @@ class InvenTreeModel { | |||||||
|       params[key] = value; |       params[key] = value; | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     if (search.isNotEmpty) { |     if (searchQuery.isNotEmpty) { | ||||||
|       params["search"] = search; |       params["search"] = searchQuery; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Limit to 1 result, for quick DB access |     // Limit to 1 result, for quick DB access | ||||||
| @@ -382,6 +382,21 @@ class InvenTreeModel { | |||||||
|     params["limit"] = "${limit}"; |     params["limit"] = "${limit}"; | ||||||
|     params["offset"] = "${offset}"; |     params["offset"] = "${offset}"; | ||||||
|  |  | ||||||
|  |     /* Special case: "original_search": | ||||||
|  |      * - We may wish to provide an original "query" which is augmented by the user | ||||||
|  |      * - Thus, "search" and "original_search" may both be provided | ||||||
|  |      * - In such a case, we want to concatenate them together | ||||||
|  |      */ | ||||||
|  |     if (params.containsKey("original_search")) { | ||||||
|  |  | ||||||
|  |       String search = params["search"] ?? ""; | ||||||
|  |       String original = params["original_search"] ?? ""; | ||||||
|  |  | ||||||
|  |       params["search"] = "${search} ${original}"; | ||||||
|  |  | ||||||
|  |       params.remove("original_search"); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     var response = await api.get(URL, params: params); |     var response = await api.get(URL, params: params); | ||||||
|  |  | ||||||
|     if (!response.isValid()) { |     if (!response.isValid()) { | ||||||
|   | |||||||
| @@ -80,7 +80,7 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> { | |||||||
|  |  | ||||||
|     // Search parts |     // Search parts | ||||||
|     InvenTreePart().count( |     InvenTreePart().count( | ||||||
|       search: term |       searchQuery: term | ||||||
|     ).then((int n) { |     ).then((int n) { | ||||||
|       setState(() { |       setState(() { | ||||||
|         nPartResults = n; |         nPartResults = n; | ||||||
| @@ -89,7 +89,7 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> { | |||||||
|  |  | ||||||
|     // Search part categories |     // Search part categories | ||||||
|     InvenTreePartCategory().count( |     InvenTreePartCategory().count( | ||||||
|       search: term, |       searchQuery: term, | ||||||
|     ).then((int n) { |     ).then((int n) { | ||||||
|       setState(() { |       setState(() { | ||||||
|         nCategoryResults = n; |         nCategoryResults = n; | ||||||
| @@ -98,7 +98,7 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> { | |||||||
|  |  | ||||||
|     // Search stock items |     // Search stock items | ||||||
|     InvenTreeStockItem().count( |     InvenTreeStockItem().count( | ||||||
|       search: term |       searchQuery: term | ||||||
|     ).then((int n) { |     ).then((int n) { | ||||||
|       setState(() { |       setState(() { | ||||||
|         nStockResults = n; |         nStockResults = n; | ||||||
| @@ -107,7 +107,7 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> { | |||||||
|  |  | ||||||
|     // Search stock locations |     // Search stock locations | ||||||
|     InvenTreeStockLocation().count( |     InvenTreeStockLocation().count( | ||||||
|       search: term |       searchQuery: term | ||||||
|     ).then((int n) { |     ).then((int n) { | ||||||
|       setState(() { |       setState(() { | ||||||
|         nLocationResults = n; |         nLocationResults = n; | ||||||
| @@ -116,7 +116,7 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> { | |||||||
|  |  | ||||||
|     // Search suppliers |     // Search suppliers | ||||||
|     InvenTreeCompany().count( |     InvenTreeCompany().count( | ||||||
|       search: term, |       searchQuery: term, | ||||||
|       filters: { |       filters: { | ||||||
|         "is_supplier": "true", |         "is_supplier": "true", | ||||||
|       }, |       }, | ||||||
| @@ -128,7 +128,7 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> { | |||||||
|  |  | ||||||
|     // Search purchase orders |     // Search purchase orders | ||||||
|     InvenTreePurchaseOrder().count( |     InvenTreePurchaseOrder().count( | ||||||
|       search: term, |       searchQuery: term, | ||||||
|       filters: { |       filters: { | ||||||
|         "outstanding": "true" |         "outstanding": "true" | ||||||
|       } |       } | ||||||
| @@ -168,6 +168,8 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> { | |||||||
|       ) |       ) | ||||||
|     ); |     ); | ||||||
|  |  | ||||||
|  |     String query = searchController.text; | ||||||
|  |  | ||||||
|     List<Widget> results = []; |     List<Widget> results = []; | ||||||
|  |  | ||||||
|     // Part Results |     // Part Results | ||||||
| @@ -223,7 +225,21 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> { | |||||||
|         ListTile( |         ListTile( | ||||||
|           title: Text(L10().suppliers), |           title: Text(L10().suppliers), | ||||||
|           leading: FaIcon(FontAwesomeIcons.building), |           leading: FaIcon(FontAwesomeIcons.building), | ||||||
|           trailing: Text("${nSupplierResults}") |           trailing: Text("${nSupplierResults}"), | ||||||
|  |           onTap: () { | ||||||
|  |             Navigator.push( | ||||||
|  |               context, | ||||||
|  |               MaterialPageRoute( | ||||||
|  |                 builder: (context) => CompanyListWidget( | ||||||
|  |                   L10().suppliers, | ||||||
|  |                   { | ||||||
|  |                     "is_supplier": "true", | ||||||
|  |                     "original_search": query | ||||||
|  |                   } | ||||||
|  |                 ) | ||||||
|  |               ) | ||||||
|  |             ); | ||||||
|  |           }, | ||||||
|         ) |         ) | ||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user