Add run_template action
This commit is contained in:
parent
290224a4c9
commit
30b5295639
|
|
@ -353,7 +353,7 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
|
|
||||||
return StyledToast(
|
return StyledToast(
|
||||||
locale: locale,
|
locale: locale,
|
||||||
duration: Duration(seconds: 3),
|
duration: Duration(seconds: 4),
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
state.prefState.enableDarkMode ? Colors.white : Colors.black,
|
state.prefState.enableDarkMode ? Colors.white : Colors.black,
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
|
||||||
|
|
||||||
// Package imports:
|
// Package imports:
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||||
import 'package:invoiceninja_flutter/main_app.dart';
|
import 'package:invoiceninja_flutter/main_app.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/task/task_actions.dart';
|
import 'package:invoiceninja_flutter/redux/task/task_actions.dart';
|
||||||
|
|
@ -628,6 +629,7 @@ class RunTemplateDialog extends StatefulWidget {
|
||||||
class _RunTemplateDialogState extends State<RunTemplateDialog> {
|
class _RunTemplateDialogState extends State<RunTemplateDialog> {
|
||||||
String _designId = '';
|
String _designId = '';
|
||||||
bool _sendEmail = false;
|
bool _sendEmail = false;
|
||||||
|
bool _isLoading = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
@ -660,12 +662,22 @@ class _RunTemplateDialogState extends State<RunTemplateDialog> {
|
||||||
};
|
};
|
||||||
|
|
||||||
print('## DATA: $data');
|
print('## DATA: $data');
|
||||||
|
|
||||||
|
setState(() => _isLoading = true);
|
||||||
|
|
||||||
WebClient()
|
WebClient()
|
||||||
.post(url, credentials.token, data: jsonEncode(data))
|
.post(url, credentials.token, data: jsonEncode(data))
|
||||||
.then((response) {
|
.then((response) {
|
||||||
print('## RESPONSE: $response');
|
print('## RESPONSE: $response');
|
||||||
|
setState(() => _isLoading = false);
|
||||||
|
|
||||||
|
if (_sendEmail) {
|
||||||
|
Navigator.of(navigatorKey.currentContext!).pop();
|
||||||
|
showToast(localization.exportedData);
|
||||||
|
}
|
||||||
}).catchError((error) {
|
}).catchError((error) {
|
||||||
print('## ERROR: $error');
|
print('## ERROR: $error');
|
||||||
|
setState(() => _isLoading = false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Text(localization.start.toUpperCase()),
|
child: Text(localization.start.toUpperCase()),
|
||||||
|
|
@ -685,28 +697,34 @@ class _RunTemplateDialogState extends State<RunTemplateDialog> {
|
||||||
...widget.entities
|
...widget.entities
|
||||||
.map((entity) => Text(entity.listDisplayName))
|
.map((entity) => Text(entity.listDisplayName))
|
||||||
.toList(),
|
.toList(),
|
||||||
SizedBox(height: 8),
|
if (_isLoading) ...[
|
||||||
DesignPicker(
|
SizedBox(height: 30),
|
||||||
autofocus: true,
|
LinearProgressIndicator()
|
||||||
entityType: widget.entityType,
|
] else ...[
|
||||||
onSelected: (design) {
|
SizedBox(height: 8),
|
||||||
setState(() {
|
DesignPicker(
|
||||||
_designId = design?.id ?? '';
|
autofocus: true,
|
||||||
});
|
entityType: widget.entityType,
|
||||||
},
|
initialValue: _designId,
|
||||||
),
|
onSelected: (design) {
|
||||||
SizedBox(height: 16),
|
setState(() {
|
||||||
SwitchListTile(
|
_designId = design?.id ?? '';
|
||||||
value: _sendEmail,
|
});
|
||||||
title: Text(
|
},
|
||||||
localization.sendEmail,
|
|
||||||
),
|
),
|
||||||
onChanged: (value) {
|
SizedBox(height: 16),
|
||||||
setState(() {
|
SwitchListTile(
|
||||||
_sendEmail = value;
|
value: _sendEmail,
|
||||||
});
|
title: Text(
|
||||||
},
|
localization.sendEmail,
|
||||||
),
|
),
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
_sendEmail = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue