feat: Add isPrivate field to AdminProduct and update filtering logic in admin panels
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -38,13 +38,17 @@ List<AdminProduct> filterSelectableAdminProducts({
|
||||
required AdminProduct? selectedProduct,
|
||||
}) {
|
||||
final ownerFiltered = ownerUserId == null
|
||||
? products.where((p) => p.ownerId == null).toList()
|
||||
: products.where((p) => p.ownerId == null || p.ownerId == ownerUserId).toList();
|
||||
? products.where((p) => p.isPrivate != true).toList()
|
||||
: products
|
||||
.where(
|
||||
(p) => p.isPrivate != true || p.ownerId == ownerUserId,
|
||||
)
|
||||
.toList();
|
||||
|
||||
final scopeFiltered = switch (scopeFilter) {
|
||||
ProductScopeFilter.all => ownerFiltered,
|
||||
ProductScopeFilter.globalOnly => ownerFiltered.where((p) => p.ownerId == null).toList(),
|
||||
ProductScopeFilter.privateOnly => ownerFiltered.where((p) => p.ownerId != null).toList(),
|
||||
ProductScopeFilter.globalOnly => ownerFiltered.where((p) => p.isPrivate != true).toList(),
|
||||
ProductScopeFilter.privateOnly => ownerFiltered.where((p) => p.isPrivate == true).toList(),
|
||||
};
|
||||
|
||||
final source = categoryId == null
|
||||
@@ -64,7 +68,7 @@ List<ProductOption> toProductOptions(List<AdminProduct> products) {
|
||||
.map(
|
||||
(p) => (
|
||||
id: p.id,
|
||||
name: p.ownerId == null ? p.displayName : '${p.displayName} (privat)',
|
||||
name: p.isPrivate == true ? '${p.displayName} (privat)' : p.displayName,
|
||||
categoryId: p.categoryId,
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user