Documents

This commit is contained in:
Hillel Coren 2023-08-13 16:58:52 +03:00
parent 1f9154adec
commit 73ce305ac6
4 changed files with 52 additions and 41 deletions

View File

@ -51,7 +51,7 @@ class _ClientViewState extends State<ClientView>
final state = widget.viewModel.state;
_controller = TabController(
vsync: this,
length: 6,
length: state.company.isModuleEnabled(EntityType.document) ? 6 : 5,
initialIndex: widget.isFilter ? 0 : state.clientUIState.tabIndex);
_controller.addListener(_onTabChanged);
}
@ -85,6 +85,7 @@ class _ClientViewState extends State<ClientView>
Widget build(BuildContext context) {
final localization = AppLocalization.of(context);
final viewModel = widget.viewModel;
final company = viewModel.state.company;
final client = viewModel.client;
final documents = client.documents;
@ -122,11 +123,12 @@ class _ClientViewState extends State<ClientView>
Tab(
text: localization.details,
),
Tab(
text: documents.isEmpty
? localization.documents
: '${localization.documents} (${documents.length})',
),
if (company.isModuleEnabled(EntityType.document))
Tab(
text: documents.isEmpty
? localization.documents
: '${localization.documents} (${documents.length})',
),
Tab(
text: localization.ledger,
),

View File

@ -429,7 +429,7 @@ class _ClientViewFullwidthState extends State<ClientViewFullwidth>
bottom: kMobileDialogPadding,
left: kMobileDialogPadding / 2),
child: DefaultTabController(
length: 5,
length: company.isModuleEnabled(EntityType.document) ? 5 : 4,
child: SizedBox(
height: minHeight,
child: Column(
@ -446,11 +446,12 @@ class _ClientViewFullwidthState extends State<ClientViewFullwidth>
text:
'${localization.paymentMethods} (${tokenMap.keys.length})',
),
Tab(
text: documents.isEmpty
? localization.documents
: '${localization.documents} (${documents.length})',
),
if (company.isModuleEnabled(EntityType.document))
Tab(
text: documents.isEmpty
? localization.documents
: '${localization.documents} (${documents.length})',
),
Tab(
text: localization.ledger,
),
@ -498,13 +499,15 @@ class _ClientViewFullwidthState extends State<ClientViewFullwidth>
tokenMap: tokenMap,
),
),
RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context),
child: ClientViewDocuments(
viewModel: viewModel,
key: ValueKey(viewModel.client.id),
if (company.isModuleEnabled(EntityType.document))
RefreshIndicator(
onRefresh: () =>
viewModel.onRefreshed(context),
child: ClientViewDocuments(
viewModel: viewModel,
key: ValueKey(viewModel.client.id),
),
),
),
RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context),
child: ClientViewLedger(

View File

@ -49,7 +49,7 @@ class _VendorViewState extends State<VendorView>
final state = widget.viewModel.state;
_controller = TabController(
vsync: this,
length: 4,
length: state.company.isModuleEnabled(EntityType.document) ? 4 : 3,
initialIndex: widget.isFilter ? 0 : state.vendorUIState.tabIndex);
_controller.addListener(_onTabChanged);
}
@ -83,6 +83,7 @@ class _VendorViewState extends State<VendorView>
Widget build(BuildContext context) {
final localization = AppLocalization.of(context);
final viewModel = widget.viewModel;
final company = viewModel.state.company;
final vendor = viewModel.vendor;
final documents = vendor.documents;
@ -120,11 +121,12 @@ class _VendorViewState extends State<VendorView>
Tab(
text: localization.details,
),
Tab(
text: documents.isEmpty
? localization.documents
: '${localization.documents} (${documents.length})',
),
if (company.isModuleEnabled(EntityType.document))
Tab(
text: documents.isEmpty
? localization.documents
: '${localization.documents} (${documents.length})',
),
Tab(
text: localization.activity,
),
@ -148,12 +150,13 @@ class _VendorViewState extends State<VendorView>
onRefresh: () => viewModel.onRefreshed(context),
child: VendorViewDetails(vendor: viewModel.vendor),
),
RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context),
child: VendorViewDocuments(
viewModel: viewModel,
if (company.isModuleEnabled(EntityType.document))
RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context),
child: VendorViewDocuments(
viewModel: viewModel,
),
),
),
RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context),
child: VendorViewActivity(

View File

@ -335,7 +335,7 @@ class _VendorViewFullwidthState extends State<VendorViewFullwidth>
bottom: kMobileDialogPadding,
left: kMobileDialogPadding / 2),
child: DefaultTabController(
length: 3,
length: company.isModuleEnabled(EntityType.document) ? 3 : 2,
child: SizedBox(
height: minHeight,
child: Column(
@ -347,11 +347,12 @@ class _VendorViewFullwidthState extends State<VendorViewFullwidth>
Tab(
child: Text(localization.standing),
),
Tab(
text: documents.isEmpty
? localization.documents
: '${localization.documents} (${documents.length})',
),
if (company.isModuleEnabled(EntityType.document))
Tab(
text: documents.isEmpty
? localization.documents
: '${localization.documents} (${documents.length})',
),
Tab(
child: Text(localization.activity),
),
@ -383,13 +384,15 @@ class _VendorViewFullwidthState extends State<VendorViewFullwidth>
)
],
),
RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context),
child: VendorViewDocuments(
viewModel: viewModel,
key: ValueKey(viewModel.vendor.id),
if (company.isModuleEnabled(EntityType.document))
RefreshIndicator(
onRefresh: () =>
viewModel.onRefreshed(context),
child: VendorViewDocuments(
viewModel: viewModel,
key: ValueKey(viewModel.vendor.id),
),
),
),
RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context),
child: VendorViewActivity(