From 665d84948691a560b751f31c8b79f5d59641f726 Mon Sep 17 00:00:00 2001 From: itbeard Date: Mon, 27 Jun 2022 01:30:41 +0200 Subject: [PATCH] fix bug with button GoBack --- Pds/Pds.Web/Common/PageHistoryState.cs | 5 +++++ Pds/Pds.Web/Pages/BasePageComponent.cs | 5 +---- Pds/Pds.Web/Pages/Bills/Create.razor | 4 +--- Pds/Pds.Web/Pages/Bills/Edit.razor | 4 +--- Pds/Pds.Web/Pages/Brands/Create.razor | 3 +-- Pds/Pds.Web/Pages/Brands/Edit.razor | 3 +-- Pds/Pds.Web/Pages/Clients/Create.razor | 3 +-- Pds/Pds.Web/Pages/Clients/Edit.razor | 3 +-- Pds/Pds.Web/Pages/Clients/Info.razor | 3 +-- Pds/Pds.Web/Pages/Content/Create.razor | 4 +--- Pds/Pds.Web/Pages/Content/Edit.razor | 3 +-- Pds/Pds.Web/Pages/Content/Info.razor | 5 ++--- Pds/Pds.Web/Pages/Content/Pay.razor | 1 - Pds/Pds.Web/Pages/Costs/Create.razor | 4 +--- Pds/Pds.Web/Pages/Costs/Edit.razor | 4 +--- Pds/Pds.Web/Pages/Gifts/Create.razor | 6 +----- Pds/Pds.Web/Pages/Gifts/Edit.razor | 4 +--- Pds/Pds.Web/Pages/Gifts/Info.razor | 5 ++--- Pds/Pds.Web/Pages/Map.razor | 20 -------------------- Pds/Pds.Web/Pages/Persons/Create.razor | 3 +-- Pds/Pds.Web/Pages/Persons/Edit.razor | 3 +-- Pds/Pds.Web/Pages/Persons/Info.razor | 5 ++--- Pds/Pds.Web/Pages/Settings/Edit.razor | 2 +- 23 files changed, 28 insertions(+), 74 deletions(-) delete mode 100644 Pds/Pds.Web/Pages/Map.razor diff --git a/Pds/Pds.Web/Common/PageHistoryState.cs b/Pds/Pds.Web/Common/PageHistoryState.cs index 87ae08bf..bb5ef3d6 100644 --- a/Pds/Pds.Web/Common/PageHistoryState.cs +++ b/Pds/Pds.Web/Common/PageHistoryState.cs @@ -25,6 +25,11 @@ public bool CanGoBack() public void RemoveCurrent(string currentPage) { + if (pages.Count == 0) + { + return; + } + var lastPage = pages.Last(); if (lastPage == currentPage) { diff --git a/Pds/Pds.Web/Pages/BasePageComponent.cs b/Pds/Pds.Web/Pages/BasePageComponent.cs index 34d1e73e..91a25ca6 100644 --- a/Pds/Pds.Web/Pages/BasePageComponent.cs +++ b/Pds/Pds.Web/Pages/BasePageComponent.cs @@ -36,10 +36,7 @@ protected void GoBack(string defaultBackPath) } else { - if (!string.IsNullOrEmpty(defaultBackPath)) - { - _navManager.NavigateTo(defaultBackPath); - } + _navManager.NavigateTo(!string.IsNullOrEmpty(defaultBackPath) ? defaultBackPath : "/"); } } diff --git a/Pds/Pds.Web/Pages/Bills/Create.razor b/Pds/Pds.Web/Pages/Bills/Create.razor index aacdbc09..91547ea1 100644 --- a/Pds/Pds.Web/Pages/Bills/Create.razor +++ b/Pds/Pds.Web/Pages/Bills/Create.razor @@ -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 @@ -26,7 +24,7 @@ else {

Фиксация дохода - +

diff --git a/Pds/Pds.Web/Pages/Bills/Edit.razor b/Pds/Pds.Web/Pages/Bills/Edit.razor index 3a0e9008..969d1771 100644 --- a/Pds/Pds.Web/Pages/Bills/Edit.razor +++ b/Pds/Pds.Web/Pages/Bills/Edit.razor @@ -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 @@ -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 @@ -28,7 +26,7 @@ else {

Редактирование дохода - +

@if (bill.Content?.Id != null && bill.Content.Title != null) { diff --git a/Pds/Pds.Web/Pages/Brands/Create.razor b/Pds/Pds.Web/Pages/Brands/Create.razor index 5ee060f1..987ce5ba 100644 --- a/Pds/Pds.Web/Pages/Brands/Create.razor +++ b/Pds/Pds.Web/Pages/Brands/Create.razor @@ -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 @@ -22,7 +21,7 @@ else {

Добавление бренда - +

diff --git a/Pds/Pds.Web/Pages/Brands/Edit.razor b/Pds/Pds.Web/Pages/Brands/Edit.razor index bf6f821c..d45afc50 100644 --- a/Pds/Pds.Web/Pages/Brands/Edit.razor +++ b/Pds/Pds.Web/Pages/Brands/Edit.razor @@ -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 @@ -25,7 +24,7 @@ else {

Редактирование бренда - +

diff --git a/Pds/Pds.Web/Pages/Clients/Create.razor b/Pds/Pds.Web/Pages/Clients/Create.razor index 518aa15b..a84a8b94 100644 --- a/Pds/Pds.Web/Pages/Clients/Create.razor +++ b/Pds/Pds.Web/Pages/Clients/Create.razor @@ -5,7 +5,6 @@ @using Pds.Web.Common @using static Pds.Web.Common.TitleExtension -@inject NavigationManager NavigationManager @inject IApiClient ApiClient @inject IAccessTokenProvider TokenProvider @@ -21,7 +20,7 @@ else {

Добавление клиента - +

diff --git a/Pds/Pds.Web/Pages/Clients/Edit.razor b/Pds/Pds.Web/Pages/Clients/Edit.razor index 1dac93e6..e5521100 100644 --- a/Pds/Pds.Web/Pages/Clients/Edit.razor +++ b/Pds/Pds.Web/Pages/Clients/Edit.razor @@ -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 @@ -24,7 +23,7 @@ else {

Редактирование клиента - +

diff --git a/Pds/Pds.Web/Pages/Clients/Info.razor b/Pds/Pds.Web/Pages/Clients/Info.razor index 40d8e5bc..e4c3baa8 100644 --- a/Pds/Pds.Web/Pages/Clients/Info.razor +++ b/Pds/Pds.Web/Pages/Clients/Info.razor @@ -8,7 +8,6 @@ @using Pds.Web.Pages.Clients.Components @inject IApiClient ApiClient -@inject NavigationManager NavigationManager @inject IAccessTokenProvider TokenProvider @if (client == null) @@ -101,7 +100,7 @@ else { if (isRedirectNeeded) { - NavigationManager.NavigateTo("/clients"); + GoBack("/clients"); } client = await GetClient(); diff --git a/Pds/Pds.Web/Pages/Content/Create.razor b/Pds/Pds.Web/Pages/Content/Create.razor index 7dbd5ddd..4b1e44ee 100644 --- a/Pds/Pds.Web/Pages/Content/Create.razor +++ b/Pds/Pds.Web/Pages/Content/Create.razor @@ -1,7 +1,6 @@ @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 @@ -9,7 +8,6 @@ @using Pds.Web.Common @using static Pds.Web.Common.TitleExtension -@inject NavigationManager NavigationManager @inject IApiClient ApiClient @inject IAccessTokenProvider TokenProvider @@ -17,7 +15,7 @@

Добавление контента - +

@if (brands == null || clients == null || persons == null) { diff --git a/Pds/Pds.Web/Pages/Content/Edit.razor b/Pds/Pds.Web/Pages/Content/Edit.razor index 2a8a0100..f3993125 100644 --- a/Pds/Pds.Web/Pages/Content/Edit.razor +++ b/Pds/Pds.Web/Pages/Content/Edit.razor @@ -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 @@ -19,7 +18,7 @@

Редактирование контента - +

@if (content == null || clients == null || persons == null) { diff --git a/Pds/Pds.Web/Pages/Content/Info.razor b/Pds/Pds.Web/Pages/Content/Info.razor index c4509692..65f5b8a7 100644 --- a/Pds/Pds.Web/Pages/Content/Info.razor +++ b/Pds/Pds.Web/Pages/Content/Info.razor @@ -8,7 +8,6 @@ @using Pds.Web.Pages.Content.Components @inject IApiClient ApiClient -@inject NavigationManager NavigationManager @inject IAccessTokenProvider TokenProvider @if (content == null) @@ -23,7 +22,7 @@ else

Контент "@content.Title" - +

@@ -237,7 +236,7 @@ else { if (isRedirectNeeded) { - NavigationManager.NavigateTo("/content"); + GoBack("/content"); } content = await GetContent(); diff --git a/Pds/Pds.Web/Pages/Content/Pay.razor b/Pds/Pds.Web/Pages/Content/Pay.razor index 15324ba3..6ed4fefe 100644 --- a/Pds/Pds.Web/Pages/Content/Pay.razor +++ b/Pds/Pds.Web/Pages/Content/Pay.razor @@ -7,7 +7,6 @@ @using Pds.Web.Common @using static Pds.Web.Common.TitleExtension -@inject NavigationManager NavigationManager @inject IApiClient ApiClient @inject IAccessTokenProvider TokenProvider diff --git a/Pds/Pds.Web/Pages/Costs/Create.razor b/Pds/Pds.Web/Pages/Costs/Create.razor index 7afd2dd9..debdb5cc 100644 --- a/Pds/Pds.Web/Pages/Costs/Create.razor +++ b/Pds/Pds.Web/Pages/Costs/Create.razor @@ -1,7 +1,6 @@ @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 @@ -9,7 +8,6 @@ @using Pds.Web.Common @using static Pds.Web.Common.TitleExtension -@inject NavigationManager NavigationManager @inject IApiClient ApiClient @inject IAccessTokenProvider TokenProvider @@ -25,7 +23,7 @@ else {

Фиксация расхода - +

diff --git a/Pds/Pds.Web/Pages/Costs/Edit.razor b/Pds/Pds.Web/Pages/Costs/Edit.razor index f86c9a64..5deaa9fa 100644 --- a/Pds/Pds.Web/Pages/Costs/Edit.razor +++ b/Pds/Pds.Web/Pages/Costs/Edit.razor @@ -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 @@ -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 @@ -28,7 +26,7 @@ else {

Редактирование расхода - +

diff --git a/Pds/Pds.Web/Pages/Gifts/Create.razor b/Pds/Pds.Web/Pages/Gifts/Create.razor index 0d6df3d5..d31a3eba 100644 --- a/Pds/Pds.Web/Pages/Gifts/Create.razor +++ b/Pds/Pds.Web/Pages/Gifts/Create.razor @@ -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 @WithSuffix("Добавление подарка") @@ -28,7 +24,7 @@ else {

Добавление подарка - +

diff --git a/Pds/Pds.Web/Pages/Gifts/Edit.razor b/Pds/Pds.Web/Pages/Gifts/Edit.razor index aa972433..0be0d13f 100644 --- a/Pds/Pds.Web/Pages/Gifts/Edit.razor +++ b/Pds/Pds.Web/Pages/Gifts/Edit.razor @@ -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 @@ -28,7 +26,7 @@ else {

Редактирование подарка - +

@if (gift.Content?.Id != null && gift.Content.Title != null) { diff --git a/Pds/Pds.Web/Pages/Gifts/Info.razor b/Pds/Pds.Web/Pages/Gifts/Info.razor index 6f322eb1..73437450 100644 --- a/Pds/Pds.Web/Pages/Gifts/Info.razor +++ b/Pds/Pds.Web/Pages/Gifts/Info.razor @@ -7,7 +7,6 @@ @using Pds.Web.Pages.Gifts.Components @inject IApiClient ApiClient -@inject NavigationManager NavigationManager @inject IAccessTokenProvider TokenProvider @if (gift == null) @@ -24,7 +23,7 @@ else

Подарок "@gift.Title" @EnumsTranslator.GiftTypeToRu(gift.Type) - +

@@ -92,7 +91,7 @@ else { if (isRedirectNeeded) { - NavigationManager.NavigateTo("/gifts"); + GoBack("/gifts"); } gift = await GetGiftAsync(); diff --git a/Pds/Pds.Web/Pages/Map.razor b/Pds/Pds.Web/Pages/Map.razor deleted file mode 100644 index eb914852..00000000 --- a/Pds/Pds.Web/Pages/Map.razor +++ /dev/null @@ -1,20 +0,0 @@ -@page "/map" -@inherits BasePageComponent - -@using static Pds.Web.Common.TitleExtension -@WithSuffix("Карта") - -

Карта

- -

Скоро будет тут, а пока покликай: @currentCount

- - - -@code { - private int currentCount = 0; - - private void IncrementCount() - { - currentCount++; - } -} \ No newline at end of file diff --git a/Pds/Pds.Web/Pages/Persons/Create.razor b/Pds/Pds.Web/Pages/Persons/Create.razor index c2e0a417..2d686ec5 100644 --- a/Pds/Pds.Web/Pages/Persons/Create.razor +++ b/Pds/Pds.Web/Pages/Persons/Create.razor @@ -8,7 +8,6 @@ @using Pds.Api.Contracts.Controllers.Person.CreatePerson @using Pds.Core.Constants -@inject NavigationManager NavigationManager @inject IApiClient ApiClient @inject IAccessTokenProvider TokenProvider @@ -24,7 +23,7 @@ else {

Добавление персоны - +

diff --git a/Pds/Pds.Web/Pages/Persons/Edit.razor b/Pds/Pds.Web/Pages/Persons/Edit.razor index aa9bcce6..8eea8e7b 100644 --- a/Pds/Pds.Web/Pages/Persons/Edit.razor +++ b/Pds/Pds.Web/Pages/Persons/Edit.razor @@ -11,7 +11,6 @@ @using Pds.Api.Contracts.Controllers.Person.GetPerson @using Pds.Core.Extensions -@inject NavigationManager NavigationManager @inject IApiClient ApiClient @inject IMapper Mapper @inject IAccessTokenProvider TokenProvider @@ -28,7 +27,7 @@ else {

Редактирование персоны - +

diff --git a/Pds/Pds.Web/Pages/Persons/Info.razor b/Pds/Pds.Web/Pages/Persons/Info.razor index 856a0dcf..bea91a3b 100644 --- a/Pds/Pds.Web/Pages/Persons/Info.razor +++ b/Pds/Pds.Web/Pages/Persons/Info.razor @@ -8,7 +8,6 @@ @using Pds.Web.Pages.Persons.Components @inject IApiClient ApiClient -@inject NavigationManager NavigationManager @inject IAccessTokenProvider TokenProvider @if (person == null) @@ -25,7 +24,7 @@ else

Персона "@person.FullName" - +

@@ -144,7 +143,7 @@ else { if (isRedirectNeeded) { - NavigationManager.NavigateTo("/persons"); + GoBack("/persons"); } person = await GetPersonAsync(); diff --git a/Pds/Pds.Web/Pages/Settings/Edit.razor b/Pds/Pds.Web/Pages/Settings/Edit.razor index 52b1e09e..7eef85ff 100644 --- a/Pds/Pds.Web/Pages/Settings/Edit.razor +++ b/Pds/Pds.Web/Pages/Settings/Edit.razor @@ -24,7 +24,7 @@ else {

Редактирование настройки - +