Support cloning
This commit is contained in:
parent
f10f3d30fe
commit
5d54c5e9b7
|
|
@ -65,6 +65,10 @@ abstract class ProductEntity extends Object
|
|||
}
|
||||
ProductEntity._();
|
||||
|
||||
ProductEntity get clone => rebuild((b) => b
|
||||
..id = --ProductEntity.counter
|
||||
);
|
||||
|
||||
@override
|
||||
EntityType get entityType {
|
||||
return EntityType.product;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/custom_field.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/invoice/tax_rate_dropdown.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
|
|
@ -127,6 +128,13 @@ class _ProductEditState extends State<ProductEdit> {
|
|||
: ActionMenuButton(
|
||||
entity: viewModel.product,
|
||||
onSelected: viewModel.onActionSelected,
|
||||
customActions: [
|
||||
ActionMenuChoice(
|
||||
label: localization.clone,
|
||||
icon: Icons.control_point_duplicate,
|
||||
action: EntityAction.clone,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -106,11 +106,14 @@ class ProductEditVM {
|
|||
store.dispatch(RestoreProductRequest(completer, product.id));
|
||||
message = AppLocalization.of(context).successfullyRestoredProduct;
|
||||
break;
|
||||
case EntityAction.clone:
|
||||
store.dispatch(UpdateProduct(product.clone));
|
||||
break;
|
||||
}
|
||||
return completer.future.then((_) {
|
||||
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
|
||||
Navigator.of(context).pop(message);
|
||||
} else {
|
||||
} else if (message.isNotEmpty) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
message: message,
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@ class AppLocalization {
|
|||
'blank_contact': 'Blank Contact',
|
||||
'activity': 'Activity',
|
||||
'no_records_found': 'No records found',
|
||||
'clone': 'Clone',
|
||||
|
||||
'payment': 'Payment',
|
||||
'payments': 'Payments',
|
||||
|
|
@ -409,6 +410,7 @@ class AppLocalization {
|
|||
String get blankContact => _localizedValues[locale.languageCode]['blank_contact'];
|
||||
String get activity => _localizedValues[locale.languageCode]['activity'];
|
||||
String get noRecordsFound => _localizedValues[locale.languageCode]['no_records_found'];
|
||||
String get clone => _localizedValues[locale.languageCode]['clone'];
|
||||
|
||||
String get payment => _localizedValues[locale.languageCode]['payment'];
|
||||
String get payments => _localizedValues[locale.languageCode]['payments'];
|
||||
|
|
|
|||
Loading…
Reference in New Issue