Skip to content

Commit 665d849

Browse files
committed
fix bug with button GoBack
1 parent 19b54a0 commit 665d849

File tree

23 files changed

+28
-74
lines changed

23 files changed

+28
-74
lines changed

Pds/Pds.Web/Common/PageHistoryState.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public bool CanGoBack()
2525

2626
public void RemoveCurrent(string currentPage)
2727
{
28+
if (pages.Count == 0)
29+
{
30+
return;
31+
}
32+
2833
var lastPage = pages.Last();
2934
if (lastPage == currentPage)
3035
{

Pds/Pds.Web/Pages/BasePageComponent.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ protected void GoBack(string defaultBackPath)
3636
}
3737
else
3838
{
39-
if (!string.IsNullOrEmpty(defaultBackPath))
40-
{
41-
_navManager.NavigateTo(defaultBackPath);
42-
}
39+
_navManager.NavigateTo(!string.IsNullOrEmpty(defaultBackPath) ? defaultBackPath : "/");
4340
}
4441
}
4542

Pds/Pds.Web/Pages/Bills/Create.razor

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
@using Pds.Web.Common
66
@using static Pds.Web.Common.TitleExtension
77
@using Microsoft.AspNetCore.Components
8-
@using Pds.Api.Contracts
98
@using Pds.Api.Contracts.Controllers
109
@using Pds.Api.Contracts.Controllers.Bill
1110
@using Pds.Api.Contracts.Controllers.Bill.CreateBill
1211

13-
@inject NavigationManager NavigationManager
1412
@inject IApiClient ApiClient
1513
@inject IAccessTokenProvider TokenProvider
1614

@@ -26,7 +24,7 @@ else
2624
{
2725
<h4 class="card-header d-flex justify-content-between align-items-center">
2826
Фиксация дохода
29-
<button @onclick="GoBack" class="btn btn-primary"> Назад </button>
27+
<button @onclick='() => GoBack("/bills")' class="btn btn-primary"> Назад </button>
3028
</h4>
3129

3230
<EditForm EditContext="@editContext" OnSubmit="@HandleSubmitAsync">

Pds/Pds.Web/Pages/Bills/Edit.razor

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@page "/bills/{billId}/edit"
22
@inherits BasePageComponent
33
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
4-
@using Pds.Api.Contracts
54
@using Pds.Core.Enums
65
@using Pds.Web.Common
76
@using static Pds.Web.Common.TitleExtension
@@ -11,7 +10,6 @@
1110
@using Pds.Api.Contracts.Controllers.Bill.EditBill
1211
@using Pds.Api.Contracts.Controllers.Bill.GetBill
1312

14-
@inject NavigationManager NavigationManager
1513
@inject IApiClient ApiClient
1614
@inject IMapper Mapper
1715
@inject IAccessTokenProvider TokenProvider
@@ -28,7 +26,7 @@ else
2826
{
2927
<h4 class="card-header d-flex justify-content-between align-items-center">
3028
Редактирование дохода
31-
<button @onclick="GoBack" class="btn btn-primary"> Назад </button>
29+
<button @onclick='() => GoBack("/bills")' class="btn btn-primary"> Назад </button>
3230
</h4>
3331
@if (bill.Content?.Id != null && bill.Content.Title != null)
3432
{

Pds/Pds.Web/Pages/Brands/Create.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
@using Pds.Web.Common
66
@using static Pds.Web.Common.TitleExtension
77

8-
@inject NavigationManager NavigationManager
98
@inject IApiClient ApiClient
109
@inject IAccessTokenProvider TokenProvider
1110
@inject Blazored.LocalStorage.ILocalStorageService localStorage
@@ -22,7 +21,7 @@ else
2221
{
2322
<h4 class="card-header d-flex justify-content-between align-items-center">
2423
Добавление бренда
25-
<button @onclick="GoBack" class="btn btn-primary" >Назад</button>
24+
<button @onclick='() => GoBack("/brands")' class="btn btn-primary" >Назад</button>
2625
</h4>
2726

2827
<EditForm EditContext="@editContext" OnSubmit="@HandleSubmit">

Pds/Pds.Web/Pages/Brands/Edit.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
@using Pds.Api.Contracts.Controllers.Brand.EditBrand
88
@using Pds.Api.Contracts.Controllers.Brand.GetBrand
99

10-
@inject NavigationManager NavigationManager
1110
@inject IApiClient ApiClient
1211
@inject IMapper Mapper
1312
@inject IAccessTokenProvider TokenProvider
@@ -25,7 +24,7 @@ else
2524
{
2625
<h4 class="card-header d-flex justify-content-between align-items-center">
2726
Редактирование бренда
28-
<button @onclick="GoBack" class="btn btn-primary">Назад</button>
27+
<button @onclick='() => GoBack("/brands")' class="btn btn-primary">Назад</button>
2928
</h4>
3029

3130
<EditForm EditContext="@editContext" OnSubmit="@HandleSubmit">

Pds/Pds.Web/Pages/Clients/Create.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
@using Pds.Web.Common
66
@using static Pds.Web.Common.TitleExtension
77

8-
@inject NavigationManager NavigationManager
98
@inject IApiClient ApiClient
109
@inject IAccessTokenProvider TokenProvider
1110

@@ -21,7 +20,7 @@ else
2120
{
2221
<h4 class="card-header d-flex justify-content-between align-items-center">
2322
Добавление клиента
24-
<button @onclick="GoBack" class="btn btn-primary" >Назад</button>
23+
<button @onclick='() => GoBack("/clients")' class="btn btn-primary" >Назад</button>
2524
</h4>
2625

2726
<EditForm EditContext="@editContext" OnSubmit="@HandleSubmit">

Pds/Pds.Web/Pages/Clients/Edit.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
@using Pds.Api.Contracts.Controllers.Client.EditClient
88
@using Pds.Api.Contracts.Controllers.Client.GetClient
99

10-
@inject NavigationManager NavigationManager
1110
@inject IApiClient ApiClient
1211
@inject IMapper Mapper
1312
@inject IAccessTokenProvider TokenProvider
@@ -24,7 +23,7 @@ else
2423
{
2524
<h4 class="card-header d-flex justify-content-between align-items-center">
2625
Редактирование клиента
27-
<button @onclick="GoBack" class="btn btn-primary">Назад</button>
26+
<button @onclick='() => GoBack("/clients")' class="btn btn-primary">Назад</button>
2827
</h4>
2928

3029
<EditForm EditContext="@editContext" OnSubmit="@HandleSubmit">

Pds/Pds.Web/Pages/Clients/Info.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
@using Pds.Web.Pages.Clients.Components
99

1010
@inject IApiClient ApiClient
11-
@inject NavigationManager NavigationManager
1211
@inject IAccessTokenProvider TokenProvider
1312

1413
@if (client == null)
@@ -101,7 +100,7 @@ else
101100
{
102101
if (isRedirectNeeded)
103102
{
104-
NavigationManager.NavigateTo("/clients");
103+
GoBack("/clients");
105104
}
106105

107106
client = await GetClient();

Pds/Pds.Web/Pages/Content/Create.razor

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
@page "/content/add"
22
@inherits BasePageComponent
33
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
4-
@using Pds.Api.Contracts
54
@using Pds.Api.Contracts.Controllers
65
@using Pds.Api.Contracts.Controllers.Content
76
@using Pds.Api.Contracts.Controllers.Content.CreateContent
87
@using Pds.Core.Enums
98
@using Pds.Web.Common
109
@using static Pds.Web.Common.TitleExtension
1110

12-
@inject NavigationManager NavigationManager
1311
@inject IApiClient ApiClient
1412
@inject IAccessTokenProvider TokenProvider
1513

1614
<Title>@WithSuffix("Добавление контента")</Title>
1715

1816
<h4 class="card-header d-flex justify-content-between align-items-center">
1917
Добавление контента
20-
<button @onclick="GoBack" class="btn btn-primary" >Назад</button>
18+
<button @onclick='() => GoBack("/content")' class="btn btn-primary" >Назад</button>
2119
</h4>
2220
@if (brands == null || clients == null || persons == null)
2321
{

0 commit comments

Comments
 (0)