From a2c1b6126c87127a1f0119b73d9fb201bf84331f Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 9 Apr 2021 17:37:53 +0300 Subject: [PATCH] Show custom header names --- lib/data/models/company_model.dart | 28 ++++++++------- lib/ui/app/tables/entity_datatable.dart | 48 ------------------------- lib/ui/app/tables/entity_list.dart | 37 +++++++++++-------- 3 files changed, 38 insertions(+), 75 deletions(-) diff --git a/lib/data/models/company_model.dart b/lib/data/models/company_model.dart index 6c328a2b3..098ca1a0c 100644 --- a/lib/data/models/company_model.dart +++ b/lib/data/models/company_model.dart @@ -465,19 +465,21 @@ abstract class CompanyEntity extends Object } // TODO make sure to clear everything - CompanyEntity get coreCompany => rebuild((b) => b - ..clients.clear() - ..products.clear() - ..invoices.clear() - ..payments.clear() - ..quotes.clear() - ..credits.clear() - ..tasks.clear() - ..projects.clear() - ..vendors.clear() - ..expenses.clear() - //..designs.clear() - //..companyGateways.clear() + CompanyEntity get coreCompany => rebuild( + (b) => b + ..clients.clear() + ..products.clear() + ..invoices.clear() + ..payments.clear() + ..quotes.clear() + ..credits.clear() + ..tasks.clear() + ..projects.clear() + ..vendors.clear() + ..expenses.clear() + ..webhooks.clear() + ..designs.clear() + ..companyGateways.clear(), ); bool isModuleEnabled(EntityType entityType) { diff --git a/lib/ui/app/tables/entity_datatable.dart b/lib/ui/app/tables/entity_datatable.dart index 533dca777..744ee094c 100644 --- a/lib/ui/app/tables/entity_datatable.dart +++ b/lib/ui/app/tables/entity_datatable.dart @@ -10,7 +10,6 @@ import 'package:invoiceninja_flutter/ui/app/presenters/entity_presenter.dart'; import 'package:invoiceninja_flutter/ui/app/tables/app_data_table.dart'; import 'package:invoiceninja_flutter/ui/app/tables/app_data_table_source.dart'; import 'package:invoiceninja_flutter/utils/colors.dart'; -import 'package:invoiceninja_flutter/utils/localization.dart'; import 'package:invoiceninja_flutter/utils/platforms.dart'; class EntityDataTableSource extends AppDataTableSource { @@ -117,50 +116,3 @@ class EntityDataTableSource extends AppDataTableSource { ); } } - -class DatatableHeader extends StatelessWidget { - const DatatableHeader({ - @required this.entityType, - @required this.onClearPressed, - @required this.onRefreshPressed, - }); - - final EntityType entityType; - final Function onClearPressed; - final Function onRefreshPressed; - - @override - Widget build(BuildContext context) { - final localization = AppLocalization.of(context); - /* - final state = StoreProvider.of(context).state; - final listUIState = state.getListState(entityType); - Widget message = SizedBox(); - if (onClearPressed != null && listUIState.filterEntityId != null) { - final entity = state.getEntityMap( - listUIState.filterEntityType)[listUIState.filterEntityId]; - message = FilterListTile( - onPressed: (context) => viewEntityById( - context: context, - entityId: listUIState.filterEntityId, - entityType: listUIState.filterEntityType, - ), - onClearPressed: onClearPressed, - entityType: listUIState.filterEntityType, - entity: entity, - ); - } - */ - - return Row( - children: [ - TextButton( - child: Text(localization.refresh), - onPressed: onRefreshPressed, - ), - SizedBox(width: 20), - Expanded(child: SizedBox()), - ], - ); - } -} diff --git a/lib/ui/app/tables/entity_list.dart b/lib/ui/app/tables/entity_list.dart index 792face14..a609a42e6 100644 --- a/lib/ui/app/tables/entity_list.dart +++ b/lib/ui/app/tables/entity_list.dart @@ -247,21 +247,30 @@ class _EntityListState extends State { }, columns: [ if (!isInMultiselect) DataColumn(label: SizedBox()), - ...widget.tableColumns.map((field) => DataColumn( - label: Container( - constraints: BoxConstraints( - minWidth: kTableColumnWidthMin, - maxWidth: kTableColumnWidthMax, + ...widget.tableColumns.map((field) { + String label = + AppLocalization.of(context).lookup(field); + if (field.startsWith('custom')) { + final key = field.replaceFirst( + 'custom', entityType.snakeCase); + label = state.company.getCustomFieldLabel(key); + } + return DataColumn( + label: Container( + constraints: BoxConstraints( + minWidth: kTableColumnWidthMin, + maxWidth: kTableColumnWidthMax, + ), + child: Text( + label, + overflow: TextOverflow.ellipsis, + ), ), - child: Text( - AppLocalization.of(context).lookup(field), - overflow: TextOverflow.ellipsis, - ), - ), - numeric: EntityPresenter.isFieldNumeric(field), - onSort: (int columnIndex, bool ascending) { - widget.onSortColumn(field); - })), + numeric: EntityPresenter.isFieldNumeric(field), + onSort: (int columnIndex, bool ascending) { + widget.onSortColumn(field); + }); + }), ], source: dataTableSource, sortColumnIndex: