Support for templates

This commit is contained in:
Hillel Coren 2023-11-22 15:26:12 +02:00
parent 81119d5f37
commit 894f1a81d9
1 changed files with 8 additions and 5 deletions

View File

@ -668,13 +668,15 @@ class _RunTemplateDialogState extends State<RunTemplateDialog> {
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
child: Text(localization.close.toUpperCase()), child: Text((_isLoading ? localization.cancel : localization.close)
.toUpperCase()),
), ),
if (_data != null) ...[ if (_data != null) ...[
TextButton( TextButton(
onPressed: () { onPressed: () {
setState(() { setState(() {
_data = null; _data = null;
_designId = '';
}); });
}, },
child: Text( child: Text(
@ -685,12 +687,12 @@ class _RunTemplateDialogState extends State<RunTemplateDialog> {
child: Text(localization.download.toUpperCase()), child: Text(localization.download.toUpperCase()),
onPressed: () { onPressed: () {
final design = state.designState.map[_designId]!; final design = state.designState.map[_designId]!;
saveDownloadedFile(_data!, design.name); saveDownloadedFile(_data!, '${design.name}.pdf');
}, },
), ),
] else ] else if (!_isLoading)
TextButton( TextButton(
onPressed: _designId.isEmpty || _isLoading onPressed: _designId.isEmpty
? null ? null
: () { : () {
final credentials = state.credentials; final credentials = state.credentials;
@ -750,7 +752,8 @@ class _RunTemplateDialogState extends State<RunTemplateDialog> {
Text( Text(
localization.lookup(widget.entities.length == 1 localization.lookup(widget.entities.length == 1
? widget.entityType.snakeCase ? widget.entityType.snakeCase
: widget.entityType.plural), : widget.entityType.plural +
' (${widget.entities.length})'),
style: Theme.of(context).textTheme.bodySmall, style: Theme.of(context).textTheme.bodySmall,
), ),
SizedBox(height: 8), SizedBox(height: 8),