Add designs templates

This commit is contained in:
Hillel Coren 2023-11-09 13:07:20 +02:00
parent 2be0ed2089
commit b83b2e4361
2 changed files with 41 additions and 22 deletions

View File

@ -98,3 +98,16 @@ String? getDesignIdForVendorByEntity(
return settings.defaultInvoiceDesignId;
}
}
bool hasDesignTemplatesForEntityType(
BuiltMap<String, DesignEntity> designMap, EntityType entityType) {
var hasMatch = false;
designMap.forEach((designId, design) {
if (design.supportsEntityType(entityType)) {
hasMatch = true;
}
});
return hasMatch;
}

View File

@ -11,6 +11,7 @@ import 'package:flutter_redux/flutter_redux.dart';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import 'package:invoiceninja_flutter/main_app.dart';
import 'package:invoiceninja_flutter/redux/design/design_selectors.dart';
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
import 'package:invoiceninja_flutter/ui/app/forms/design_picker.dart';
import 'package:invoiceninja_flutter/utils/files.dart';
@ -88,6 +89,7 @@ class _InvoicePdfViewState extends State<InvoicePdfView> {
invoice,
_isDeliveryNote,
_activityId,
_designId,
).then((response) async {
setState(() {
_response = response;
@ -176,8 +178,10 @@ class _InvoicePdfViewState extends State<InvoicePdfView> {
),
);
final designSelector =
_activityId != null || (kIsWeb && state.prefState.enableNativeBrowser)
final designSelector = _activityId != null ||
(kIsWeb && state.prefState.enableNativeBrowser) ||
!hasDesignTemplatesForEntityType(
state.designState.map, invoice.entityType!)
? SizedBox()
: Padding(
padding: const EdgeInsets.only(left: 17),
@ -195,6 +199,7 @@ class _InvoicePdfViewState extends State<InvoicePdfView> {
},
label: localization.design,
showBlank: true,
entityType: invoice.entityType,
),
),
),
@ -310,6 +315,7 @@ Future<Response?> _loadPDF(
InvoiceEntity invoice,
bool isDeliveryNote,
String? activityId,
String? designId,
) async {
http.Response? response;