Support cloning

This commit is contained in:
unknown 2018-08-06 22:49:05 +03:00
parent fd591b691f
commit d6262caeae
4 changed files with 33 additions and 26 deletions

View File

@ -99,7 +99,7 @@ class ClientViewVM {
store.dispatch(UpdateCurrentRoute(ClientScreen.route)),
onActionSelected: (BuildContext context, EntityAction action) {
final Completer<Null> completer = Completer<Null>();
var message = '';
String message;
switch (action) {
case EntityAction.archive:
store.dispatch(ArchiveClientRequest(completer, client.id));
@ -114,10 +114,10 @@ class ClientViewVM {
message = AppLocalization.of(context).successfullyRestoredClient;
break;
}
return completer.future.then((_) {
completer.future.then((_) {
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
Navigator.of(context).pop(message);
} else {
} else if (message != null){
Scaffold.of(context).showSnackBar(SnackBar(
content: SnackBarRow(
message: message,

View File

@ -273,6 +273,11 @@ class _CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
),
ActionMenuButton(
customActions: [
ActionMenuChoice(
label: localization.clone,
icon: Icons.control_point_duplicate,
action: EntityAction.clone,
),
!invoice.isPublic
? ActionMenuChoice(
action: EntityAction.markSent,

View File

@ -17,6 +17,7 @@ import 'package:url_launcher/url_launcher.dart';
class InvoiceViewScreen extends StatelessWidget {
static const String route = '/invoice/view';
const InvoiceViewScreen({Key key}) : super(key: key);
@override
@ -69,7 +70,7 @@ class InvoiceViewVM {
store.dispatch(LoadInvoice(completer: completer, invoiceId: invoice.id));
return completer.future.then((_) {
Scaffold.of(context).showSnackBar(SnackBar(
content: SnackBarRow(
content: SnackBarRow(
message: AppLocalization.of(context).refreshComplete,
)));
});
@ -152,26 +153,27 @@ class InvoiceViewVM {
store.dispatch(RestoreInvoiceRequest(completer, invoice.id));
message = AppLocalization.of(context).successfullyRestoredInvoice;
break;
case EntityAction.clone:
store.dispatch(
EditInvoice(context: context, invoice: invoice.clone));
break;
}
if (message != null) {
return completer.future.then((_) {
if ([EntityAction.archive, EntityAction.delete]
.contains(action)) {
Navigator.of(context).pop(message);
} else {
Scaffold.of(context).showSnackBar(SnackBar(
content: SnackBarRow(
message: message,
)));
}
}).catchError((Object error) {
showDialog<ErrorDialog>(
context: context,
builder: (BuildContext context) {
return ErrorDialog(error);
});
});
}
completer.future.then((_) {
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
Navigator.of(context).pop(message);
} else if (message != null) {
Scaffold.of(context).showSnackBar(SnackBar(
content: SnackBarRow(
message: message,
)));
}
}).catchError((Object error) {
showDialog<ErrorDialog>(
context: context,
builder: (BuildContext context) {
return ErrorDialog(error);
});
});
});
}
}

View File

@ -92,7 +92,7 @@ class ProductEditVM {
},
onActionSelected: (BuildContext context, EntityAction action) {
final Completer<Null> completer = Completer<Null>();
var message = '';
String message;
switch (action) {
case EntityAction.archive:
store.dispatch(ArchiveProductRequest(completer, product.id));
@ -110,10 +110,10 @@ class ProductEditVM {
store.dispatch(UpdateProduct(product.clone));
break;
}
return completer.future.then((_) {
completer.future.then((_) {
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
Navigator.of(context).pop(message);
} else if (message.isNotEmpty) {
} else if (message != null) {
Scaffold.of(context).showSnackBar(SnackBar(
content: SnackBarRow(
message: message,