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,39 +85,54 @@ class CreditEditVM extends AbstractInvoiceEditVM {
|
|||
});
|
||||
return null;
|
||||
}
|
||||
final Completer<InvoiceEntity> completer = Completer<InvoiceEntity>();
|
||||
store.dispatch(
|
||||
SaveCreditRequest(completer: completer, credit: credit));
|
||||
return completer.future.then((savedCredit) {
|
||||
showToast(credit.isNew
|
||||
? localization.createdCredit
|
||||
: localization.updatedCredit);
|
||||
|
||||
if (state.prefState.isMobile) {
|
||||
store.dispatch(UpdateCurrentRoute(CreditViewScreen.route));
|
||||
if (credit.isNew) {
|
||||
navigator.pushReplacementNamed(CreditViewScreen.route);
|
||||
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) {
|
||||
showToast(credit.isNew
|
||||
? localization.createdCredit
|
||||
: localization.updatedCredit);
|
||||
|
||||
if (state.prefState.isMobile) {
|
||||
store.dispatch(UpdateCurrentRoute(CreditViewScreen.route));
|
||||
if (credit.isNew) {
|
||||
navigator.pushReplacementNamed(CreditViewScreen.route);
|
||||
} else {
|
||||
navigator.pop(savedCredit);
|
||||
}
|
||||
} else {
|
||||
navigator.pop(savedCredit);
|
||||
}
|
||||
} else {
|
||||
viewEntity(entity: savedCredit);
|
||||
viewEntity(entity: savedCredit);
|
||||
|
||||
if (state.prefState.isEditorFullScreen(EntityType.credit)) {
|
||||
editEntity(
|
||||
context: navigatorKey.currentContext, entity: savedCredit);
|
||||
if (state.prefState.isEditorFullScreen(EntityType.credit)) {
|
||||
editEntity(
|
||||
context: navigatorKey.currentContext,
|
||||
entity: savedCredit);
|
||||
}
|
||||
|
||||
if ([
|
||||
EntityAction.emailCredit,
|
||||
EntityAction.viewPdf,
|
||||
].contains(action)) {
|
||||
handleEntityAction(savedCredit, action);
|
||||
}
|
||||
}
|
||||
if (action != null) {
|
||||
handleEntityAction(savedCredit, action);
|
||||
}
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
showDialog<ErrorDialog>(
|
||||
context: navigatorKey.currentContext,
|
||||
builder: (BuildContext context) {
|
||||
return ErrorDialog(error);
|
||||
});
|
||||
});
|
||||
}).catchError((Object error) {
|
||||
showDialog<ErrorDialog>(
|
||||
context: navigatorKey.currentContext,
|
||||
builder: (BuildContext context) {
|
||||
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,46 +85,55 @@ class QuoteEditVM extends AbstractInvoiceEditVM {
|
|||
});
|
||||
return null;
|
||||
}
|
||||
final Completer<InvoiceEntity> completer = Completer<InvoiceEntity>();
|
||||
store.dispatch(SaveQuoteRequest(
|
||||
completer: completer,
|
||||
quote: quote,
|
||||
action: action,
|
||||
));
|
||||
return completer.future.then((savedQuote) {
|
||||
showToast(quote.isNew
|
||||
? localization.createdQuote
|
||||
: localization.updatedQuote);
|
||||
|
||||
if (state.prefState.isMobile) {
|
||||
store.dispatch(UpdateCurrentRoute(QuoteViewScreen.route));
|
||||
if (quote.isNew) {
|
||||
navigator.pushReplacementNamed(QuoteViewScreen.route);
|
||||
} else {
|
||||
navigator.pop(savedQuote);
|
||||
}
|
||||
} else {
|
||||
viewEntity(entity: savedQuote);
|
||||
|
||||
if (state.prefState.isEditorFullScreen(EntityType.invoice)) {
|
||||
editEntity(
|
||||
context: navigatorKey.currentContext, entity: savedQuote);
|
||||
}
|
||||
|
||||
if ([
|
||||
if (!hasQuoteChanges(quote, state.quoteState.map) &&
|
||||
[
|
||||
EntityAction.emailQuote,
|
||||
EntityAction.viewPdf,
|
||||
].contains(action)) {
|
||||
handleEntityAction(savedQuote, action);
|
||||
handleEntityAction(quote, action);
|
||||
} else {
|
||||
final Completer<InvoiceEntity> completer =
|
||||
Completer<InvoiceEntity>();
|
||||
store.dispatch(SaveQuoteRequest(
|
||||
completer: completer,
|
||||
quote: quote,
|
||||
action: action,
|
||||
));
|
||||
return completer.future.then((savedQuote) {
|
||||
showToast(quote.isNew
|
||||
? localization.createdQuote
|
||||
: localization.updatedQuote);
|
||||
|
||||
if (state.prefState.isMobile) {
|
||||
store.dispatch(UpdateCurrentRoute(QuoteViewScreen.route));
|
||||
if (quote.isNew) {
|
||||
navigator.pushReplacementNamed(QuoteViewScreen.route);
|
||||
} else {
|
||||
navigator.pop(savedQuote);
|
||||
}
|
||||
} else {
|
||||
viewEntity(entity: savedQuote);
|
||||
|
||||
if (state.prefState.isEditorFullScreen(EntityType.invoice)) {
|
||||
editEntity(
|
||||
context: navigatorKey.currentContext, entity: savedQuote);
|
||||
}
|
||||
|
||||
if ([
|
||||
EntityAction.emailQuote,
|
||||
EntityAction.viewPdf,
|
||||
].contains(action)) {
|
||||
handleEntityAction(savedQuote, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
showDialog<ErrorDialog>(
|
||||
context: navigatorKey.currentContext,
|
||||
builder: (BuildContext context) {
|
||||
return ErrorDialog(error);
|
||||
});
|
||||
});
|
||||
}).catchError((Object error) {
|
||||
showDialog<ErrorDialog>(
|
||||
context: navigatorKey.currentContext,
|
||||
builder: (BuildContext context) {
|
||||
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,44 +86,54 @@ class RecurringInvoiceEditVM extends AbstractInvoiceEditVM {
|
|||
});
|
||||
return null;
|
||||
}
|
||||
final Completer<InvoiceEntity> completer = Completer<InvoiceEntity>();
|
||||
store.dispatch(SaveRecurringInvoiceRequest(
|
||||
completer: completer, recurringInvoice: recurringInvoice));
|
||||
return completer.future.then((savedRecurringInvoice) {
|
||||
showToast(recurringInvoice.isNew
|
||||
? localization.createdRecurringInvoice
|
||||
: localization.updatedRecurringInvoice);
|
||||
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) {
|
||||
showToast(recurringInvoice.isNew
|
||||
? localization.createdRecurringInvoice
|
||||
: localization.updatedRecurringInvoice);
|
||||
|
||||
if (state.prefState.isMobile) {
|
||||
store.dispatch(
|
||||
UpdateCurrentRoute(RecurringInvoiceViewScreen.route));
|
||||
if (recurringInvoice.isNew) {
|
||||
navigator
|
||||
.pushReplacementNamed(RecurringInvoiceViewScreen.route);
|
||||
if (state.prefState.isMobile) {
|
||||
store.dispatch(
|
||||
UpdateCurrentRoute(RecurringInvoiceViewScreen.route));
|
||||
if (recurringInvoice.isNew) {
|
||||
navigator
|
||||
.pushReplacementNamed(RecurringInvoiceViewScreen.route);
|
||||
} else {
|
||||
navigator.pop(savedRecurringInvoice);
|
||||
}
|
||||
} else {
|
||||
navigator.pop(savedRecurringInvoice);
|
||||
}
|
||||
} else {
|
||||
viewEntity(entity: savedRecurringInvoice);
|
||||
viewEntity(entity: savedRecurringInvoice);
|
||||
|
||||
if (state.prefState.isEditorFullScreen(EntityType.invoice)) {
|
||||
editEntity(
|
||||
context: navigatorKey.currentContext,
|
||||
entity: savedRecurringInvoice);
|
||||
}
|
||||
if (state.prefState.isEditorFullScreen(EntityType.invoice)) {
|
||||
editEntity(
|
||||
context: navigatorKey.currentContext,
|
||||
entity: savedRecurringInvoice);
|
||||
}
|
||||
|
||||
if ([EntityAction.emailInvoice, EntityAction.viewPdf]
|
||||
.contains(action)) {
|
||||
handleEntityAction(savedRecurringInvoice, action);
|
||||
if ([EntityAction.emailInvoice, EntityAction.viewPdf]
|
||||
.contains(action)) {
|
||||
handleEntityAction(savedRecurringInvoice, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
showDialog<ErrorDialog>(
|
||||
context: navigatorKey.currentContext,
|
||||
builder: (BuildContext context) {
|
||||
return ErrorDialog(error);
|
||||
});
|
||||
});
|
||||
}).catchError((Object error) {
|
||||
showDialog<ErrorDialog>(
|
||||
context: navigatorKey.currentContext,
|
||||
builder: (BuildContext context) {
|
||||
return ErrorDialog(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
onItemsAdded: (items, clientId) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue