Add designs templates
This commit is contained in:
parent
2be0ed2089
commit
b83b2e4361
|
|
@ -98,3 +98,16 @@ String? getDesignIdForVendorByEntity(
|
||||||
return settings.defaultInvoiceDesignId;
|
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' as http;
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
import 'package:invoiceninja_flutter/main_app.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/dialogs/error_dialog.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/forms/design_picker.dart';
|
import 'package:invoiceninja_flutter/ui/app/forms/design_picker.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/files.dart';
|
import 'package:invoiceninja_flutter/utils/files.dart';
|
||||||
|
|
@ -88,6 +89,7 @@ class _InvoicePdfViewState extends State<InvoicePdfView> {
|
||||||
invoice,
|
invoice,
|
||||||
_isDeliveryNote,
|
_isDeliveryNote,
|
||||||
_activityId,
|
_activityId,
|
||||||
|
_designId,
|
||||||
).then((response) async {
|
).then((response) async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_response = response;
|
_response = response;
|
||||||
|
|
@ -176,29 +178,32 @@ class _InvoicePdfViewState extends State<InvoicePdfView> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final designSelector =
|
final designSelector = _activityId != null ||
|
||||||
_activityId != null || (kIsWeb && state.prefState.enableNativeBrowser)
|
(kIsWeb && state.prefState.enableNativeBrowser) ||
|
||||||
? SizedBox()
|
!hasDesignTemplatesForEntityType(
|
||||||
: Padding(
|
state.designState.map, invoice.entityType!)
|
||||||
padding: const EdgeInsets.only(left: 17),
|
? SizedBox()
|
||||||
child: SizedBox(
|
: Padding(
|
||||||
width: 200,
|
padding: const EdgeInsets.only(left: 17),
|
||||||
child: IgnorePointer(
|
child: SizedBox(
|
||||||
ignoring: _isLoading,
|
width: 200,
|
||||||
child: DesignPicker(
|
child: IgnorePointer(
|
||||||
initialValue: _designId,
|
ignoring: _isLoading,
|
||||||
onSelected: (design) {
|
child: DesignPicker(
|
||||||
setState(() {
|
initialValue: _designId,
|
||||||
_designId = design?.id;
|
onSelected: (design) {
|
||||||
loadPdf();
|
setState(() {
|
||||||
});
|
_designId = design?.id;
|
||||||
},
|
loadPdf();
|
||||||
label: localization.design,
|
});
|
||||||
showBlank: true,
|
},
|
||||||
),
|
label: localization.design,
|
||||||
),
|
showBlank: true,
|
||||||
|
entityType: invoice.entityType,
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
final deliveryNote = Container(
|
final deliveryNote = Container(
|
||||||
width: 200,
|
width: 200,
|
||||||
|
|
@ -310,6 +315,7 @@ Future<Response?> _loadPDF(
|
||||||
InvoiceEntity invoice,
|
InvoiceEntity invoice,
|
||||||
bool isDeliveryNote,
|
bool isDeliveryNote,
|
||||||
String? activityId,
|
String? activityId,
|
||||||
|
String? designId,
|
||||||
) async {
|
) async {
|
||||||
http.Response? response;
|
http.Response? response;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue