Support cloning
This commit is contained in:
parent
fd591b691f
commit
d6262caeae
|
|
@ -99,7 +99,7 @@ class ClientViewVM {
|
||||||
store.dispatch(UpdateCurrentRoute(ClientScreen.route)),
|
store.dispatch(UpdateCurrentRoute(ClientScreen.route)),
|
||||||
onActionSelected: (BuildContext context, EntityAction action) {
|
onActionSelected: (BuildContext context, EntityAction action) {
|
||||||
final Completer<Null> completer = Completer<Null>();
|
final Completer<Null> completer = Completer<Null>();
|
||||||
var message = '';
|
String message;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case EntityAction.archive:
|
case EntityAction.archive:
|
||||||
store.dispatch(ArchiveClientRequest(completer, client.id));
|
store.dispatch(ArchiveClientRequest(completer, client.id));
|
||||||
|
|
@ -114,10 +114,10 @@ class ClientViewVM {
|
||||||
message = AppLocalization.of(context).successfullyRestoredClient;
|
message = AppLocalization.of(context).successfullyRestoredClient;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return completer.future.then((_) {
|
completer.future.then((_) {
|
||||||
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
|
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
|
||||||
Navigator.of(context).pop(message);
|
Navigator.of(context).pop(message);
|
||||||
} else {
|
} else if (message != null){
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
content: SnackBarRow(
|
content: SnackBarRow(
|
||||||
message: message,
|
message: message,
|
||||||
|
|
|
||||||
|
|
@ -273,6 +273,11 @@ class _CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
),
|
),
|
||||||
ActionMenuButton(
|
ActionMenuButton(
|
||||||
customActions: [
|
customActions: [
|
||||||
|
ActionMenuChoice(
|
||||||
|
label: localization.clone,
|
||||||
|
icon: Icons.control_point_duplicate,
|
||||||
|
action: EntityAction.clone,
|
||||||
|
),
|
||||||
!invoice.isPublic
|
!invoice.isPublic
|
||||||
? ActionMenuChoice(
|
? ActionMenuChoice(
|
||||||
action: EntityAction.markSent,
|
action: EntityAction.markSent,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class InvoiceViewScreen extends StatelessWidget {
|
class InvoiceViewScreen extends StatelessWidget {
|
||||||
static const String route = '/invoice/view';
|
static const String route = '/invoice/view';
|
||||||
|
|
||||||
const InvoiceViewScreen({Key key}) : super(key: key);
|
const InvoiceViewScreen({Key key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -69,7 +70,7 @@ class InvoiceViewVM {
|
||||||
store.dispatch(LoadInvoice(completer: completer, invoiceId: invoice.id));
|
store.dispatch(LoadInvoice(completer: completer, invoiceId: invoice.id));
|
||||||
return completer.future.then((_) {
|
return completer.future.then((_) {
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
content: SnackBarRow(
|
content: SnackBarRow(
|
||||||
message: AppLocalization.of(context).refreshComplete,
|
message: AppLocalization.of(context).refreshComplete,
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
|
|
@ -152,26 +153,27 @@ class InvoiceViewVM {
|
||||||
store.dispatch(RestoreInvoiceRequest(completer, invoice.id));
|
store.dispatch(RestoreInvoiceRequest(completer, invoice.id));
|
||||||
message = AppLocalization.of(context).successfullyRestoredInvoice;
|
message = AppLocalization.of(context).successfullyRestoredInvoice;
|
||||||
break;
|
break;
|
||||||
|
case EntityAction.clone:
|
||||||
|
store.dispatch(
|
||||||
|
EditInvoice(context: context, invoice: invoice.clone));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (message != null) {
|
completer.future.then((_) {
|
||||||
return completer.future.then((_) {
|
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
|
||||||
if ([EntityAction.archive, EntityAction.delete]
|
Navigator.of(context).pop(message);
|
||||||
.contains(action)) {
|
} else if (message != null) {
|
||||||
Navigator.of(context).pop(message);
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
} else {
|
content: SnackBarRow(
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
message: message,
|
||||||
content: SnackBarRow(
|
)));
|
||||||
message: message,
|
}
|
||||||
)));
|
}).catchError((Object error) {
|
||||||
}
|
showDialog<ErrorDialog>(
|
||||||
}).catchError((Object error) {
|
context: context,
|
||||||
showDialog<ErrorDialog>(
|
builder: (BuildContext context) {
|
||||||
context: context,
|
return ErrorDialog(error);
|
||||||
builder: (BuildContext context) {
|
});
|
||||||
return ErrorDialog(error);
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class ProductEditVM {
|
||||||
},
|
},
|
||||||
onActionSelected: (BuildContext context, EntityAction action) {
|
onActionSelected: (BuildContext context, EntityAction action) {
|
||||||
final Completer<Null> completer = Completer<Null>();
|
final Completer<Null> completer = Completer<Null>();
|
||||||
var message = '';
|
String message;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case EntityAction.archive:
|
case EntityAction.archive:
|
||||||
store.dispatch(ArchiveProductRequest(completer, product.id));
|
store.dispatch(ArchiveProductRequest(completer, product.id));
|
||||||
|
|
@ -110,10 +110,10 @@ class ProductEditVM {
|
||||||
store.dispatch(UpdateProduct(product.clone));
|
store.dispatch(UpdateProduct(product.clone));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return completer.future.then((_) {
|
completer.future.then((_) {
|
||||||
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
|
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
|
||||||
Navigator.of(context).pop(message);
|
Navigator.of(context).pop(message);
|
||||||
} else if (message.isNotEmpty) {
|
} else if (message != null) {
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
content: SnackBarRow(
|
content: SnackBarRow(
|
||||||
message: message,
|
message: message,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue