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

View File

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

View File

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

View File

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

View File

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

View File

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