Skip to content

Commit

Permalink
Update behaviour of Back Button
Browse files Browse the repository at this point in the history
  • Loading branch information
itbeard committed Jun 26, 2022
1 parent bafecc6 commit 19b54a0
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 16 deletions.
14 changes: 13 additions & 1 deletion Pds/Pds.Web/Pages/BasePageComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,24 @@ protected override void OnInitialized()
base.OnInitialized();
}

protected void GoBack()
protected void GoBack(string defaultBackPath)
{
_pageState.RemoveCurrent(_navManager.Uri);
if (_pageState.CanGoBack())
{
_navManager.NavigateTo(_pageState.PreviousPage());
}
else
{
if (!string.IsNullOrEmpty(defaultBackPath))
{
_navManager.NavigateTo(defaultBackPath);
}
}
}

protected void GoBack()
{
GoBack(null);
}
}
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Bills/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ else
isCreateButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
NavigationManager.NavigateTo("/bills");
GoBack("/bills");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Bills/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ else
isSaveButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
NavigationManager.NavigateTo("/bills");
GoBack("/bills");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Brands/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ else
if (result.IsSuccessStatusCode)
{
await localStorage.ClearAsync();
NavigationManager.NavigateTo("/brands");
GoBack("/brands");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Brands/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ else
if (result.IsSuccessStatusCode)
{
await localStorage.ClearAsync();
NavigationManager.NavigateTo("/brands");
GoBack("/brands");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Clients/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ else
isCreateButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
NavigationManager.NavigateTo("/clients");
GoBack("/clients");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Clients/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ else
isCreateButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
NavigationManager.NavigateTo("/clients");
GoBack("/clients");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Content/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ else
isCreateButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
NavigationManager.NavigateTo("/content");
GoBack("/content");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Content/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ else
isEditButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
NavigationManager.NavigateTo("/content");
GoBack("/content");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Content/Pay.razor
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ else
{
isCreateButtonDisabled = true;
await ApiClient.Put<object, PayBillPayload>(TokenProvider, $"bills/{content.Bill.Id}/pay", paymentPayload);
NavigationManager.NavigateTo("/content");
GoBack("/content");
}
}

Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Costs/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ else
isCreateButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
NavigationManager.NavigateTo("/costs");
GoBack("/costs");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Costs/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ else
isSaveButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
NavigationManager.NavigateTo("/costs");
GoBack("/costs");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Gifts/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ else
isCreateButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
NavigationManager.NavigateTo("/gifts");
GoBack("/gifts");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Gifts/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ else
isSaveButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
NavigationManager.NavigateTo("/gifts");
GoBack("/gifts");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Persons/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ else
isCreateButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
NavigationManager.NavigateTo("/persons");
GoBack("/persons");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Pds/Pds.Web/Pages/Persons/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ else
isSaveButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
NavigationManager.NavigateTo("/persons");
GoBack("/persons");
}
else
{
Expand Down
1 change: 1 addition & 0 deletions Pds/Pds.Web/Pages/Settings/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ else
isCreateButtonDisabled = false;
if (result.IsSuccessStatusCode)
{
GoBack("/persons");
NavigationManager.NavigateTo("/settings", forceLoad: true);
}
else
Expand Down

0 comments on commit 19b54a0

Please sign in to comment.