Support cloning
This commit is contained in:
parent
fd591b691f
commit
d6262caeae
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue