Add designs templates
This commit is contained in:
parent
2be0ed2089
commit
b83b2e4361
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue