WIP user manager create web shop user pick company
This commit is contained in:
parent
4c8ea61749
commit
7d21b834fc
49 changed files with 229 additions and 135 deletions
29
Wonky.Client/Helpers/Mapper.cs
Normal file
29
Wonky.Client/Helpers/Mapper.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
using System.Reflection.Metadata.Ecma335;
|
||||||
|
using Wonky.Client.Models;
|
||||||
|
using Wonky.Entity.DTO;
|
||||||
|
|
||||||
|
namespace Wonky.Client.Helpers;
|
||||||
|
|
||||||
|
public class Mapper
|
||||||
|
{
|
||||||
|
public static UserManagerCreateView MapCreateUser(CreateUserInputModel model)
|
||||||
|
{
|
||||||
|
return new UserManagerCreateView
|
||||||
|
{
|
||||||
|
Description = model.Description,
|
||||||
|
Email = model.Email,
|
||||||
|
Passwd = model.NewPassword,
|
||||||
|
AssignedRoles = model.AssignedRoles,
|
||||||
|
CompanyId = model.CompanyId,
|
||||||
|
CountryCode = model.CountryCode,
|
||||||
|
EmailConfirmed = true,
|
||||||
|
EShop = model.EShop,
|
||||||
|
FirstName = model.FirstName,
|
||||||
|
LastName = model.LastName,
|
||||||
|
LockoutEnabled = false,
|
||||||
|
PhoneNumber = model.PhoneNumber,
|
||||||
|
SalesRep = model.SalesRep,
|
||||||
|
UserId = ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
46
Wonky.Client/Models/CreateUserInputModel.cs
Normal file
46
Wonky.Client/Models/CreateUserInputModel.cs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using Wonky.Entity.DTO;
|
||||||
|
|
||||||
|
namespace Wonky.Client.Models;
|
||||||
|
|
||||||
|
public class CreateUserInputModel
|
||||||
|
{
|
||||||
|
[MaxLength(128)] public string CompanyId { get; set; } = "";
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Der skal vælges et land")]
|
||||||
|
public string CountryCode { get; set; } = "";
|
||||||
|
|
||||||
|
[MaxLength(128, ErrorMessage = "Kort beskrivelse på højst 128 tegn.")]
|
||||||
|
public string Description { get; set; } = "";
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Email adresse skal udfyldes")]
|
||||||
|
[MaxLength(255, ErrorMessage = "Der er afsat 255 tegn til email adressen")]
|
||||||
|
public string Email { get; set; } = "";
|
||||||
|
|
||||||
|
public bool EmailConfirmed { get; set; }
|
||||||
|
public bool EShop { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Fornavn skal udfyldes")]
|
||||||
|
[MaxLength(50, ErrorMessage = "Der er afsat 50 tegn til fornavn")]
|
||||||
|
public string FirstName { get; set; } = "";
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Efternavn skal udfyldes")]
|
||||||
|
[MaxLength(50, ErrorMessage = "Der er afsat 50 tegn til efternavn")]
|
||||||
|
public string LastName { get; set; } = "";
|
||||||
|
|
||||||
|
public bool LockoutEnabled { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "AdgangsKode skal udfyldes")]
|
||||||
|
public string NewPassword { get; set; } = "";
|
||||||
|
|
||||||
|
[Compare(nameof(NewPassword), ErrorMessage = "Adgangskoder er ikke ens.")]
|
||||||
|
public string ConfirmPassword { get; set; } = "";
|
||||||
|
|
||||||
|
[MaxLength(20, ErrorMessage = "Der er afsat 20 tegn til telefon nummber")]
|
||||||
|
public string PhoneNumber { get; set; } = "";
|
||||||
|
|
||||||
|
[MaxLength(20, ErrorMessage = "Der er afsat 20 tegn til Sælger Identifikation")]
|
||||||
|
public string SalesRep { get; set; } = "";
|
||||||
|
|
||||||
|
public List<UserRoleAssignment> AssignedRoles { get; set; } = new();
|
||||||
|
}
|
|
@ -33,4 +33,4 @@
|
||||||
<div class="modal-backdrop fade show"></div>
|
<div class="modal-backdrop fade show"></div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<CustomerInventoryReorderOverlay CompanyId="@CompanyId" SalesItem="SalesItem" OnSelected="OnSelected" @ref="ReorderOverlay" />
|
<CustomerInventoryReorderOverlay CompanyId="@CompanyId" SalesItem="SalesItem" OnSelected="OnSelected" @ref="@ReorderOverlay" />
|
|
@ -34,4 +34,4 @@
|
||||||
<div class="modal-backdrop fade show"></div>
|
<div class="modal-backdrop fade show"></div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<CustomerInvoiceViewOverlay CompanyId="@Company.CompanyId" InvoiceId="@InvoiceId" @ref="CustomerInvoiceView" />
|
<CustomerInvoiceViewOverlay CompanyId="@Company.CompanyId" InvoiceId="@InvoiceId" @ref="@CustomerInvoiceView" />
|
|
@ -23,72 +23,60 @@
|
||||||
<button type="button" class="btn btn-danger" @onclick="@Hide" data-bs-dismiss="modal" aria-label="Luk"><i class="bi-x-lg"></i></button>
|
<button type="button" class="btn btn-danger" @onclick="@Hide" data-bs-dismiss="modal" aria-label="Luk"><i class="bi-x-lg"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="sticky-top bg-dark rounded-2 p-3">
|
<div class="sticky-top rounded-2 p-3">
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<SearchCatalogColumnComponent OnChanged="SetSearchCol"/>
|
<SearchCustomerColumnComponent OnChanged="SetSearchCol"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<SearchCatalogPhraseComponent OnChanged="SetSearchPhrase"/>
|
<SearchCustomerPhraseComponent OnChanged="SetSearchPhrase"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<SearchCatalogSortColumnComponent OnChanged="SetSortCol"/>
|
<SearchCustomerSortColumnComponent OnChanged="SetSortCol"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<PageSizeComponent OnChanged="SetPageSize"/>
|
<PageSizeComponent OnChanged="SetPageSize"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<div class="col-sm-12 text-center">
|
<div class="col-sm-12 text-center">
|
||||||
<PagerPagesComponent MetaData="PageData" Spread="2" SelectedPage="SetSelectedPage" />
|
<PagerPagesComponent MetaData="PageData" Spread="2" SelectedPage="SetSelectedPage" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row text-white">
|
<div class="row text-white">
|
||||||
<div class="col-sm-3 fw-bold">Vare</div>
|
<div class="col-sm-3 fw-bold">Navn</div>
|
||||||
<div class="col-sm-2 fw-bold">Varenr</div>
|
<div class="col-sm-2 fw-bold">Konto</div>
|
||||||
<div class="col-sm-2 fw-bold">Fork</div>
|
<div class="col-sm-2 fw-bold">Telefon</div>
|
||||||
<div class="col-sm-1 text-center fw-bold">Colli</div>
|
<div class="col-sm-1 fw-bold">Post Nr.</div>
|
||||||
<div class="col-sm-4 text-center fw-bold">Stk / Pris</div>
|
<div class="col-sm-2 fw-bold">Bynavn</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (Items.Any())
|
@if (Companies.Any())
|
||||||
{
|
{
|
||||||
<ul class="list-group list-group-flush">
|
<ul class="list-group list-group-flush">
|
||||||
@foreach (var item in Items)
|
@foreach (var company in Companies)
|
||||||
{
|
{
|
||||||
<li class="list-group-item">
|
<li class="list-group-item list-group-item-action action-link-element" @onclick="@(() => SelectCompany(company))">
|
||||||
<div class="row align-middle">
|
<div class="row align-middle">
|
||||||
<div class="col-sm-3 text-sm-start">
|
<div class="col-sm-3 text-sm-start">
|
||||||
@item.Name
|
@company.Name
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2 text-sm-start">
|
<div class="col-sm-2 text-sm-start">
|
||||||
@item.Sku
|
@company.Account
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2 text-sm-start">
|
<div class="col-sm-2 text-sm-start">
|
||||||
@item.ShortName
|
@company.Phone
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-1 text-center">
|
<div class="col-sm-1 text-center">
|
||||||
@item.BoxSize
|
@company.ZipCode
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-2">
|
||||||
<ul class="list-group">
|
@company.City
|
||||||
@foreach (var rate in item.Rates)
|
|
||||||
{
|
|
||||||
<li class="list-group-item d-flex justify-content-between align-items-end">
|
|
||||||
<div class="text-sm-end me-1">@rate.Quantity</div>
|
|
||||||
<div class="text-sm-end me-1">@rate.Rate</div>
|
|
||||||
<div>
|
|
||||||
<a class="btn btn-primary btn-sm" data-bs-dismiss="modal" @onclick="@(() => SelectItem(item.SalesItemId, rate.Quantity, rate.Rate))">
|
|
||||||
<i class="bi-plus-lg"></i>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
}
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
|
@ -20,38 +20,39 @@ using Wonky.Client.HttpInterceptors;
|
||||||
using Wonky.Client.HttpRepository;
|
using Wonky.Client.HttpRepository;
|
||||||
using Wonky.Client.Local.Services;
|
using Wonky.Client.Local.Services;
|
||||||
using Wonky.Client.Models;
|
using Wonky.Client.Models;
|
||||||
|
using Wonky.Entity.DTO;
|
||||||
using Wonky.Entity.Requests;
|
using Wonky.Entity.Requests;
|
||||||
using Wonky.Entity.Views;
|
using Wonky.Entity.Views;
|
||||||
|
|
||||||
#pragma warning disable CS8618
|
#pragma warning disable CS8618
|
||||||
|
|
||||||
namespace Wonky.Client.Overlay.System;
|
namespace Wonky.Client.OverlaySystem;
|
||||||
|
|
||||||
public partial class SelectCustomerPagedOverlay : IDisposable
|
public partial class CustomerSearchOverlay : IDisposable
|
||||||
{
|
{
|
||||||
// ##############################################################
|
// ##############################################################
|
||||||
[Inject] public ICountryCatalogRepository CatalogRepo { get; set; }
|
[Inject] public ICountryCustomerRepository CustomerRepo { get; set; }
|
||||||
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
||||||
[Inject] public UserPreferenceService PreferenceService { get; set; }
|
[Inject] public UserPreferenceService PreferenceService { get; set; }
|
||||||
[Inject] public ILogger<SelectCustomerPagedOverlay> Logger { get; set; }
|
[Inject] public ILogger<CustomerSearchOverlay> Logger { get; set; }
|
||||||
|
|
||||||
// ##############################################################
|
// ##############################################################
|
||||||
[Parameter] public string CountryCode { get; set; } = "";
|
[Parameter] public string CountryCode { get; set; } = "";
|
||||||
[Parameter] public EventCallback<SelectedSku> OnSelected { get; set; }
|
[Parameter] public EventCallback<CompanyDto> OnSelected { get; set; }
|
||||||
|
|
||||||
// ##############################################################
|
// ##############################################################
|
||||||
private string _modalDisplay = "";
|
private string _modalDisplay = "";
|
||||||
private bool _showBackdrop;
|
private bool _showBackdrop;
|
||||||
private List<SalesItemView> Items { get; set; } = new();
|
private List<CompanyDto> Companies { get; set; } = new();
|
||||||
private MetaData? PageData { get; set; } = new();
|
private MetaData? PageData { get; set; } = new();
|
||||||
private CatalogPager _pager = new();
|
private CustomerPaging _pager = new();
|
||||||
private UserPreference _userPreference = new();
|
private UserPreference _userPreference = new();
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
Interceptor.RegisterEvent();
|
Interceptor.RegisterEvent();
|
||||||
Interceptor.RegisterBeforeSendEvent();
|
Interceptor.RegisterBeforeSendEvent();
|
||||||
await GetSalesItems();
|
await GetCompanies();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
@ -62,58 +63,58 @@ public partial class SelectCustomerPagedOverlay : IDisposable
|
||||||
_pager.PageSize = Convert.ToInt32(_userPreference.PageSize);
|
_pager.PageSize = Convert.ToInt32(_userPreference.PageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task GetSalesItems()
|
private async Task GetCompanies()
|
||||||
{
|
{
|
||||||
var pagingResponse = await CatalogRepo.GetSalesItemsPaged(CountryCode, _pager);
|
var pagingResponse = await CustomerRepo.GetCompaniesPaged(CountryCode, _pager);
|
||||||
if (pagingResponse == null)
|
// if (pagingResponse == null)
|
||||||
Task.Delay(250);
|
// Task.Delay(250);
|
||||||
Items = pagingResponse.Items!;
|
Companies = pagingResponse.Items;
|
||||||
PageData = pagingResponse.MetaData;
|
PageData = pagingResponse.MetaData;
|
||||||
Logger.LogDebug("PriceCatalogOverlay => Items <= {}", JsonSerializer.Serialize(Items));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectItem(string itemId, string quantity, string rate)
|
|
||||||
|
private async Task SelectCompany(CompanyDto company)
|
||||||
{
|
{
|
||||||
OnSelected.InvokeAsync(new SelectedSku { Quantity = quantity, Rate = rate, ItemId = itemId });
|
await OnSelected.InvokeAsync(company);
|
||||||
Hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task SetSelectedPage(int page)
|
private async Task SetSelectedPage(int page)
|
||||||
{
|
{
|
||||||
Items = new List<SalesItemView>();
|
Companies = new List<CompanyDto>();
|
||||||
_pager.PageNumber = page;
|
_pager.PageNumber = page;
|
||||||
await GetSalesItems();
|
await GetCompanies();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SetSearchPhrase(string searchTerm)
|
private async Task SetSearchPhrase(string searchTerm)
|
||||||
{
|
{
|
||||||
Items = new List<SalesItemView>();
|
Companies = new List<CompanyDto>();
|
||||||
_pager.PageNumber = 1;
|
_pager.PageNumber = 1;
|
||||||
_pager.SearchTerm = searchTerm;
|
_pager.SearchTerm = searchTerm;
|
||||||
await GetSalesItems();
|
await GetCompanies();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SetPageSize(string pageSize)
|
private async Task SetPageSize(string pageSize)
|
||||||
{
|
{
|
||||||
Items = new List<SalesItemView>();
|
Companies = new List<CompanyDto>();
|
||||||
_pager.PageSize = Convert.ToInt32(pageSize);
|
_pager.PageSize = Convert.ToInt32(pageSize);
|
||||||
_pager.PageNumber = 1;
|
_pager.PageNumber = 1;
|
||||||
await GetSalesItems();
|
await GetCompanies();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SetSearchCol(string columnName)
|
private async Task SetSearchCol(string columnName)
|
||||||
{
|
{
|
||||||
Items = new List<SalesItemView>();
|
Companies = new List<CompanyDto>();
|
||||||
_pager.PageNumber = 1;
|
_pager.PageNumber = 1;
|
||||||
_pager.SearchColumn = columnName;
|
_pager.SearchColumn = columnName;
|
||||||
await GetSalesItems();
|
await GetCompanies();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SetSortCol(string orderBy)
|
private async Task SetSortCol(string orderBy)
|
||||||
{
|
{
|
||||||
Items = new List<SalesItemView>();
|
Companies = new List<CompanyDto>();
|
||||||
_pager.OrderBy = orderBy;
|
_pager.OrderBy = orderBy;
|
||||||
await GetSalesItems();
|
await GetCompanies();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Show()
|
public void Show()
|
||||||
|
@ -123,7 +124,7 @@ public partial class SelectCustomerPagedOverlay : IDisposable
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Hide()
|
public void Hide()
|
||||||
{
|
{
|
||||||
_modalDisplay = "none;";
|
_modalDisplay = "none;";
|
||||||
_showBackdrop = false;
|
_showBackdrop = false;
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
@using Microsoft.AspNetCore.Authorization
|
@using Microsoft.AspNetCore.Authorization
|
||||||
@using Wonky.Client.Components
|
@using Wonky.Client.Components
|
||||||
|
@using Wonky.Client.OverlaySystem
|
||||||
@attribute [Authorize(Roles = "Admin")]
|
@attribute [Authorize(Roles = "Admin")]
|
||||||
|
|
||||||
@page "/system/users/create"
|
@page "/system/users/create"
|
||||||
|
@ -27,84 +28,68 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<EditForm EditContext="NewUserContext" OnValidSubmit="CreateUserRequest">
|
<EditForm EditContext="FormContext" OnValidSubmit="CreateUserRequest">
|
||||||
<DataAnnotationsValidator/>
|
<DataAnnotationsValidator/>
|
||||||
<div class="row g-3 mb-3">
|
<div class="row g-3 mb-3">
|
||||||
@* firstName *@
|
@* firstName *@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<InputText id="firstName" class="form-control" @bind-Value="NewUserInfo.FirstName" placeholder="Fornavn"/>
|
<InputText id="firstName" class="form-control" @bind-Value="CreateUserInput.FirstName" placeholder="Fornavn"/>
|
||||||
<ValidationMessage For="@(() => NewUserInfo.FirstName)"></ValidationMessage>
|
<ValidationMessage For="@(() => CreateUserInput.FirstName)"></ValidationMessage>
|
||||||
<label for="firstName">Fornavn</label>
|
<label for="firstName">Fornavn</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@* lastName *@
|
@* lastName *@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<InputText id="lastName" class="form-control" @bind-Value="NewUserInfo.LastName" placeholder="Efternavn"/>
|
<InputText id="lastName" class="form-control" @bind-Value="CreateUserInput.LastName" placeholder="Efternavn"/>
|
||||||
<ValidationMessage For="@(() => NewUserInfo.LastName)"></ValidationMessage>
|
<ValidationMessage For="@(() => CreateUserInput.LastName)"></ValidationMessage>
|
||||||
<label for="lastName">Efternavn</label>
|
<label for="lastName">Efternavn</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@* email *@
|
@* email *@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<InputText id="email" class="form-control" @bind-Value="NewUserInfo.Email" placeholder="Email"/>
|
<InputText id="email" class="form-control" @bind-Value="CreateUserInput.Email" placeholder="Email"/>
|
||||||
<ValidationMessage For="@(() => NewUserInfo.Email)"></ValidationMessage>
|
<ValidationMessage For="@(() => CreateUserInput.Email)"></ValidationMessage>
|
||||||
<label for="email">Email</label>
|
<label for="email">Email</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@* phoneNumber *@
|
@* phoneNumber *@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<InputText id="phoneNumber" class="form-control" @bind-Value="NewUserInfo.PhoneNumber" placeholder="Direkte Telefon Nr."/>
|
<InputText id="phoneNumber" class="form-control" @bind-Value="CreateUserInput.PhoneNumber" placeholder="Direkte Telefon Nr."/>
|
||||||
<ValidationMessage For="@(() => NewUserInfo.PhoneNumber)"></ValidationMessage>
|
<ValidationMessage For="@(() => CreateUserInput.PhoneNumber)"></ValidationMessage>
|
||||||
<label for="phoneNumber">Direkte Telefon Nr.</label>
|
<label for="phoneNumber">Direkte Telefon Nr.</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@* salesRep *@
|
@* salesRep *@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<InputText id="salesRep" class="form-control" @bind-Value="NewUserInfo.SalesRep" placeholder="Sælger"/>
|
<InputText id="salesRep" class="form-control" @bind-Value="CreateUserInput.SalesRep" placeholder="Sælger"/>
|
||||||
<ValidationMessage For="@(() => NewUserInfo.SalesRep)"></ValidationMessage>
|
<ValidationMessage For="@(() => CreateUserInput.SalesRep)"></ValidationMessage>
|
||||||
<label for="salesRep">Sælger</label>
|
<label for="salesRep">Sælger</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@* countrycode *@
|
@* countrycode *@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<InputSelect id="countryCode" class="form-control" @bind-Value="NewUserInfo.CountryCode" placeholder="Landekode">
|
<InputSelect id="countryCode" class="form-control" @bind-Value="CreateUserInput.CountryCode" placeholder="Landekode">
|
||||||
<option value="" disabled>Klik for valg</option>
|
<option value="" disabled>Klik for valg</option>
|
||||||
<option value="DK">Danmark</option>
|
<option value="DK">Danmark</option>
|
||||||
<option value="NO">Norge</option>
|
<option value="NO">Norge</option>
|
||||||
<option value="SE">Sverige</option>
|
<option value="SE">Sverige</option>
|
||||||
</InputSelect>
|
</InputSelect>
|
||||||
<ValidationMessage For="@(() => NewUserInfo.CountryCode)"></ValidationMessage>
|
<ValidationMessage For="@(() => CreateUserInput.CountryCode)"></ValidationMessage>
|
||||||
<label for="countryCode">Landekode</label>
|
<label for="countryCode">Landekode</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
|
||||||
<InputCheckbox id="admin" class="form-check-input" @bind-Value="AssignedRoles.Admin"/>
|
|
||||||
<label for="admin" class="form-check-label">Administrator</label>
|
|
||||||
</div>
|
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
|
||||||
<InputCheckbox id="warehouse" class="form-check-input" @bind-Value="AssignedRoles.Warehouse"/>
|
|
||||||
<label for="warehouse" class="form-check-label">Forsendelse</label>
|
|
||||||
</div>
|
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
|
||||||
<InputCheckbox id="office" class="form-check-input" @bind-Value="AssignedRoles.Office"/>
|
|
||||||
<label for="office" class="form-check-label">Kontor</label>
|
|
||||||
</div>
|
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
<div class="ms-2 col-sm-2 form-check form-switch">
|
||||||
<InputCheckbox id="eshop" class="form-check-input" @bind-Value="AssignedRoles.EShop"/>
|
<InputCheckbox id="eshop" class="form-check-input" @bind-Value="AssignedRoles.EShop"/>
|
||||||
<label for="eshop" class="form-check-label">WebShop Kunde</label>
|
<label for="eshop" class="form-check-label">WebShop Kunde</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
|
||||||
<InputCheckbox id="management" class="form-check-input" @bind-Value="AssignedRoles.Management"/>
|
|
||||||
<label for="management" class="form-check-label">Ledelse</label>
|
|
||||||
</div>
|
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
<div class="ms-2 col-sm-2 form-check form-switch">
|
||||||
<InputCheckbox id="supervisor" class="form-check-input" @bind-Value="AssignedRoles.Supervisor"/>
|
<InputCheckbox id="supervisor" class="form-check-input" @bind-Value="AssignedRoles.Supervisor"/>
|
||||||
<label for="supervisor" class="form-check-label">Supervisor</label>
|
<label for="supervisor" class="form-check-label">Supervisor</label>
|
||||||
|
@ -113,7 +98,35 @@
|
||||||
<InputCheckbox id="advisor" class="form-check-input" @bind-Value="AssignedRoles.Advisor"/>
|
<InputCheckbox id="advisor" class="form-check-input" @bind-Value="AssignedRoles.Advisor"/>
|
||||||
<label for="advisor" class="form-check-label">Sælger</label>
|
<label for="advisor" class="form-check-label">Sælger</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="ms-2 col-sm-2 form-check form-switch">
|
||||||
|
<InputCheckbox id="office" class="form-check-input" @bind-Value="AssignedRoles.Office"/>
|
||||||
|
<label for="office" class="form-check-label">Kontor</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="ms-2 col-sm-2 form-check form-switch">
|
||||||
|
<InputCheckbox id="warehouse" class="form-check-input" @bind-Value="AssignedRoles.Warehouse"/>
|
||||||
|
<label for="warehouse" class="form-check-label">Lager</label>
|
||||||
|
</div>
|
||||||
|
<div class="ms-2 col-sm-2 form-check form-switch">
|
||||||
|
<InputCheckbox id="management" class="form-check-input" @bind-Value="AssignedRoles.Management"/>
|
||||||
|
<label for="management" class="form-check-label">Ledelse</label>
|
||||||
|
</div>
|
||||||
|
<div class="ms-2 col-sm-2 form-check form-switch">
|
||||||
|
<InputCheckbox id="admin" class="form-check-input" @bind-Value="AssignedRoles.Admin"/>
|
||||||
|
<label for="admin" class="form-check-label">Administrator</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row @(_webShop && !string.IsNullOrWhiteSpace(CreateUserInput.CountryCode) ? "inno-display" : "inno-hidden")">
|
||||||
|
<div class="col-sm-10">
|
||||||
|
@_company.Name - @_company.Account - @_company.Phone
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<button type="button" class="btn btn-primary" @onclick="@ShowSearchOverlay">
|
||||||
|
Tilknyt kunde ...
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<a class="btn btn-primary" href="/system/users"><i class="bi-back"></i> Tilbage</a>
|
<a class="btn btn-primary" href="/system/users"><i class="bi-back"></i> Tilbage</a>
|
||||||
|
@ -130,14 +143,14 @@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<InputText id="newPasswd" class="form-control" @bind-Value="@PasswdInput.NewPassword" placeholder="Ny Adgangskode"/>
|
<InputText id="newPasswd" class="form-control" @bind-Value="@PasswdInput.NewPassword" placeholder="Ny Adgangskode"/>
|
||||||
<ValidationMessage For="@(() => PasswdInput.NewPassword)"></ValidationMessage>
|
<ValidationMessage For="@(() => CreateUserInput.NewPassword)"></ValidationMessage>
|
||||||
<label for="newPasswd">Ny Adgangskode</label>
|
<label for="newPasswd">Ny Adgangskode</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<InputText id="verifyPasswd" class="form-control" @bind-Value="@PasswdInput.ConfirmPassword" placeholder="Gentag Adgangskode"/>
|
<InputText id="verifyPasswd" class="form-control" @bind-Value="@PasswdInput.ConfirmPassword" placeholder="Gentag Adgangskode"/>
|
||||||
<ValidationMessage For="@(() => PasswdInput.ConfirmPassword)"></ValidationMessage>
|
<ValidationMessage For="@(() => CreateUserInput.ConfirmPassword)"></ValidationMessage>
|
||||||
<label for="verifyPasswd">Gentag Adgangskode</label>
|
<label for="verifyPasswd">Gentag Adgangskode</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -151,3 +164,5 @@
|
||||||
{
|
{
|
||||||
<WorkingThreeDots/>
|
<WorkingThreeDots/>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<CustomerSearchOverlay CountryCode="@CreateUserInput.CountryCode" OnSelected="@OnSelectCompany" @ref="SearchOverlay" />
|
|
@ -22,6 +22,7 @@ using Wonky.Client.Helpers;
|
||||||
using Wonky.Client.HttpInterceptors;
|
using Wonky.Client.HttpInterceptors;
|
||||||
using Wonky.Client.HttpRepository;
|
using Wonky.Client.HttpRepository;
|
||||||
using Wonky.Client.Models;
|
using Wonky.Client.Models;
|
||||||
|
using Wonky.Client.OverlaySystem;
|
||||||
using Wonky.Entity.DTO;
|
using Wonky.Entity.DTO;
|
||||||
|
|
||||||
#pragma warning disable CS8618
|
#pragma warning disable CS8618
|
||||||
|
@ -37,8 +38,9 @@ public partial class SystemUserCreatePage : IDisposable
|
||||||
[Inject] public IToastService Toaster { get; set; }
|
[Inject] public IToastService Toaster { get; set; }
|
||||||
|
|
||||||
// #############################################################
|
// #############################################################
|
||||||
private UserManagerCreateView NewUserInfo { get; set; } = new();
|
private CreateUserInputModel CreateUserInput { get; set; } = new();
|
||||||
private EditContext NewUserContext { get; set; }
|
private UserManagerCreateView CreateUserDto { get; set; } = new();
|
||||||
|
private EditContext FormContext { get; set; }
|
||||||
private bool ContextInvalid { get; set; } = true;
|
private bool ContextInvalid { get; set; } = true;
|
||||||
private bool Working { get; set; } = true;
|
private bool Working { get; set; } = true;
|
||||||
private bool ReadOnly { get; set; } = true;
|
private bool ReadOnly { get; set; } = true;
|
||||||
|
@ -47,16 +49,18 @@ public partial class SystemUserCreatePage : IDisposable
|
||||||
|
|
||||||
private readonly JsonSerializerOptions _options = new() { PropertyNameCaseInsensitive = true };
|
private readonly JsonSerializerOptions _options = new() { PropertyNameCaseInsensitive = true };
|
||||||
private bool _webShop;
|
private bool _webShop;
|
||||||
|
private CompanyDto _company = new();
|
||||||
|
private CustomerSearchOverlay SearchOverlay { get; set; }
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
Interceptor.RegisterEvent();
|
Interceptor.RegisterEvent();
|
||||||
Interceptor.RegisterBeforeSendEvent();
|
Interceptor.RegisterBeforeSendEvent();
|
||||||
|
|
||||||
NewUserContext = new EditContext(NewUserInfo);
|
FormContext = new EditContext(CreateUserInput);
|
||||||
|
|
||||||
NewUserContext.OnFieldChanged += ContextHandleFieldChanged!;
|
FormContext.OnFieldChanged += ContextHandleFieldChanged!;
|
||||||
NewUserContext.OnValidationStateChanged += ContextValidationChanged;
|
FormContext.OnValidationStateChanged += ContextValidationChanged;
|
||||||
Working = false;
|
Working = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,15 +70,33 @@ public partial class SystemUserCreatePage : IDisposable
|
||||||
ReadOnly = true;
|
ReadOnly = true;
|
||||||
Working = true;
|
Working = true;
|
||||||
|
|
||||||
NewUserInfo.AssignedRoles = Utils.MapSaveAssignedRoles(AssignedRoles);
|
CreateUserInput.AssignedRoles = Utils.MapSaveAssignedRoles(AssignedRoles);
|
||||||
|
CreateUserInput.EShop = _webShop;
|
||||||
|
CreateUserInput.CompanyId = !_webShop ? "" : _company.CompanyId;
|
||||||
|
|
||||||
Toaster.ShowInfo("Sender data til server ...");
|
Toaster.ShowInfo("Sender data til server ...");
|
||||||
await UserRepo.CreateUser(NewUserInfo);
|
|
||||||
|
CreateUserDto = Mapper.MapCreateUser(CreateUserInput);
|
||||||
|
|
||||||
|
await UserRepo.CreateUser(CreateUserDto);
|
||||||
|
|
||||||
Working = false;
|
Working = false;
|
||||||
Toaster.ShowInfo("Bruger er oprettet ...");
|
Toaster.ShowInfo("Bruger er oprettet ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ShowSearchOverlay()
|
||||||
|
{
|
||||||
|
SearchOverlay.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSelectCompany(CompanyDto company)
|
||||||
|
{
|
||||||
|
_company = company;
|
||||||
|
CreateUserInput.CompanyId = _company.CompanyId;
|
||||||
|
SearchOverlay.Hide();
|
||||||
|
}
|
||||||
|
|
||||||
private void ContextHandleFieldChanged(object? sender, FieldChangedEventArgs e)
|
private void ContextHandleFieldChanged(object? sender, FieldChangedEventArgs e)
|
||||||
{
|
{
|
||||||
Logger.LogDebug("contextHandleFieldChanged => e.FieldIdentifier.FieldName {}", e.FieldIdentifier.FieldName);
|
Logger.LogDebug("contextHandleFieldChanged => e.FieldIdentifier.FieldName {}", e.FieldIdentifier.FieldName);
|
||||||
|
@ -103,9 +125,7 @@ public partial class SystemUserCreatePage : IDisposable
|
||||||
_webShop = false;
|
_webShop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContextInvalid = !FormContext.Validate();
|
||||||
NewUserInfo.Passwd = PasswdInput.NewPassword;
|
|
||||||
ContextInvalid = !NewUserContext.Validate();
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,20 +134,20 @@ public partial class SystemUserCreatePage : IDisposable
|
||||||
{
|
{
|
||||||
ContextInvalid = true;
|
ContextInvalid = true;
|
||||||
|
|
||||||
NewUserContext.OnFieldChanged -= ContextHandleFieldChanged;
|
FormContext.OnFieldChanged -= ContextHandleFieldChanged;
|
||||||
NewUserContext.OnValidationStateChanged -= ContextValidationChanged;
|
FormContext.OnValidationStateChanged -= ContextValidationChanged;
|
||||||
|
|
||||||
NewUserContext = new EditContext(NewUserInfo);
|
FormContext = new EditContext(CreateUserInput);
|
||||||
|
|
||||||
NewUserContext.OnFieldChanged += ContextHandleFieldChanged;
|
FormContext.OnFieldChanged += ContextHandleFieldChanged;
|
||||||
NewUserContext.OnValidationStateChanged += ContextValidationChanged;
|
FormContext.OnValidationStateChanged += ContextValidationChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Interceptor.DisposeEvent();
|
Interceptor.DisposeEvent();
|
||||||
NewUserContext.OnFieldChanged -= ContextHandleFieldChanged!;
|
FormContext.OnFieldChanged -= ContextHandleFieldChanged!;
|
||||||
NewUserContext.OnValidationStateChanged -= ContextValidationChanged;
|
FormContext.OnValidationStateChanged -= ContextValidationChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -114,26 +114,10 @@
|
||||||
<th scope="col">Roller</th>
|
<th scope="col">Roller</th>
|
||||||
<td colspan="5">
|
<td colspan="5">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
|
||||||
<InputCheckbox id="admin" class="form-check-input" @bind-Value="AssignedRoles.Admin"/>
|
|
||||||
<label for="admin" class="form-check-label">Administrator</label>
|
|
||||||
</div>
|
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
|
||||||
<InputCheckbox id="warehouse" class="form-check-input" @bind-Value="AssignedRoles.Warehouse"/>
|
|
||||||
<label for="warehouse" class="form-check-label">Lager</label>
|
|
||||||
</div>
|
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
|
||||||
<InputCheckbox id="office" class="form-check-input" @bind-Value="AssignedRoles.Office"/>
|
|
||||||
<label for="office" class="form-check-label">Kontor</label>
|
|
||||||
</div>
|
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
<div class="ms-2 col-sm-2 form-check form-switch">
|
||||||
<InputCheckbox id="eshop" class="form-check-input" @bind-Value="AssignedRoles.EShop"/>
|
<InputCheckbox id="eshop" class="form-check-input" @bind-Value="AssignedRoles.EShop"/>
|
||||||
<label for="eshop" class="form-check-label">WebShop Kunde</label>
|
<label for="eshop" class="form-check-label">WebShop Kunde</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
|
||||||
<InputCheckbox id="management" class="form-check-input" @bind-Value="AssignedRoles.Management"/>
|
|
||||||
<label for="management" class="form-check-label">Ledelse</label>
|
|
||||||
</div>
|
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
<div class="ms-2 col-sm-2 form-check form-switch">
|
||||||
<InputCheckbox id="supervisor" class="form-check-input" @bind-Value="AssignedRoles.Supervisor"/>
|
<InputCheckbox id="supervisor" class="form-check-input" @bind-Value="AssignedRoles.Supervisor"/>
|
||||||
<label for="supervisor" class="form-check-label">Supervisor</label>
|
<label for="supervisor" class="form-check-label">Supervisor</label>
|
||||||
|
@ -142,6 +126,22 @@
|
||||||
<InputCheckbox id="advisor" class="form-check-input" @bind-Value="AssignedRoles.Advisor"/>
|
<InputCheckbox id="advisor" class="form-check-input" @bind-Value="AssignedRoles.Advisor"/>
|
||||||
<label for="advisor" class="form-check-label">Sælger</label>
|
<label for="advisor" class="form-check-label">Sælger</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="ms-2 col-sm-2 form-check form-switch">
|
||||||
|
<InputCheckbox id="office" class="form-check-input" @bind-Value="AssignedRoles.Office"/>
|
||||||
|
<label for="office" class="form-check-label">Kontor</label>
|
||||||
|
</div>
|
||||||
|
<div class="ms-2 col-sm-2 form-check form-switch">
|
||||||
|
<InputCheckbox id="warehouse" class="form-check-input" @bind-Value="AssignedRoles.Warehouse"/>
|
||||||
|
<label for="warehouse" class="form-check-label">Lager</label>
|
||||||
|
</div>
|
||||||
|
<div class="ms-2 col-sm-2 form-check form-switch">
|
||||||
|
<InputCheckbox id="management" class="form-check-input" @bind-Value="AssignedRoles.Management"/>
|
||||||
|
<label for="management" class="form-check-label">Ledelse</label>
|
||||||
|
</div>
|
||||||
|
<div class="ms-2 col-sm-2 form-check form-switch">
|
||||||
|
<InputCheckbox id="admin" class="form-check-input" @bind-Value="AssignedRoles.Admin"/>
|
||||||
|
<label for="admin" class="form-check-label">Administrator</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
|
body {
|
||||||
body {
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +19,7 @@ body {
|
||||||
.action-link-element {
|
.action-link-element {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.i-larger {
|
.i-larger {
|
||||||
font-size: 1.3rem;
|
font-size: 1.3rem;
|
||||||
}
|
}
|
||||||
|
@ -118,9 +118,6 @@ a, .btn-link {
|
||||||
.the-dead-bg {
|
.the-dead-bg {
|
||||||
background-color: black;
|
background-color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* end state elements */
|
/* end state elements */
|
||||||
|
|
||||||
/* led elements */
|
/* led elements */
|
||||||
|
|
|
@ -22,10 +22,8 @@ namespace Wonky.Entity.DTO;
|
||||||
public class UserManagerCreateView
|
public class UserManagerCreateView
|
||||||
{
|
{
|
||||||
[MaxLength(128)] public string CompanyId { get; set; } = "";
|
[MaxLength(128)] public string CompanyId { get; set; } = "";
|
||||||
[MaxLength(128)] public string ContactId { get; set; } = "";
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "Landekode skal udfyldes")]
|
[Required(ErrorMessage = "Land skal angives")]
|
||||||
[MaxLength(2, ErrorMessage = "Landekode er 2 bogstaver")]
|
|
||||||
public string CountryCode { get; set; } = "";
|
public string CountryCode { get; set; } = "";
|
||||||
|
|
||||||
[MaxLength(128, ErrorMessage = "Kort beskrivelse på højst 128 tegn.")]
|
[MaxLength(128, ErrorMessage = "Kort beskrivelse på højst 128 tegn.")]
|
||||||
|
|
Loading…
Reference in a new issue