wip - office report - refactor
This commit is contained in:
parent
dba5d2decb
commit
3b8f8948c1
24 changed files with 84 additions and 391 deletions
|
@ -44,9 +44,9 @@
|
|||
<td>@user.FullName</td>
|
||||
<td>@user.PhoneNumber</td>
|
||||
<td>@user.Email</td>
|
||||
<td><a class="btn btn-outline-dark" href="/admin/users/advisors/@user.CountryCode.ToLower()/@user.UserId/reports">Rapporter</a></td>
|
||||
<td><a class="btn btn-outline-dark" href="/admin/users/advisors/@user.CountryCode.ToLower()/@user.UserId/companies">Kunder</a></td>
|
||||
<td><a class="btn btn-outline-dark" href="/admin/users/advisors/@user.CountryCode.ToLower()/@user.UserId/view">Rediger</a></td>
|
||||
<td><a class="btn btn-outline-dark" href="/office/users/advisors/@user.CountryCode.ToLower()/@user.UserId/reports">Rapporter</a></td>
|
||||
<td><a class="btn btn-outline-dark" href="/office/users/advisors/@user.CountryCode.ToLower()/@user.UserId/companies">Kunder</a></td>
|
||||
<td><a class="btn btn-outline-dark" href="/office/users/advisors/@user.CountryCode.ToLower()/@user.UserId/view">Rediger</a></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
ActionLink="/office/customers/$ID$/orders/new"
|
||||
ButtonText="Telefon Ordre"
|
||||
ButtonType="primary"
|
||||
Enabled="true">
|
||||
Enabled=1>
|
||||
</ActivityButton>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
</div>
|
||||
@foreach (var report in ReportList)
|
||||
{
|
||||
<a class="list-group-item list-group-item-action" href="/admin/users/advisors/@CountryCode/@UserId/reports/@report.ReportDate">
|
||||
<a class="list-group-item list-group-item-action" href="/office/users/advisors/@CountryCode/@UserId/reports/@report.ReportDate">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@report.ReportDate
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
</div>
|
||||
@foreach (var user in UserList)
|
||||
{
|
||||
<a class="list-group-item list-group-item-action" href="/admin/users/office/@user.CountryCode.ToLower()/@user.UserId/view">
|
||||
<a class="list-group-item list-group-item-action" href="/office/users/office/@user.CountryCode.ToLower()/@user.UserId/view">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@user.FullName
|
||||
|
|
|
@ -48,12 +48,12 @@ public class OfficeReportHttpRepository : IOfficeReportHttpRepository
|
|||
|
||||
public async Task<List<NgSalesReportListView>> GetReports(string userId)
|
||||
{
|
||||
return await _client.GetFromJsonAsync<List<NgSalesReportListView>>($"{_apiConfig.OfficeAdvisors}/{userId}/reports");
|
||||
return await _client.GetFromJsonAsync<List<NgSalesReportListView>>($"{_apiConfig.OfficeReports}/{userId}");
|
||||
}
|
||||
|
||||
public async Task<ReportView> GetReport(string userId, string workDate)
|
||||
{
|
||||
return await _client.GetFromJsonAsync<ReportView>($"{_apiConfig.OfficeAdvisors}/{userId}/reports/{workDate}");
|
||||
return await _client.GetFromJsonAsync<ReportView>($"{_apiConfig.OfficeReports}/{userId}/{workDate}");
|
||||
|
||||
}
|
||||
}
|
|
@ -27,7 +27,6 @@
|
|||
<div class="card-header bg-dark text-white">
|
||||
<h3>@_company.Account - @_company.Name</h3>
|
||||
</div>
|
||||
@*
|
||||
@if (_dk)
|
||||
{
|
||||
<div class="card-body">
|
||||
|
@ -67,7 +66,6 @@
|
|||
</table>
|
||||
}
|
||||
}
|
||||
*@
|
||||
<EditForm EditContext="_editContext" OnValidSubmit="SubmitUpdate">
|
||||
<DataAnnotationsValidator/>
|
||||
<div class="card-body">
|
||||
|
@ -83,7 +81,7 @@
|
|||
<td>
|
||||
<InputText id="vatNumber" class="form-control" @bind-Value="_company.VatNumber"/>
|
||||
<ValidationMessage For="@(() => _company.VatNumber)"></ValidationMessage>
|
||||
<button class="btn btn-warning" type="button" @onclick="CallVatLookupModal">CVR opslag</button>
|
||||
@* <button class="btn btn-warning" type="button" @onclick="CallVatLookupModal">CVR opslag</button> *@
|
||||
</td>
|
||||
<th>
|
||||
Telefon
|
||||
|
|
|
@ -203,6 +203,22 @@ public partial class CrmViewCompanyPage : IDisposable
|
|||
_hideButtons = false;
|
||||
}
|
||||
|
||||
private async Task GetInfoFromAddress(VatAddress address)
|
||||
{
|
||||
_toast.ShowInfo("Vent for adresse info ...");
|
||||
_vInfos = await _vatService.QueryVirkRegistry(
|
||||
new VirkParams
|
||||
{
|
||||
StreetName = address.StreetName,
|
||||
HouseNumber = address.HouseNumber,
|
||||
ZipCode = address.ZipCode
|
||||
});
|
||||
if (!_vInfos.Any())
|
||||
{
|
||||
_toast.ShowWarning($"Ingen data fundet ...");
|
||||
}
|
||||
}
|
||||
|
||||
private static VatAddress PrepareVatAddress(CompanyDto model)
|
||||
{
|
||||
var digits = "1234567890".ToCharArray();
|
||||
|
@ -245,49 +261,49 @@ public partial class CrmViewCompanyPage : IDisposable
|
|||
|
||||
if (regInfo.SyncAll)
|
||||
{
|
||||
_company.VatNumber = this._virkRegInfo.VatNumber;
|
||||
_company.Name = this._virkRegInfo.Name;
|
||||
_company.Address1 = this._virkRegInfo.Address;
|
||||
_company.Address2 = this._virkRegInfo.CoName;
|
||||
_company.ZipCode = this._virkRegInfo.ZipCode;
|
||||
_company.City = this._virkRegInfo.City;
|
||||
_company.VatNumber = _virkRegInfo.VatNumber;
|
||||
_company.Name = _virkRegInfo.Name;
|
||||
_company.Address1 = _virkRegInfo.Address;
|
||||
_company.Address2 = _virkRegInfo.CoName;
|
||||
_company.ZipCode = _virkRegInfo.ZipCode;
|
||||
_company.City = _virkRegInfo.City;
|
||||
_isDirty = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_company.VatNumber = this._virkRegInfo.VatNumber;
|
||||
_company.VatNumber = _virkRegInfo.VatNumber;
|
||||
_vatUpdated = 1;
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
// private void SelectCompany(string vatNumber, bool syncAll)
|
||||
// {
|
||||
// _virkRegInfo = (from x in _vInfos where x.VatNumber == vatNumber select x).First();
|
||||
// _validVat = _virkRegInfo.States[0].State.ToLower() == "normal";
|
||||
// _company.HasFolded = _validVat ? 1 : 0;
|
||||
// _enableActivity = _validVat ? 1 : 0;
|
||||
// _vatState = _virkRegInfo.States[0].State.ToLower() == "normal" ? "the-good" : "the-dead";
|
||||
//
|
||||
// if (syncAll)
|
||||
// {
|
||||
// _company.VatNumber = _virkRegInfo.VatNumber;
|
||||
// _company.Name = _virkRegInfo.Name;
|
||||
// _company.Address1 = _virkRegInfo.Address;
|
||||
// _company.Address2 = _virkRegInfo.CoName;
|
||||
// _company.ZipCode = _virkRegInfo.ZipCode;
|
||||
// _company.City = _virkRegInfo.City;
|
||||
// _isDirty = 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _company.VatNumber = _virkRegInfo.VatNumber;
|
||||
// _vatUpdated = 1;
|
||||
// }
|
||||
// // empty list
|
||||
// _vInfos = new List<VirkRegInfo>();
|
||||
// StateHasChanged();
|
||||
// }
|
||||
private void SelectCompany(string vatNumber, bool syncAll)
|
||||
{
|
||||
_virkRegInfo = (from x in _vInfos where x.VatNumber == vatNumber select x).First();
|
||||
_validVat = _virkRegInfo.States[0].State.ToLower() == "normal";
|
||||
_company.HasFolded = _validVat ? 1 : 0;
|
||||
_enableActivity = _validVat ? 1 : 0;
|
||||
_vatState = _virkRegInfo.States[0].State.ToLower() == "normal" ? "the-good" : "the-dead";
|
||||
|
||||
if (syncAll)
|
||||
{
|
||||
_company.VatNumber = _virkRegInfo.VatNumber;
|
||||
_company.Name = _virkRegInfo.Name;
|
||||
_company.Address1 = _virkRegInfo.Address;
|
||||
_company.Address2 = _virkRegInfo.CoName;
|
||||
_company.ZipCode = _virkRegInfo.ZipCode;
|
||||
_company.City = _virkRegInfo.City;
|
||||
_isDirty = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_company.VatNumber = _virkRegInfo.VatNumber;
|
||||
_vatUpdated = 1;
|
||||
}
|
||||
// empty list
|
||||
_vInfos = new List<VirkRegInfo>();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
@page "/admin/users/advisors"
|
||||
@page "/office/users/advisors"
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header bg-dark text-white">
|
||||
|
@ -27,9 +27,9 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<div class="list-group list-group-flush">
|
||||
<a class="list-group-item list-group-item-action" href="/admin/users/advisors/dk">Danmark</a>
|
||||
<a class="list-group-item list-group-item-action" href="/admin/users/advisors/no">Norge</a>
|
||||
<a class="list-group-item list-group-item-action" href="/admin/users/advisors/se">Sverige</a>
|
||||
<a class="list-group-item list-group-item-action" href="/office/users/advisors/dk">Danmark</a>
|
||||
<a class="list-group-item list-group-item-action" href="/office/users/advisors/no">Norge</a>
|
||||
<a class="list-group-item list-group-item-action" href="/office/users/advisors/se">Sverige</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
@page "/admin/users/office"
|
||||
@page "/office/users/office"
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header bg-dark text-white">
|
||||
|
@ -27,7 +27,7 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<div class="list-group list-group-flush">
|
||||
<a class="list-group-item list-group-item-action" href="/admin/users/office/dk">Danmark</a>
|
||||
<a class="list-group-item list-group-item-action" href="/office/users/office/dk">Danmark</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
|
||||
@using Wonky.Client.Components
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
@page "/admin/users/advisors/{CountryCode}"
|
||||
@attribute [Authorize(Roles = "Admin,Office")]
|
||||
@page "/office/users/advisors/{CountryCode}"
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header bg-dark text-white">
|
||||
<h3>Sælgere</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<OfficeAdvisorTableComponent UserList="_salesReps"></OfficeAdvisorTableComponent>
|
||||
<OfficeAdvisorTableComponent UserList="_salesReps" />
|
||||
</div>
|
||||
</div>
|
|
@ -16,7 +16,7 @@
|
|||
*@
|
||||
|
||||
@using Wonky.Client.Components
|
||||
@page "/admin/companies"
|
||||
@page "/office/companies"
|
||||
|
||||
<div class="sticky-top bg-dark text-light rounded-2 px-3">
|
||||
<div class="container-fluid pt-3">
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*@
|
||||
|
||||
@using Wonky.Client.Components
|
||||
@page "/admin/companies"
|
||||
@page "/office/companies/{CountryCode}/{UserId}"
|
||||
|
||||
<div class="sticky-top bg-dark text-light rounded-2 px-3">
|
||||
<div class="container-fluid pt-3">
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
@using Wonky.Client.Components
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
@page "/admin/users/advisors/{CountryCode}/{UserId}/reports"
|
||||
@page "/office/users/advisors/{CountryCode}/{UserId}/reports"
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header bg-dark text-white">
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
//
|
||||
*@
|
||||
|
||||
@page "/admin/users/advisors/{CountryCode}/{UserId}/view"
|
||||
@page "/office/users/advisors/{CountryCode}/{UserId}/view"
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Wonky.Client.Components
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
@ -97,10 +97,10 @@
|
|||
<button type="submit" class="btn btn-primary">Gem</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<a class="btn btn-primary" href="/admin/users/advisors/@CountryCode">Tilbage</a>
|
||||
<a class="btn btn-primary" href="/office/users/advisors/@CountryCode">Tilbage</a>
|
||||
</div>
|
||||
<div class="col">
|
||||
<a class="btn btn-primary" href="/admin/users/advisors/@CountryCode/@UserId/reports">Salg</a>
|
||||
<a class="btn btn-primary" href="/office/users/advisors/@CountryCode/@UserId/reports">Salg</a>
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
@using Wonky.Client.Components
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@page "/admin/users/advisors/{CountryCode}/{UserId}/reports/{ReportDate}"
|
||||
@page "/office/users/advisors/{CountryCode}/{UserId}/reports/{ReportDate}"
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<div class="report-main">
|
||||
|
|
|
@ -73,7 +73,7 @@ public partial class OfficeViewReportPage : IDisposable
|
|||
{
|
||||
if (workDate != ReportDate)
|
||||
{
|
||||
_navigator.NavigateTo($"/admin/users/advisors/{CountryCode}/{UserId}/reports/{workDate}");
|
||||
_navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}/reports/{workDate}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
@*
|
||||
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
*@
|
||||
|
||||
@page "/price-catalog"
|
||||
@using Wonky.Client.Components
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
|
||||
@attribute [Authorize(Roles = "Advisor,Admin")]
|
||||
|
||||
<div class="sticky-top bg-dark rounded-2 px-3">
|
||||
<div class="container-fluid pt-3">
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<ItemGroupComponent OnChanged="SetItemGroup"/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<ItemSearchComponent OnChanged="SetSearchCol"/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<ItemSearchPhraseComponent OnChanged="SetSearchPhrase"/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<ItemSortComponent OnChanged="SetSortCol"/>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<PageSizeComponent OnChanged="SetPageSize" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-10">
|
||||
<PaginationComponent MetaData="_metaData" Spread="2" SelectedPage="SelectedPage" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ItemTableComponent SalesItems="_items" />
|
|
@ -1,110 +0,0 @@
|
|||
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Blazored.LocalStorage;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Wonky.Client.Components;
|
||||
using Wonky.Client.HttpInterfaces;
|
||||
using Wonky.Client.Services;
|
||||
using Wonky.Entity.DTO;
|
||||
using Wonky.Entity.Requests;
|
||||
using Wonky.Entity.Views;
|
||||
|
||||
namespace Wonky.Client.Pages;
|
||||
|
||||
public partial class SalesCatalogNoPage : IDisposable
|
||||
{
|
||||
[Inject] public ILocalStorageService _storage { get; set; }
|
||||
[Inject] public ICatalogHttpRepository _itemRepo { get; set; }
|
||||
[Inject] public HttpInterceptorService _interceptor { get; set; }
|
||||
[Inject] public UserPreferenceService _preferenceService { get; set; }
|
||||
private List<SalesItemView> _items { get; set; } = new();
|
||||
private MetaData _metaData { get; set; } = new();
|
||||
private CatalogPagingParams _paging = new();
|
||||
private Preferences _preferences = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_preferences = await _preferenceService.GetPreferences();
|
||||
_paging.OrderBy = _preferences.ItemSort;
|
||||
_paging.SearchColumn = _preferences.ItemSearch;
|
||||
_paging.PageSize = Convert.ToInt32(_preferences.PageSize);
|
||||
|
||||
_interceptor.RegisterEvent();
|
||||
_interceptor.RegisterBeforeSendEvent();
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
private async Task GetSalesItems()
|
||||
{
|
||||
var pagingResponse = await _itemRepo.GetSalesItemsPaged(_paging);
|
||||
_items = pagingResponse.Items!;
|
||||
_metaData = pagingResponse.MetaData;
|
||||
}
|
||||
|
||||
private async Task SetSearchPhrase(string searchTerm)
|
||||
{
|
||||
_items = new List<SalesItemView>();
|
||||
_paging.PageNumber = 1;
|
||||
_paging.SearchTerm = searchTerm;
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
private async Task SetPageSize(string pageSize)
|
||||
{
|
||||
_items = new List<SalesItemView>();
|
||||
_paging.PageSize = Convert.ToInt32(pageSize);
|
||||
_paging.PageNumber = 1;
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
private async Task SetSearchCol(string columnName)
|
||||
{
|
||||
_items = new List<SalesItemView>();
|
||||
_paging.PageNumber = 1;
|
||||
_paging.SearchColumn = columnName;
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
private async Task SetSortCol(string orderBy)
|
||||
{
|
||||
_items = new List<SalesItemView>();
|
||||
_paging.OrderBy = orderBy;
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
private async Task SelectedPage(int page)
|
||||
{
|
||||
_items = new List<SalesItemView>();
|
||||
_paging.PageNumber = page;
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
private async Task SetItemGroup(string groupFilter)
|
||||
{
|
||||
_items = new List<SalesItemView>();
|
||||
_paging.PageNumber = 1;
|
||||
_paging.SelectGroup = groupFilter;
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
public void Dispose() => _interceptor.DisposeEvent();
|
||||
|
||||
}
|
|
@ -29,8 +29,9 @@ using Wonky.Entity.Views;
|
|||
|
||||
namespace Wonky.Client.Pages;
|
||||
|
||||
public partial class SalesCatalogDkPage : IDisposable
|
||||
public partial class SalesCatalogPage : IDisposable
|
||||
{
|
||||
[Parameter] public string CountryCode { get; set; } = "";
|
||||
[Inject] public ILocalStorageService _storage { get; set; }
|
||||
[Inject] public ICatalogHttpRepository _itemRepo { get; set; }
|
||||
[Inject] public HttpInterceptorService _interceptor { get; set; }
|
|
@ -1,51 +0,0 @@
|
|||
@*
|
||||
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
*@
|
||||
|
||||
@page "/price-catalog"
|
||||
@using Wonky.Client.Components
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
|
||||
@attribute [Authorize(Roles = "Advisor,Admin")]
|
||||
|
||||
<div class="sticky-top bg-dark rounded-2 px-3">
|
||||
<div class="container-fluid pt-3">
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<ItemGroupComponent OnChanged="SetItemGroup"/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<ItemSearchComponent OnChanged="SetSearchCol"/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<ItemSearchPhraseComponent OnChanged="SetSearchPhrase"/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<ItemSortComponent OnChanged="SetSortCol"/>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<PageSizeComponent OnChanged="SetPageSize" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-10">
|
||||
<PaginationComponent MetaData="_metaData" Spread="2" SelectedPage="SelectedPage" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ItemTableComponent SalesItems="_items" />
|
|
@ -1,110 +0,0 @@
|
|||
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Blazored.LocalStorage;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Wonky.Client.Components;
|
||||
using Wonky.Client.HttpInterfaces;
|
||||
using Wonky.Client.Services;
|
||||
using Wonky.Entity.DTO;
|
||||
using Wonky.Entity.Requests;
|
||||
using Wonky.Entity.Views;
|
||||
|
||||
namespace Wonky.Client.Pages;
|
||||
|
||||
public partial class SalesCatalogSePage : IDisposable
|
||||
{
|
||||
[Inject] public ILocalStorageService _storage { get; set; }
|
||||
[Inject] public ICatalogHttpRepository _itemRepo { get; set; }
|
||||
[Inject] public HttpInterceptorService _interceptor { get; set; }
|
||||
[Inject] public UserPreferenceService _preferenceService { get; set; }
|
||||
private List<SalesItemView> _items { get; set; } = new();
|
||||
private MetaData _metaData { get; set; } = new();
|
||||
private CatalogPagingParams _paging = new();
|
||||
private Preferences _preferences = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_preferences = await _preferenceService.GetPreferences();
|
||||
_paging.OrderBy = _preferences.ItemSort;
|
||||
_paging.SearchColumn = _preferences.ItemSearch;
|
||||
_paging.PageSize = Convert.ToInt32(_preferences.PageSize);
|
||||
|
||||
_interceptor.RegisterEvent();
|
||||
_interceptor.RegisterBeforeSendEvent();
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
private async Task GetSalesItems()
|
||||
{
|
||||
var pagingResponse = await _itemRepo.GetSalesItemsPaged(_paging);
|
||||
_items = pagingResponse.Items!;
|
||||
_metaData = pagingResponse.MetaData;
|
||||
}
|
||||
|
||||
private async Task SetSearchPhrase(string searchTerm)
|
||||
{
|
||||
_items = new List<SalesItemView>();
|
||||
_paging.PageNumber = 1;
|
||||
_paging.SearchTerm = searchTerm;
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
private async Task SetPageSize(string pageSize)
|
||||
{
|
||||
_items = new List<SalesItemView>();
|
||||
_paging.PageSize = Convert.ToInt32(pageSize);
|
||||
_paging.PageNumber = 1;
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
private async Task SetSearchCol(string columnName)
|
||||
{
|
||||
_items = new List<SalesItemView>();
|
||||
_paging.PageNumber = 1;
|
||||
_paging.SearchColumn = columnName;
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
private async Task SetSortCol(string orderBy)
|
||||
{
|
||||
_items = new List<SalesItemView>();
|
||||
_paging.OrderBy = orderBy;
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
private async Task SelectedPage(int page)
|
||||
{
|
||||
_items = new List<SalesItemView>();
|
||||
_paging.PageNumber = page;
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
private async Task SetItemGroup(string groupFilter)
|
||||
{
|
||||
_items = new List<SalesItemView>();
|
||||
_paging.PageNumber = 1;
|
||||
_paging.SelectGroup = groupFilter;
|
||||
await GetSalesItems();
|
||||
}
|
||||
|
||||
public void Dispose() => _interceptor.DisposeEvent();
|
||||
|
||||
}
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
<AuthorizeView Roles="Admin">
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link ps-2" href="/admin/users/advisors">
|
||||
<NavLink class="nav-link ps-2" href="/office/users/advisors">
|
||||
<span class="oi oi-people" aria-hidden="true"></span> Sælgere
|
||||
</NavLink>
|
||||
</div>
|
||||
|
@ -61,7 +61,7 @@
|
|||
|
||||
<AuthorizeView Roles="Office">
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link ps-2" href="/admin/users/advisors">
|
||||
<NavLink class="nav-link ps-2" href="/office/users/advisors">
|
||||
<span class="oi oi-people" aria-hidden="true"></span> Sælgere
|
||||
</NavLink>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"appInfo": {
|
||||
"name": "Wonky Client",
|
||||
"version": "0.19.1",
|
||||
"rc": true,
|
||||
"sandBox": true,
|
||||
"version": "0.20.20",
|
||||
"rc": false,
|
||||
"sandBox": false,
|
||||
"image": "grumpy-coder.png"
|
||||
},
|
||||
"apiConfig": {
|
||||
|
@ -25,7 +25,7 @@
|
|||
"crmSync": "history/sync",
|
||||
"crmWorkplaces": "workplaces",
|
||||
"officeAdvisors": "api/v2/office/users/advisors",
|
||||
"officeUsers": "api/v2/office/users/office",
|
||||
"officeUsers": "api/v2/office/users/admin",
|
||||
"officeUserPasswd": "api/v2/office/users/passwd",
|
||||
"officeCustomers": "api/v2/office/customers",
|
||||
"officeReports": "api/v2/office/reports",
|
||||
|
|
Loading…
Reference in a new issue