mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Company active filters (#484)
* Add support for "active" status for: - SupplierPart - Company * Add filtering options * Fix default value * Add inactive tiles * Update text and release notes
This commit is contained in:
parent
0e658febe2
commit
a889417fe0
@ -1,3 +1,10 @@
|
|||||||
|
### 0.14.3 - April 2024
|
||||||
|
---
|
||||||
|
|
||||||
|
- Support "active" field for Company model
|
||||||
|
- Support "active" field for SupplierPart model
|
||||||
|
- Updated translations
|
||||||
|
|
||||||
### 0.14.2 - February 2024
|
### 0.14.2 - February 2024
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -342,6 +342,9 @@ class InvenTreeAPI {
|
|||||||
// Does the server support "null" top-level filtering for PartCategory and StockLocation endpoints?
|
// Does the server support "null" top-level filtering for PartCategory and StockLocation endpoints?
|
||||||
bool get supportsNullTopLevelFiltering => isConnected() && apiVersion < 174;
|
bool get supportsNullTopLevelFiltering => isConnected() && apiVersion < 174;
|
||||||
|
|
||||||
|
// Does the server support "active" status on Company and SupplierPart API endpoints?
|
||||||
|
bool get supportsCompanyActiveStatus => isConnected() && apiVersion >= 189;
|
||||||
|
|
||||||
// Cached list of plugins (refreshed when we connect to the server)
|
// Cached list of plugins (refreshed when we connect to the server)
|
||||||
List<InvenTreePlugin> _plugins = [];
|
List<InvenTreePlugin> _plugins = [];
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class InvenTreeCompany extends InvenTreeModel {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, Map<String, dynamic>> formFields() {
|
Map<String, Map<String, dynamic>> formFields() {
|
||||||
return {
|
Map<String, Map<String, dynamic>> fields = {
|
||||||
"name": {},
|
"name": {},
|
||||||
"description": {},
|
"description": {},
|
||||||
"website": {},
|
"website": {},
|
||||||
@ -32,6 +32,12 @@ class InvenTreeCompany extends InvenTreeModel {
|
|||||||
"is_customer": {},
|
"is_customer": {},
|
||||||
"currency": {},
|
"currency": {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (InvenTreeAPI().supportsCompanyActiveStatus) {
|
||||||
|
fields["active"] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
String get image => (jsondata["image"] ?? jsondata["thumbnail"] ?? InvenTreeAPI.staticImage) as String;
|
String get image => (jsondata["image"] ?? jsondata["thumbnail"] ?? InvenTreeAPI.staticImage) as String;
|
||||||
@ -50,6 +56,8 @@ class InvenTreeCompany extends InvenTreeModel {
|
|||||||
|
|
||||||
bool get isCustomer => getBool("is_customer");
|
bool get isCustomer => getBool("is_customer");
|
||||||
|
|
||||||
|
bool get active => getBool("active", backup: true);
|
||||||
|
|
||||||
int get partSuppliedCount => getInt("part_supplied");
|
int get partSuppliedCount => getInt("part_supplied");
|
||||||
|
|
||||||
int get partManufacturedCount => getInt("parts_manufactured");
|
int get partManufacturedCount => getInt("parts_manufactured");
|
||||||
@ -137,6 +145,10 @@ class InvenTreeSupplierPart extends InvenTreeModel {
|
|||||||
fields["pack_quantity"] = {};
|
fields["pack_quantity"] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (InvenTreeAPI().supportsCompanyActiveStatus) {
|
||||||
|
fields["active"] = {};
|
||||||
|
}
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +187,8 @@ class InvenTreeSupplierPart extends InvenTreeModel {
|
|||||||
String get supplierImage => (jsondata["supplier_detail"]?["image"] ?? jsondata["supplier_detail"]["thumbnail"] ?? InvenTreeAPI.staticThumb) as String;
|
String get supplierImage => (jsondata["supplier_detail"]?["image"] ?? jsondata["supplier_detail"]["thumbnail"] ?? InvenTreeAPI.staticThumb) as String;
|
||||||
|
|
||||||
String get SKU => getString("SKU");
|
String get SKU => getString("SKU");
|
||||||
|
|
||||||
|
bool get active => getBool("active", backup: true);
|
||||||
|
|
||||||
int get partId => getInt("part");
|
int get partId => getInt("part");
|
||||||
|
|
||||||
|
@ -509,6 +509,9 @@
|
|||||||
"inactive": "Inactive",
|
"inactive": "Inactive",
|
||||||
"@inactive": {},
|
"@inactive": {},
|
||||||
|
|
||||||
|
"inactiveCompany": "This company is marked as inactive",
|
||||||
|
"@inactiveCompany": {},
|
||||||
|
|
||||||
"inactiveDetail": "This part is marked as inactive",
|
"inactiveDetail": "This part is marked as inactive",
|
||||||
"@inactiveDetail": {},
|
"@inactiveDetail": {},
|
||||||
|
|
||||||
|
@ -233,6 +233,29 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
if (!widget.company.active) {
|
||||||
|
tiles.add(
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
L10().inactive,
|
||||||
|
style: TextStyle(
|
||||||
|
color: COLOR_DANGER
|
||||||
|
)
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
L10().inactiveCompany,
|
||||||
|
style: TextStyle(
|
||||||
|
color: COLOR_DANGER
|
||||||
|
)
|
||||||
|
),
|
||||||
|
leading: FaIcon(
|
||||||
|
FontAwesomeIcons.circleExclamation,
|
||||||
|
color: COLOR_DANGER
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (widget.company.website.isNotEmpty) {
|
if (widget.company.website.isNotEmpty) {
|
||||||
tiles.add(ListTile(
|
tiles.add(ListTile(
|
||||||
title: Text("${widget.company.website}"),
|
title: Text("${widget.company.website}"),
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
|
|
||||||
import "package:inventree/api.dart";
|
import "package:inventree/api.dart";
|
||||||
|
import "package:inventree/l10.dart";
|
||||||
|
|
||||||
import "package:inventree/inventree/company.dart";
|
import "package:inventree/inventree/company.dart";
|
||||||
import "package:inventree/inventree/model.dart";
|
import "package:inventree/inventree/model.dart";
|
||||||
@ -58,6 +59,22 @@ class _CompanyListState extends PaginatedSearchState<PaginatedCompanyList> {
|
|||||||
|
|
||||||
_CompanyListState() : super();
|
_CompanyListState() : super();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, Map<String, dynamic>> get filterOptions {
|
||||||
|
|
||||||
|
Map<String, Map<String, dynamic>> filters = {};
|
||||||
|
|
||||||
|
if (InvenTreeAPI().supportsCompanyActiveStatus) {
|
||||||
|
filters["active"] = {
|
||||||
|
"label": L10().filterActive,
|
||||||
|
"help_text": L10().filterActiveDetail,
|
||||||
|
"tristate": true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return filters;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||||
|
|
||||||
|
@ -131,6 +131,29 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!widget.supplierPart.active) {
|
||||||
|
tiles.add(
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
L10().inactive,
|
||||||
|
style: TextStyle(
|
||||||
|
color: COLOR_DANGER
|
||||||
|
)
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
L10().inactiveDetail,
|
||||||
|
style: TextStyle(
|
||||||
|
color: COLOR_DANGER
|
||||||
|
)
|
||||||
|
),
|
||||||
|
leading: FaIcon(
|
||||||
|
FontAwesomeIcons.circleExclamation,
|
||||||
|
color: COLOR_DANGER
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Supplier details
|
// Supplier details
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
|
@ -62,7 +62,20 @@ class _PaginatedSupplierPartListState extends PaginatedSearchState<PaginatedSupp
|
|||||||
Map<String, String> get orderingOptions => {};
|
Map<String, String> get orderingOptions => {};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, Map<String, dynamic>> get filterOptions => {};
|
Map<String, Map<String, dynamic>> get filterOptions {
|
||||||
|
|
||||||
|
Map<String, Map<String, dynamic>> filters = {};
|
||||||
|
|
||||||
|
if (InvenTreeAPI().supportsCompanyActiveStatus) {
|
||||||
|
filters["active"] = {
|
||||||
|
"label": L10().filterActive,
|
||||||
|
"help_text": L10().filterActiveDetail,
|
||||||
|
"tristate": true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return filters;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user