This commit is contained in:
Hillel Coren 2018-12-18 17:25:42 +02:00
parent 7e0eb3626f
commit 392b3b81b4
6 changed files with 19 additions and 6 deletions

View File

@ -62,7 +62,7 @@ class ClientEditVM {
isSaving: state.isSaving,
onBackPressed: () {
if (state.uiState.currentRoute.contains(ClientScreen.route)) {
store.dispatch(UpdateCurrentRoute(ClientViewScreen.route));
store.dispatch(UpdateCurrentRoute(ClientScreen.route));
}
},
onChanged: (ClientEntity client) =>
@ -81,6 +81,10 @@ class ClientEditVM {
store.dispatch(
SaveClientRequest(completer: completer, client: client));
return completer.future.then((savedClient) {
if (state.uiState.currentRoute.contains(ClientScreen.route)) {
store.dispatch(UpdateCurrentRoute(
client.isNew ? ClientScreen.route : ClientViewScreen.route));
}
if (client.isNew) {
if ([
InvoiceEditScreen.route,

View File

@ -87,7 +87,8 @@ class InvoiceEditVM extends EntityEditVM {
origInvoice: store.state.invoiceState.map[invoice.id],
onBackPressed: () {
if (state.uiState.currentRoute.contains(InvoiceScreen.route)) {
store.dispatch(UpdateCurrentRoute(InvoiceViewScreen.route));
store.dispatch(UpdateCurrentRoute(
invoice.isNew ? InvoiceScreen.route : InvoiceViewScreen.route));
}
},
onSavePressed: (BuildContext context) {
@ -95,6 +96,7 @@ class InvoiceEditVM extends EntityEditVM {
store.dispatch(
SaveInvoiceRequest(completer: completer, invoice: invoice));
return completer.future.then((savedInvoice) {
store.dispatch(UpdateCurrentRoute(InvoiceViewScreen.route));
if (invoice.isNew) {
Navigator.of(context).pushReplacementNamed(InvoiceViewScreen.route);
} else {

View File

@ -84,12 +84,14 @@ class PaymentEditVM {
},
onBackPressed: () {
if (state.uiState.currentRoute.contains(PaymentScreen.route)) {
store.dispatch(UpdateCurrentRoute(PaymentViewScreen.route));
store.dispatch(UpdateCurrentRoute(
payment.isNew ? PaymentScreen.route : PaymentViewScreen.route));
}
},
onSavePressed: (BuildContext context) {
final Completer<Null> completer = errorCompleter(context)
..future.then((_) {
store.dispatch(UpdateCurrentRoute(PaymentViewScreen.route));
if (payment.isNew) {
Navigator.of(context)
.pushReplacementNamed(PaymentViewScreen.route);

View File

@ -69,7 +69,8 @@ class ProjectEditVM {
},
onBackPressed: () {
if (state.uiState.currentRoute.contains(ProjectScreen.route)) {
store.dispatch(UpdateCurrentRoute(ProjectViewScreen.route));
store.dispatch(UpdateCurrentRoute(
project.isNew ? ProjectScreen.route : ProjectViewScreen.route));
}
},
onAddClientPressed: (context, completer) {
@ -91,6 +92,9 @@ class ProjectEditVM {
store.dispatch(
SaveProjectRequest(completer: completer, project: project));
return completer.future.then((savedProject) {
if (state.uiState.currentRoute.contains(ProjectScreen.route)) {
store.dispatch(UpdateCurrentRoute(ProjectScreen.route));
}
if (project.isNew) {
if ([
TaskEditScreen.route,

View File

@ -66,7 +66,8 @@ class QuoteEditVM extends EntityEditVM {
origInvoice: store.state.quoteState.map[quote.id],
onBackPressed: () {
if (state.uiState.currentRoute.contains(QuoteScreen.route)) {
store.dispatch(UpdateCurrentRoute(QuoteViewScreen.route));
store.dispatch(UpdateCurrentRoute(
quote.isNew ? QuoteScreen.route : QuoteViewScreen.route));
}
},
onSavePressed: (BuildContext context) {

View File

@ -61,7 +61,7 @@ class StubEditVM {
},
onBackPressed: () {
if (state.uiState.currentRoute.contains(StubScreen.route)) {
store.dispatch(UpdateCurrentRoute(StubViewScreen.route));
store.dispatch(UpdateCurrentRoute(stub.isNew ? StubScreen.route : StubViewScreen.route));
}
},
onSavePressed: (BuildContext context) {