Only save if changed when using action on edit invoice page
This commit is contained in:
parent
fc303dcc58
commit
d69bf5c883
|
|
@ -6,6 +6,7 @@ import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
|||
import 'package:invoiceninja_flutter/main_app.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/credit/credit_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/credit/credit_selectors.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/credit/edit/credit_edit.dart';
|
||||
|
|
@ -84,7 +85,16 @@ class CreditEditVM extends AbstractInvoiceEditVM {
|
|||
});
|
||||
return null;
|
||||
}
|
||||
final Completer<InvoiceEntity> completer = Completer<InvoiceEntity>();
|
||||
|
||||
if (!hasCreditChanges(credit, state.creditState.map) &&
|
||||
[
|
||||
EntityAction.emailCredit,
|
||||
EntityAction.viewPdf,
|
||||
].contains(action)) {
|
||||
handleEntityAction(credit, action);
|
||||
} else {
|
||||
final Completer<InvoiceEntity> completer =
|
||||
Completer<InvoiceEntity>();
|
||||
store.dispatch(
|
||||
SaveCreditRequest(completer: completer, credit: credit));
|
||||
return completer.future.then((savedCredit) {
|
||||
|
|
@ -104,9 +114,14 @@ class CreditEditVM extends AbstractInvoiceEditVM {
|
|||
|
||||
if (state.prefState.isEditorFullScreen(EntityType.credit)) {
|
||||
editEntity(
|
||||
context: navigatorKey.currentContext, entity: savedCredit);
|
||||
context: navigatorKey.currentContext,
|
||||
entity: savedCredit);
|
||||
}
|
||||
if (action != null) {
|
||||
|
||||
if ([
|
||||
EntityAction.emailCredit,
|
||||
EntityAction.viewPdf,
|
||||
].contains(action)) {
|
||||
handleEntityAction(savedCredit, action);
|
||||
}
|
||||
}
|
||||
|
|
@ -117,6 +132,7 @@ class CreditEditVM extends AbstractInvoiceEditVM {
|
|||
return ErrorDialog(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
onItemsAdded: (items, clientId) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:flutter_redux/flutter_redux.dart';
|
|||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/quote/quote_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/quote/quote_selectors.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit_vm.dart';
|
||||
|
|
@ -84,7 +85,15 @@ class QuoteEditVM extends AbstractInvoiceEditVM {
|
|||
});
|
||||
return null;
|
||||
}
|
||||
final Completer<InvoiceEntity> completer = Completer<InvoiceEntity>();
|
||||
if (!hasQuoteChanges(quote, state.quoteState.map) &&
|
||||
[
|
||||
EntityAction.emailQuote,
|
||||
EntityAction.viewPdf,
|
||||
].contains(action)) {
|
||||
handleEntityAction(quote, action);
|
||||
} else {
|
||||
final Completer<InvoiceEntity> completer =
|
||||
Completer<InvoiceEntity>();
|
||||
store.dispatch(SaveQuoteRequest(
|
||||
completer: completer,
|
||||
quote: quote,
|
||||
|
|
@ -124,6 +133,7 @@ class QuoteEditVM extends AbstractInvoiceEditVM {
|
|||
return ErrorDialog(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
onItemsAdded: (items, clientId) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:flutter_redux/flutter_redux.dart';
|
|||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/recurring_invoice/recurring_invoice_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/recurring_invoice/recurring_invoice_selectors.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit_vm.dart';
|
||||
|
|
@ -85,7 +86,16 @@ class RecurringInvoiceEditVM extends AbstractInvoiceEditVM {
|
|||
});
|
||||
return null;
|
||||
}
|
||||
final Completer<InvoiceEntity> completer = Completer<InvoiceEntity>();
|
||||
if (!hasRecurringInvoiceChanges(
|
||||
recurringInvoice, state.recurringInvoiceState.map) &&
|
||||
[
|
||||
EntityAction.emailInvoice,
|
||||
EntityAction.viewPdf,
|
||||
].contains(action)) {
|
||||
handleEntityAction(recurringInvoice, action);
|
||||
} else {
|
||||
final Completer<InvoiceEntity> completer =
|
||||
Completer<InvoiceEntity>();
|
||||
store.dispatch(SaveRecurringInvoiceRequest(
|
||||
completer: completer, recurringInvoice: recurringInvoice));
|
||||
return completer.future.then((savedRecurringInvoice) {
|
||||
|
|
@ -123,6 +133,7 @@ class RecurringInvoiceEditVM extends AbstractInvoiceEditVM {
|
|||
return ErrorDialog(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
onItemsAdded: (items, clientId) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue