Skip to content

Commit

Permalink
fix bug with button GoBack
Browse files Browse the repository at this point in the history
  • Loading branch information
itbeard committed Jun 26, 2022
1 parent 19b54a0 commit 665d849
Show file tree
Hide file tree
Showing 23 changed files with 28 additions and 74 deletions.
5 changes: 5 additions & 0 deletions Pds/Pds.Web/Common/PageHistoryState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public bool CanGoBack()

public void RemoveCurrent(string currentPage)
{
if (pages.Count == 0)
{
return;
}

var lastPage = pages.Last();
if (lastPage == currentPage)
{
Expand Down
5 changes: 1 addition & 4 deletions Pds/Pds.Web/Pages/BasePageComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ protected void GoBack(string defaultBackPath)
}
else
{
if (!string.IsNullOrEmpty(defaultBackPath))
{
_navManager.NavigateTo(defaultBackPath);
}
_navManager.NavigateTo(!string.IsNullOrEmpty(defaultBackPath) ? defaultBackPath : "/");
}
}

Expand Down
4 changes: 1 addition & 3 deletions Pds/Pds.Web/Pages/Bills/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
@using Pds.Web.Common
@using static Pds.Web.Common.TitleExtension
@using Microsoft.AspNetCore.Components
@using Pds.Api.Contracts
@using Pds.Api.Contracts.Controllers
@using Pds.Api.Contracts.Controllers.Bill
@using Pds.Api.Contracts.Controllers.Bill.CreateBill

@inject NavigationManager NavigationManager
@inject IApiClient ApiClient
@inject IAccessTokenProvider TokenProvider

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

<EditForm EditContext="@editContext" OnSubmit="@HandleSubmitAsync">
Expand Down
4 changes: 1 addition & 3 deletions Pds/Pds.Web/Pages/Bills/Edit.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@page "/bills/{billId}/edit"
@inherits BasePageComponent
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@using Pds.Api.Contracts
@using Pds.Core.Enums
@using Pds.Web.Common
@using static Pds.Web.Common.TitleExtension
Expand All @@ -11,7 +10,6 @@
@using Pds.Api.Contracts.Controllers.Bill.EditBill
@using Pds.Api.Contracts.Controllers.Bill.GetBill

@inject NavigationManager NavigationManager
@inject IApiClient ApiClient
@inject IMapper Mapper
@inject IAccessTokenProvider TokenProvider
Expand All @@ -28,7 +26,7 @@ else
{
<h4 class="card-header d-flex justify-content-between align-items-center">
Редактирование дохода
<button @onclick="GoBack" class="btn btn-primary"> Назад </button>
<button @onclick='() => GoBack("/bills")' class="btn btn-primary"> Назад </button>
</h4>
@if (bill.Content?.Id != null && bill.Content.Title != null)
{
Expand Down
3 changes: 1 addition & 2 deletions Pds/Pds.Web/Pages/Brands/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@using Pds.Web.Common
@using static Pds.Web.Common.TitleExtension

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

<EditForm EditContext="@editContext" OnSubmit="@HandleSubmit">
Expand Down
3 changes: 1 addition & 2 deletions Pds/Pds.Web/Pages/Brands/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@using Pds.Api.Contracts.Controllers.Brand.EditBrand
@using Pds.Api.Contracts.Controllers.Brand.GetBrand

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

<EditForm EditContext="@editContext" OnSubmit="@HandleSubmit">
Expand Down
3 changes: 1 addition & 2 deletions Pds/Pds.Web/Pages/Clients/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@using Pds.Web.Common
@using static Pds.Web.Common.TitleExtension

@inject NavigationManager NavigationManager
@inject IApiClient ApiClient
@inject IAccessTokenProvider TokenProvider

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

<EditForm EditContext="@editContext" OnSubmit="@HandleSubmit">
Expand Down
3 changes: 1 addition & 2 deletions Pds/Pds.Web/Pages/Clients/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@using Pds.Api.Contracts.Controllers.Client.EditClient
@using Pds.Api.Contracts.Controllers.Client.GetClient

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

<EditForm EditContext="@editContext" OnSubmit="@HandleSubmit">
Expand Down
3 changes: 1 addition & 2 deletions Pds/Pds.Web/Pages/Clients/Info.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
@using Pds.Web.Pages.Clients.Components

@inject IApiClient ApiClient
@inject NavigationManager NavigationManager
@inject IAccessTokenProvider TokenProvider

@if (client == null)
Expand Down Expand Up @@ -101,7 +100,7 @@ else
{
if (isRedirectNeeded)
{
NavigationManager.NavigateTo("/clients");
GoBack("/clients");
}

client = await GetClient();
Expand Down
4 changes: 1 addition & 3 deletions Pds/Pds.Web/Pages/Content/Create.razor
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
@page "/content/add"
@inherits BasePageComponent
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@using Pds.Api.Contracts
@using Pds.Api.Contracts.Controllers
@using Pds.Api.Contracts.Controllers.Content
@using Pds.Api.Contracts.Controllers.Content.CreateContent
@using Pds.Core.Enums
@using Pds.Web.Common
@using static Pds.Web.Common.TitleExtension

@inject NavigationManager NavigationManager
@inject IApiClient ApiClient
@inject IAccessTokenProvider TokenProvider

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

<h4 class="card-header d-flex justify-content-between align-items-center">
Добавление контента
<button @onclick="GoBack" class="btn btn-primary" >Назад</button>
<button @onclick='() => GoBack("/content")' class="btn btn-primary" >Назад</button>
</h4>
@if (brands == null || clients == null || persons == null)
{
Expand Down
3 changes: 1 addition & 2 deletions Pds/Pds.Web/Pages/Content/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
@using Pds.Api.Contracts.Controllers.Content.EditContent
@using Pds.Api.Contracts.Controllers.Content.GetContent

@inject NavigationManager NavigationManager
@inject IApiClient ApiClient
@inject IMapper Mapper
@inject IAccessTokenProvider TokenProvider
Expand All @@ -19,7 +18,7 @@

<h4 class="card-header d-flex justify-content-between align-items-center">
Редактирование контента
<button @onclick="GoBack" class="btn btn-primary">Назад</button>
<button @onclick='() => GoBack("/content")' class="btn btn-primary">Назад</button>
</h4>
@if (content == null || clients == null || persons == null)
{
Expand Down
5 changes: 2 additions & 3 deletions Pds/Pds.Web/Pages/Content/Info.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
@using Pds.Web.Pages.Content.Components

@inject IApiClient ApiClient
@inject NavigationManager NavigationManager
@inject IAccessTokenProvider TokenProvider

@if (content == null)
Expand All @@ -23,7 +22,7 @@ else

<h4 class="card-header d-flex justify-content-between align-items-center">
Контент "@content.Title"
<button @onclick="GoBack" class="btn btn-primary" >Назад</button>
<button @onclick='() => GoBack("/content")' class="btn btn-primary" >Назад</button>
</h4>
<div class="page-container @ContentHelper.GetContentBgColorClass(content.Status, content.Bill)">
<div class="info-item">
Expand Down Expand Up @@ -237,7 +236,7 @@ else
{
if (isRedirectNeeded)
{
NavigationManager.NavigateTo("/content");
GoBack("/content");
}

content = await GetContent();
Expand Down
1 change: 0 additions & 1 deletion Pds/Pds.Web/Pages/Content/Pay.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@using Pds.Web.Common
@using static Pds.Web.Common.TitleExtension

@inject NavigationManager NavigationManager
@inject IApiClient ApiClient
@inject IAccessTokenProvider TokenProvider

Expand Down
4 changes: 1 addition & 3 deletions Pds/Pds.Web/Pages/Costs/Create.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
@page "/costs/add"
@inherits BasePageComponent
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@using Pds.Api.Contracts
@using Pds.Api.Contracts.Controllers
@using Pds.Api.Contracts.Controllers.Cost
@using Pds.Api.Contracts.Controllers.Cost.CreateCost
@using Pds.Core.Enums
@using Pds.Web.Common
@using static Pds.Web.Common.TitleExtension

@inject NavigationManager NavigationManager
@inject IApiClient ApiClient
@inject IAccessTokenProvider TokenProvider

Expand All @@ -25,7 +23,7 @@ else
{
<h4 class="card-header d-flex justify-content-between align-items-center">
Фиксация расхода
<button @onclick="GoBack" class="btn btn-primary"> Назад </button>
<button @onclick='() => GoBack("/costs")' class="btn btn-primary"> Назад </button>
</h4>

<EditForm EditContext="@editContext" OnSubmit="@HandleSubmitAsync">
Expand Down
4 changes: 1 addition & 3 deletions Pds/Pds.Web/Pages/Costs/Edit.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@page "/costs/{costId}/edit"
@inherits BasePageComponent
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@using Pds.Api.Contracts
@using Pds.Core.Enums
@using Pds.Web.Common
@using static Pds.Web.Common.TitleExtension
Expand All @@ -11,7 +10,6 @@
@using Pds.Api.Contracts.Controllers.Cost.EditCost
@using Pds.Api.Contracts.Controllers.Cost.GetCost

@inject NavigationManager NavigationManager
@inject IApiClient ApiClient
@inject IMapper Mapper
@inject IAccessTokenProvider TokenProvider
Expand All @@ -28,7 +26,7 @@ else
{
<h4 class="card-header d-flex justify-content-between align-items-center">
Редактирование расхода
<button @onclick="GoBack" class="btn btn-primary"> Назад </button>
<button @onclick='() => GoBack("/costs")' class="btn btn-primary"> Назад </button>
</h4>

<EditForm EditContext="@editContext" OnSubmit="@HandleSubmitAsync">
Expand Down
6 changes: 1 addition & 5 deletions Pds/Pds.Web/Pages/Gifts/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
@using Pds.Web.Common
@using static Pds.Web.Common.TitleExtension
@using Microsoft.AspNetCore.Components
@using Pds.Api.Contracts
@using System.Security.Cryptography
@using Pds.Api.Contracts.Controllers
@using Pds.Api.Contracts.Controllers.Gift
@using Pds.Api.Contracts.Controllers.Gift.CreateGift

@inject NavigationManager NavigationManager
@inject IApiClient ApiClient
@inject IAccessTokenProvider TokenProvider
@inject IJSRuntime JsRuntime

<Title>@WithSuffix("Добавление подарка")</Title>

Expand All @@ -28,7 +24,7 @@ else
{
<h4 class="card-header d-flex justify-content-between align-items-center">
Добавление подарка
<button @onclick="GoBack" class="btn btn-primary"> Назад </button>
<button @onclick='() => GoBack("/gifts")' class="btn btn-primary"> Назад </button>
</h4>

<EditForm EditContext="@editContext" OnSubmit="@HandleSubmitAsync">
Expand Down
4 changes: 1 addition & 3 deletions Pds/Pds.Web/Pages/Gifts/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
@using Pds.Web.Common
@using static Pds.Web.Common.TitleExtension
@using AutoMapper
@using Pds.Api.Contracts
@using Pds.Api.Contracts.Controllers
@using Pds.Api.Contracts.Controllers.Gift
@using Pds.Api.Contracts.Controllers.Gift.EditGift
@using Pds.Api.Contracts.Controllers.Gift.GetGift

@inject NavigationManager NavigationManager
@inject IApiClient ApiClient
@inject IMapper Mapper
@inject IAccessTokenProvider TokenProvider
Expand All @@ -28,7 +26,7 @@ else
{
<h4 class="card-header d-flex justify-content-between align-items-center">
Редактирование подарка
<button @onclick="GoBack" class="btn btn-primary"> Назад </button>
<button @onclick='() => GoBack("/gifts")' class="btn btn-primary"> Назад </button>
</h4>
@if (gift.Content?.Id != null && gift.Content.Title != null)
{
Expand Down
5 changes: 2 additions & 3 deletions Pds/Pds.Web/Pages/Gifts/Info.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@using Pds.Web.Pages.Gifts.Components

@inject IApiClient ApiClient
@inject NavigationManager NavigationManager
@inject IAccessTokenProvider TokenProvider

@if (gift == null)
Expand All @@ -24,7 +23,7 @@ else

<h4 class="card-header d-flex justify-content-between align-items-center">
<span>Подарок "@gift.Title" <span class="gift-type"> @EnumsTranslator.GiftTypeToRu(gift.Type) </span></span>
<button @onclick="GoBack" class="btn btn-primary">Назад</button>
<button @onclick='() => GoBack("/gifts")' class="btn btn-primary">Назад</button>
</h4>

<div class="page-container @GiftHelper.GetGiftBgColorClass(gift.Status)">
Expand Down Expand Up @@ -92,7 +91,7 @@ else
{
if (isRedirectNeeded)
{
NavigationManager.NavigateTo("/gifts");
GoBack("/gifts");
}

gift = await GetGiftAsync();
Expand Down
20 changes: 0 additions & 20 deletions Pds/Pds.Web/Pages/Map.razor

This file was deleted.

3 changes: 1 addition & 2 deletions Pds/Pds.Web/Pages/Persons/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
@using Pds.Api.Contracts.Controllers.Person.CreatePerson
@using Pds.Core.Constants

@inject NavigationManager NavigationManager
@inject IApiClient ApiClient
@inject IAccessTokenProvider TokenProvider

Expand All @@ -24,7 +23,7 @@ else
{
<h4 class="card-header d-flex justify-content-between align-items-center">
Добавление персоны
<button @onclick="GoBack" class="btn btn-primary"> Назад </button>
<button @onclick='() => GoBack("/persons")' class="btn btn-primary"> Назад </button>
</h4>

<EditForm EditContext="@editContext" OnSubmit="@HandleSubmitAsync">
Expand Down
Loading

0 comments on commit 665d849

Please sign in to comment.