Fix table sorting

This commit is contained in:
Hillel Coren 2020-05-15 13:39:01 +03:00
parent 8034328dd5
commit 69b5010c2d
4 changed files with 16 additions and 3 deletions

View File

@ -325,6 +325,16 @@ abstract class ClientEntity extends Object
.toLowerCase()
.compareTo(clientB.displayName.toLowerCase());
break;
case ClientFields.contact:
response = clientA.primaryContact.fullName
.toLowerCase()
.compareTo(clientB.primaryContact.fullName.toLowerCase());
break;
case ClientFields.contactEmail:
response = clientA.primaryContact.email
.toLowerCase()
.compareTo(clientB.primaryContact.email.toLowerCase());
break;
case ClientFields.balance:
response = clientA.balance.compareTo(clientB.balance);
break;

View File

@ -174,6 +174,9 @@ abstract class ProductEntity extends Object
case ProductFields.cost:
response = productA.cost.compareTo(productB.cost);
break;
case ProductFields.quantity:
response = productA.quantity.compareTo(productB.quantity);
break;
case ProductFields.updatedAt:
response = productA.updatedAt.compareTo(productB.updatedAt);
break;

View File

@ -749,8 +749,8 @@ class AppDataTable extends StatelessWidget {
: null,
// IGNORE SORTING ON FIRST COLUMN
sorted: displayCheckboxColumn
? (dataColumnIndex + 1) == sortColumnIndex
: dataColumnIndex == sortColumnIndex,
? dataColumnIndex == sortColumnIndex
: (dataColumnIndex - 1) == sortColumnIndex,
ascending: sortAscending,
);
rowIndex = 1;

View File

@ -182,7 +182,7 @@ class _EntityListState extends State<EntityList> {
onRefreshPressed: () => widget.onRefreshed(context),
),
sortColumnIndex:
widget.tableColumns.indexOf(listUIState.sortField) + 1,
widget.tableColumns.indexOf(listUIState.sortField),
sortAscending: listUIState.sortAscending,
),
),