WIP system user create web shop user
This commit is contained in:
parent
5258adfa07
commit
ff9d9ae3c5
14 changed files with 217 additions and 236 deletions
|
@ -60,7 +60,7 @@
|
||||||
<td class="align-middle state">
|
<td class="align-middle state">
|
||||||
@if (activity.Lines.Any() && activity.StatusTypeEnum == "Order")
|
@if (activity.Lines.Any() && activity.StatusTypeEnum == "Order")
|
||||||
{
|
{
|
||||||
<ProcessStateComponent StateClass="@Utils.MapProcessStatus(activity.ProcessStatusEnum)"/>
|
<ProcessStateComponent StateClass="@Mapper.MapProcessStatus(activity.ProcessStatusEnum)"/>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle font-monospace text-sm-start">@activity.ESalesNumber</td>
|
<td class="align-middle font-monospace text-sm-start">@activity.ESalesNumber</td>
|
||||||
|
|
|
@ -36,10 +36,10 @@
|
||||||
{
|
{
|
||||||
<tr @onclick="@(() => { ViewCustomer(company.CompanyId); })" class="action-link-element">
|
<tr @onclick="@(() => { ViewCustomer(company.CompanyId); })" class="action-link-element">
|
||||||
<td class="state align-middle">
|
<td class="state align-middle">
|
||||||
<DisplayStateComponent StateClass="@(company.HasFolded == 1 ? "the-dead" : Utils.MapVisitState(company.NextVisit))"/>
|
<DisplayStateComponent StateClass="@(company.HasFolded == 1 ? "the-dead" : Mapper.MapVisitState(company.NextVisit))"/>
|
||||||
</td>
|
</td>
|
||||||
<td class="state align-middle">
|
<td class="state align-middle">
|
||||||
<DisplayStateComponent StateClass="@(Utils.MapOrgState(company.ValidVat))"/>
|
<DisplayStateComponent StateClass="@(Mapper.MapOrgState(company.ValidVat))"/>
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
@if (!string.IsNullOrWhiteSpace(company.Note))
|
@if (!string.IsNullOrWhiteSpace(company.Note))
|
||||||
|
|
|
@ -59,13 +59,13 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Sidst besøgt</th>
|
<th scope="row">Sidst besøgt</th>
|
||||||
<td>
|
<td>
|
||||||
@(Utils.MapVisitState(company.LastVisit) == "the-draw" ? "?" : company.LastVisit)
|
@(Mapper.MapVisitState(company.LastVisit) == "the-draw" ? "?" : company.LastVisit)
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Næste besøg</th>
|
<th scope="row">Næste besøg</th>
|
||||||
<td>
|
<td>
|
||||||
@(Utils.MapVisitState(company.LastVisit) == "the-draw" ? "?" : company.NextVisit)
|
@(Mapper.MapVisitState(company.LastVisit) == "the-draw" ? "?" : company.NextVisit)
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
<td class="align-middle state">
|
<td class="align-middle state">
|
||||||
@if (activity.Lines.Any() && activity.StatusTypeEnum == "Order")
|
@if (activity.Lines.Any() && activity.StatusTypeEnum == "Order")
|
||||||
{
|
{
|
||||||
<ProcessStateComponent StateClass="@Utils.MapProcessStatus(activity.ProcessStatusEnum)"/>
|
<ProcessStateComponent StateClass="@Mapper.MapProcessStatus(activity.ProcessStatusEnum)"/>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
<td class="align-middle state">
|
<td class="align-middle state">
|
||||||
@if (activity.Lines.Any() && activity.StatusTypeEnum == "Order")
|
@if (activity.Lines.Any() && activity.StatusTypeEnum == "Order")
|
||||||
{
|
{
|
||||||
<ProcessStateComponent StateClass="@Utils.MapProcessStatus(activity.ProcessStatusEnum)"/>
|
<ProcessStateComponent StateClass="@Mapper.MapProcessStatus(activity.ProcessStatusEnum)"/>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -1,43 +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 Wonky.Client.Models;
|
|
||||||
using Wonky.Entity.DTO;
|
|
||||||
|
|
||||||
namespace Wonky.Client.Helpers;
|
|
||||||
|
|
||||||
public class MapUtils
|
|
||||||
{
|
|
||||||
public static ManagerNewUserDto MapCreateUser(NewUserForm model)
|
|
||||||
{
|
|
||||||
return new ManagerNewUserDto
|
|
||||||
{
|
|
||||||
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 = ""
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,7 +12,7 @@ public class Mapper
|
||||||
{
|
{
|
||||||
Description = model.Description,
|
Description = model.Description,
|
||||||
Email = model.Email,
|
Email = model.Email,
|
||||||
Passwd = model.NewPassword,
|
Passwd = model.PasswordInput.NewPassword,
|
||||||
AssignedRoles = model.AssignedRoles,
|
AssignedRoles = model.AssignedRoles,
|
||||||
CompanyId = model.CompanyId,
|
CompanyId = model.CompanyId,
|
||||||
CountryCode = model.CountryCode,
|
CountryCode = model.CountryCode,
|
||||||
|
@ -26,4 +26,95 @@ public class Mapper
|
||||||
UserId = ""
|
UserId = ""
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string MapOrgState(int validVat)
|
||||||
|
{
|
||||||
|
return validVat == 0 ? "no-vat" : "the-good";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static string MapVisitState(string dtNextVisit)
|
||||||
|
{
|
||||||
|
if (dtNextVisit is "0001-01-01" or "1970-01-01" or "2010-01-01" or "2020-01-01")
|
||||||
|
return "the-draw";
|
||||||
|
if (!DateTime.TryParse(dtNextVisit, out _))
|
||||||
|
return "the-draw";
|
||||||
|
|
||||||
|
var dtNow = DateTime.Now;
|
||||||
|
var dtNext = DateTime.Parse(dtNextVisit);
|
||||||
|
if (dtNow > dtNext)
|
||||||
|
return "the-ugly";
|
||||||
|
|
||||||
|
return dtNow > dtNext.AddDays(-14) ? "the-bad" : "the-good";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static string MapProcessStatus(string processStatus)
|
||||||
|
{
|
||||||
|
return processStatus.ToLower() switch
|
||||||
|
{
|
||||||
|
"express" => "the-fast",
|
||||||
|
"none" => "the-good",
|
||||||
|
"picked" => "the-bad",
|
||||||
|
"packed" => "the-ugly",
|
||||||
|
"shipped" => "the-dead",
|
||||||
|
"printed" => "printed",
|
||||||
|
_ => "question"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static List<UserRoleAssignment> MapSaveAssignedRoles(RoleAssignment model)
|
||||||
|
{
|
||||||
|
return new List<UserRoleAssignment>()
|
||||||
|
{
|
||||||
|
new() { Name = "Admin", Assigned = model.Admin },
|
||||||
|
new() { Name = "Advisor", Assigned = model.Advisor },
|
||||||
|
new() { Name = "EDoc", Assigned = model.EDoc },
|
||||||
|
new() { Name = "EShop", Assigned = model.EShop },
|
||||||
|
new() { Name = "Management", Assigned = model.Management },
|
||||||
|
new() { Name = "Office", Assigned = model.Office },
|
||||||
|
new() { Name = "Supervisor", Assigned = model.Supervisor },
|
||||||
|
new() { Name = "Warehouse", Assigned = model.Warehouse }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static RoleAssignment MapEditAssignedRoles(UserManagerEditView model)
|
||||||
|
{
|
||||||
|
var x = new RoleAssignment();
|
||||||
|
foreach (var role in model.AssignedRoles)
|
||||||
|
{
|
||||||
|
switch (role.Name.ToLower())
|
||||||
|
{
|
||||||
|
case "admin":
|
||||||
|
x.Admin = role.Assigned;
|
||||||
|
break;
|
||||||
|
case "advisor":
|
||||||
|
x.Advisor = role.Assigned;
|
||||||
|
break;
|
||||||
|
case "edoc":
|
||||||
|
x.EDoc = role.Assigned;
|
||||||
|
break;
|
||||||
|
case "eshop":
|
||||||
|
x.EShop = role.Assigned;
|
||||||
|
break;
|
||||||
|
case "management":
|
||||||
|
x.Management = role.Assigned;
|
||||||
|
break;
|
||||||
|
case "office":
|
||||||
|
x.Office = role.Assigned;
|
||||||
|
break;
|
||||||
|
case "supervisor":
|
||||||
|
x.Supervisor = role.Assigned;
|
||||||
|
break;
|
||||||
|
case "warehouse":
|
||||||
|
x.Warehouse = role.Assigned;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -158,60 +158,6 @@ public static class Utils
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<UserRoleAssignment> MapSaveAssignedRoles(RoleAssignment model)
|
|
||||||
{
|
|
||||||
return new List<UserRoleAssignment>()
|
|
||||||
{
|
|
||||||
new() { Name = "Admin", Assigned = model.Admin },
|
|
||||||
new() { Name = "Advisor", Assigned = model.Advisor },
|
|
||||||
new() { Name = "EDoc", Assigned = model.EDoc },
|
|
||||||
new() { Name = "EShop", Assigned = model.EShop },
|
|
||||||
new() { Name = "Management", Assigned = model.Management },
|
|
||||||
new() { Name = "Office", Assigned = model.Office },
|
|
||||||
new() { Name = "Supervisor", Assigned = model.Supervisor },
|
|
||||||
new() { Name = "Warehouse", Assigned = model.Warehouse }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static RoleAssignment MapEditAssignedRoles(UserManagerEditView model)
|
|
||||||
{
|
|
||||||
var x = new RoleAssignment();
|
|
||||||
foreach (var role in model.AssignedRoles)
|
|
||||||
{
|
|
||||||
switch (role.Name.ToLower())
|
|
||||||
{
|
|
||||||
case "admin":
|
|
||||||
x.Admin = role.Assigned;
|
|
||||||
break;
|
|
||||||
case "advisor":
|
|
||||||
x.Advisor = role.Assigned;
|
|
||||||
break;
|
|
||||||
case "edoc":
|
|
||||||
x.EDoc = role.Assigned;
|
|
||||||
break;
|
|
||||||
case "eshop":
|
|
||||||
x.EShop = role.Assigned;
|
|
||||||
break;
|
|
||||||
case "management":
|
|
||||||
x.Management = role.Assigned;
|
|
||||||
break;
|
|
||||||
case "office":
|
|
||||||
x.Office = role.Assigned;
|
|
||||||
break;
|
|
||||||
case "supervisor":
|
|
||||||
x.Supervisor = role.Assigned;
|
|
||||||
break;
|
|
||||||
case "warehouse":
|
|
||||||
x.Warehouse = role.Assigned;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static string StringToDigits(string digitString)
|
public static string StringToDigits(string digitString)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(digitString))
|
if (string.IsNullOrWhiteSpace(digitString))
|
||||||
|
@ -332,41 +278,4 @@ public static class Utils
|
||||||
{
|
{
|
||||||
return DateTime.Now.ToFileTimeUtc().GetHashCode();
|
return DateTime.Now.ToFileTimeUtc().GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static string MapOrgState(int validVat)
|
|
||||||
{
|
|
||||||
return validVat == 0 ? "no-vat" : "the-good";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static string MapVisitState(string dtNextVisit)
|
|
||||||
{
|
|
||||||
if (dtNextVisit is "0001-01-01" or "1970-01-01" or "2010-01-01" or "2020-01-01")
|
|
||||||
return "the-draw";
|
|
||||||
if (!DateTime.TryParse(dtNextVisit, out _))
|
|
||||||
return "the-draw";
|
|
||||||
|
|
||||||
var dtNow = DateTime.Now;
|
|
||||||
var dtNext = DateTime.Parse(dtNextVisit);
|
|
||||||
if (dtNow > dtNext)
|
|
||||||
return "the-ugly";
|
|
||||||
|
|
||||||
return dtNow > dtNext.AddDays(-14) ? "the-bad" : "the-good";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static string MapProcessStatus(string processStatus)
|
|
||||||
{
|
|
||||||
return processStatus.ToLower() switch
|
|
||||||
{
|
|
||||||
"express" => "the-fast",
|
|
||||||
"none" => "the-good",
|
|
||||||
"picked" => "the-bad",
|
|
||||||
"packed" => "the-ugly",
|
|
||||||
"shipped" => "the-dead",
|
|
||||||
"printed" => "printed",
|
|
||||||
_ => "question"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -30,11 +30,11 @@ public class NewUserForm
|
||||||
|
|
||||||
public bool LockoutEnabled { get; set; }
|
public bool LockoutEnabled { get; set; }
|
||||||
|
|
||||||
[Required(ErrorMessage = "AdgangsKode skal udfyldes")]
|
// [Required(ErrorMessage = "AdgangsKode skal udfyldes")]
|
||||||
public string NewPassword { get; set; } = "";
|
// public string NewPassword { get; set; } = "";
|
||||||
|
//
|
||||||
[Compare(nameof(NewPassword), ErrorMessage = "Adgangskoder er ikke ens.")]
|
// [Compare(nameof(NewPassword), ErrorMessage = "Adgangskoder er ikke ens.")]
|
||||||
public string ConfirmPassword { get; set; } = "";
|
// public string ConfirmPassword { get; set; } = "";
|
||||||
|
|
||||||
[MaxLength(20, ErrorMessage = "Der er afsat 20 tegn til telefon nummber")]
|
[MaxLength(20, ErrorMessage = "Der er afsat 20 tegn til telefon nummber")]
|
||||||
public string PhoneNumber { get; set; } = "";
|
public string PhoneNumber { get; set; } = "";
|
||||||
|
@ -43,4 +43,5 @@ public class NewUserForm
|
||||||
public string SalesRep { get; set; } = "";
|
public string SalesRep { get; set; } = "";
|
||||||
|
|
||||||
public List<UserRoleAssignment> AssignedRoles { get; set; } = new();
|
public List<UserRoleAssignment> AssignedRoles { get; set; } = new();
|
||||||
|
public PasswordInput PasswordInput { get; set; } = new();
|
||||||
}
|
}
|
|
@ -18,8 +18,8 @@
|
||||||
<div class="modal" tabindex="-1" role="dialog" style="display:@_modalDisplay">
|
<div class="modal" tabindex="-1" role="dialog" style="display:@_modalDisplay">
|
||||||
<div class="modal-dialog modal-dialog-scrollable modal-fullscreen">
|
<div class="modal-dialog modal-dialog-scrollable modal-fullscreen">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header alert alert-info">
|
||||||
<h5 class="modal-title">Pris Katalog</h5>
|
<h5 class="modal-title">Kunde liste</h5>
|
||||||
<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">
|
||||||
|
|
|
@ -184,7 +184,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
|
||||||
/*
|
/*
|
||||||
* display urgency of next visit
|
* display urgency of next visit
|
||||||
*/
|
*/
|
||||||
_visitStateCss = Utils.MapVisitState($"{_nextVisit:yyyy-MM-dd}");
|
_visitStateCss = Mapper.MapVisitState($"{_nextVisit:yyyy-MM-dd}");
|
||||||
/*
|
/*
|
||||||
* handle InfoDrawer.Company out of business case
|
* handle InfoDrawer.Company out of business case
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,15 +21,47 @@
|
||||||
|
|
||||||
@page "/system/users/create"
|
@page "/system/users/create"
|
||||||
|
|
||||||
|
<PageTitle>Opret Bruger - Administration</PageTitle>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header bg-dark text-white">
|
<div class="card-header bg-dark text-white">
|
||||||
<div class="mt-3 h3 card-title">
|
<div class="mt-3 h3 card-title">
|
||||||
System Bruger Oprettelse
|
Opret Bruger
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<EditForm EditContext="FormContext" OnValidSubmit="PostNewUser">
|
<EditForm EditContext="FormContext" OnValidSubmit="PostNewUser">
|
||||||
<DataAnnotationsValidator/>
|
<DataAnnotationsValidator/>
|
||||||
|
<div class="row mb-3 ps-3">
|
||||||
|
<div class="col-sm-3 form-check form-switch">
|
||||||
|
<InputCheckbox id="eshop" class="form-check-input" @bind-Value="AssignedRoles.EShop"/>
|
||||||
|
<label for="eshop" class="form-check-label">WebShop Kunde</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3 form-check form-switch">
|
||||||
|
<InputCheckbox id="supervisor" class="form-check-input" @bind-Value="AssignedRoles.Supervisor"/>
|
||||||
|
<label for="supervisor" class="form-check-label">Supervisor</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3 form-check form-switch">
|
||||||
|
<InputCheckbox id="advisor" class="form-check-input" @bind-Value="AssignedRoles.Advisor"/>
|
||||||
|
<label for="advisor" class="form-check-label">Sælger</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3 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="col-sm-3 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="col-sm-3 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="col-sm-3 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 g-3 mb-3">
|
<div class="row g-3 mb-3">
|
||||||
@* firstName *@
|
@* firstName *@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
@ -65,66 +97,72 @@
|
||||||
</div>
|
</div>
|
||||||
@* salesRep *@
|
@* salesRep *@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
<div class="@(!UserForm.EShop ? "inno-display" : "inno-hidden")">
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<InputText id="salesRep" class="form-control" @bind-Value="UserForm.SalesRep" placeholder="Sælger"/>
|
<InputText id="salesRep" class="form-control" @bind-Value="UserForm.SalesRep" placeholder="Sælger"/>
|
||||||
<ValidationMessage For="@(() => UserForm.SalesRep)"></ValidationMessage>
|
<ValidationMessage For="@(() => UserForm.SalesRep)"></ValidationMessage>
|
||||||
<label for="salesRep">Sælger</label>
|
<label for="salesRep">Sælger</label>
|
||||||
</div>
|
</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="UserForm.CountryCode" placeholder="Landekode">
|
<InputSelect id="countryCode" class="form-control" @bind-Value="UserForm.CountryCode" placeholder="Landekode">
|
||||||
<option value="" disabled>Klik for valg</option>
|
<option value="" disabled>Vælg Land</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="@(() => UserForm.CountryCode)"></ValidationMessage>
|
<ValidationMessage For="@(() => UserForm.CountryCode)"></ValidationMessage>
|
||||||
<label for="countryCode">Landekode</label>
|
<label for="countryCode">Lande</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-floating">
|
||||||
|
<InputText id="newPassword" class="form-control" @bind-Value="@UserForm.PasswordInput.NewPassword" placeholder="Ny Adgangskode"/>
|
||||||
|
<ValidationMessage For="@(() => UserForm.PasswordInput.NewPassword)"></ValidationMessage>
|
||||||
|
<label for="newPassword">Ny Adgangskode</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
|
||||||
<InputCheckbox id="eshop" class="form-check-input" @bind-Value="AssignedRoles.EShop"/>
|
|
||||||
<label for="eshop" class="form-check-label">WebShop Kunde</label>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
<div class="col-sm-6">
|
||||||
<InputCheckbox id="supervisor" class="form-check-input" @bind-Value="AssignedRoles.Supervisor"/>
|
<div class="form-floating">
|
||||||
<label for="supervisor" class="form-check-label">Supervisor</label>
|
<InputText id="verifyPassword" class="form-control" @bind-Value="@UserForm.PasswordInput.ConfirmPassword" placeholder="Gentag Adgangskode"/>
|
||||||
|
<ValidationMessage For="@(() => UserForm.PasswordInput.ConfirmPassword)"></ValidationMessage>
|
||||||
|
<label for="verifyPassword">Gentag Adgangskode</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="ms-2 col-sm-2 form-check form-switch">
|
|
||||||
<InputCheckbox id="advisor" class="form-check-input" @bind-Value="AssignedRoles.Advisor"/>
|
|
||||||
<label for="advisor" class="form-check-label">Sælger</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">
|
|
||||||
<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>
|
</div>
|
||||||
|
|
||||||
<div class="row @(UserForm.EShop && !string.IsNullOrWhiteSpace(UserForm.CountryCode) ? "inno-display" : "inno-hidden")">
|
<div class="@(UserForm.EShop && !string.IsNullOrWhiteSpace(UserForm.CountryCode) ? "inno-display" : "inno-hidden")">
|
||||||
<div class="col-sm-10">
|
<div class="row mb-3">
|
||||||
@_company.Name - @_company.Account - @_company.Phone
|
<div class="col-sm-6">
|
||||||
|
@if (!string.IsNullOrWhiteSpace(_company.Name))
|
||||||
|
{
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Tilknyttet kunde</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>@_company.Account</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>@_company.Name</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>@_company.Phone</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-6">
|
||||||
<button type="button" class="btn btn-primary" @onclick="@ShowCompanySearchOverlay">
|
<button type="button" class="btn btn-primary" @onclick="@ShowCompanySearchOverlay">
|
||||||
Tilknyt kunde ...
|
Tilknyt kunde ...
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
|
@ -132,30 +170,15 @@
|
||||||
<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>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6 text-end">
|
<div class="col-sm-6 text-end">
|
||||||
<button type="submit" class="btn btn-primary" disabled="@ContextInvalid">Gem</button>
|
<button type="submit" class="btn btn-primary" disabled="@_formInvalid">Gem</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</EditForm>
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
<h4>Password politik</h4>
|
<h4>Password politik</h4>
|
||||||
<p>Mindst 10 tegn bestående af store og små bogstaver samt tal. Password generator <a href="https://pw.nix.dk">pw.nix.dk</a></p>
|
<p>Mindst 10 tegn bestående af store og små bogstaver samt tal. Password generator <a href="https://pw.nix.dk">pw.nix.dk</a></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="form-floating">
|
|
||||||
<InputText id="newPasswd" class="form-control" @bind-Value="@PasswdInput.NewPassword" placeholder="Ny Adgangskode"/>
|
|
||||||
<ValidationMessage For="@(() => UserForm.NewPassword)"></ValidationMessage>
|
|
||||||
<label for="newPasswd">Ny Adgangskode</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="form-floating">
|
|
||||||
<InputText id="verifyPasswd" class="form-control" @bind-Value="@PasswdInput.ConfirmPassword" placeholder="Gentag Adgangskode"/>
|
|
||||||
<ValidationMessage For="@(() => UserForm.ConfirmPassword)"></ValidationMessage>
|
|
||||||
<label for="verifyPasswd">Gentag Adgangskode</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</EditForm>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,9 @@ public partial class SystemUserCreatePage : IDisposable
|
||||||
private NewUserForm UserForm { get; set; } = new();
|
private NewUserForm UserForm { get; set; } = new();
|
||||||
private ManagerNewUserDto NewUserDto { get; set; } = new();
|
private ManagerNewUserDto NewUserDto { get; set; } = new();
|
||||||
private EditContext FormContext { get; set; }
|
private EditContext FormContext { get; set; }
|
||||||
private bool ContextInvalid { get; set; } = true;
|
private bool _formInvalid = true;
|
||||||
private bool Working { get; set; } = true;
|
private bool Working { get; set; } = true;
|
||||||
private bool ReadOnly { get; set; } = true;
|
private bool _readOnly;
|
||||||
private PasswordInput PasswdInput { get; set; } = new();
|
private PasswordInput PasswdInput { get; set; } = new();
|
||||||
private RoleAssignment AssignedRoles { get; set; } = new();
|
private RoleAssignment AssignedRoles { get; set; } = new();
|
||||||
|
|
||||||
|
@ -57,9 +57,8 @@ public partial class SystemUserCreatePage : IDisposable
|
||||||
Interceptor.RegisterBeforeSendEvent();
|
Interceptor.RegisterBeforeSendEvent();
|
||||||
|
|
||||||
FormContext = new EditContext(UserForm);
|
FormContext = new EditContext(UserForm);
|
||||||
|
|
||||||
FormContext.OnFieldChanged += ContextHandleFieldChanged;
|
FormContext.OnFieldChanged += ContextHandleFieldChanged;
|
||||||
FormContext.OnValidationStateChanged += ContextValidationChanged;
|
FormContext.OnValidationStateChanged += ContextValidationChanged!;
|
||||||
|
|
||||||
Working = false;
|
Working = false;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +76,7 @@ public partial class SystemUserCreatePage : IDisposable
|
||||||
/*
|
/*
|
||||||
* Make fields reaonly
|
* Make fields reaonly
|
||||||
*/
|
*/
|
||||||
ReadOnly = true;
|
_readOnly = true;
|
||||||
/*
|
/*
|
||||||
* Raise working flag
|
* Raise working flag
|
||||||
*/
|
*/
|
||||||
|
@ -85,15 +84,15 @@ public partial class SystemUserCreatePage : IDisposable
|
||||||
/*
|
/*
|
||||||
* ensure companyId is set correct
|
* ensure companyId is set correct
|
||||||
*/
|
*/
|
||||||
UserForm.CompanyId = !UserForm.EShop ? "" : _company.CompanyId;
|
UserForm.CompanyId = UserForm.EShop ? _company.CompanyId : "";
|
||||||
/*
|
/*
|
||||||
* Map RoleAssignment
|
* Map RoleAssignment
|
||||||
*/
|
*/
|
||||||
UserForm.AssignedRoles = Utils.MapSaveAssignedRoles(AssignedRoles);
|
UserForm.AssignedRoles = Mapper.MapSaveAssignedRoles(AssignedRoles);
|
||||||
/*
|
/*
|
||||||
* Map form input to a model the backend expects
|
* Map form input to a model the backend expects
|
||||||
*/
|
*/
|
||||||
NewUserDto = MapUtils.MapCreateUser(UserForm);
|
NewUserDto = Mapper.MapCreateUser(UserForm);
|
||||||
/*
|
/*
|
||||||
* Send Post Request
|
* Send Post Request
|
||||||
*/
|
*/
|
||||||
|
@ -142,7 +141,7 @@ public partial class SystemUserCreatePage : IDisposable
|
||||||
{
|
{
|
||||||
if (!Utils.IsValidPasswd(PasswdInput.NewPassword))
|
if (!Utils.IsValidPasswd(PasswdInput.NewPassword))
|
||||||
{
|
{
|
||||||
ContextInvalid = true;
|
_formInvalid = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +162,7 @@ public partial class SystemUserCreatePage : IDisposable
|
||||||
UserForm.EShop = false;
|
UserForm.EShop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextInvalid = !FormContext.Validate();
|
_formInvalid = !FormContext.Validate();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,17 +172,18 @@ public partial class SystemUserCreatePage : IDisposable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ContextValidationChanged(object? sender, ValidationStateChangedEventArgs e)
|
private void ContextValidationChanged(object sender, ValidationStateChangedEventArgs e)
|
||||||
{
|
{
|
||||||
ContextInvalid = true;
|
_formInvalid = false;
|
||||||
|
|
||||||
FormContext.OnFieldChanged -= ContextHandleFieldChanged;
|
FormContext.OnFieldChanged -= ContextHandleFieldChanged;
|
||||||
FormContext.OnValidationStateChanged -= ContextValidationChanged;
|
FormContext.OnValidationStateChanged -= ContextValidationChanged!;
|
||||||
|
|
||||||
FormContext = new EditContext(UserForm);
|
FormContext = new EditContext(UserForm);
|
||||||
|
|
||||||
FormContext.OnFieldChanged += ContextHandleFieldChanged;
|
FormContext.OnFieldChanged += ContextHandleFieldChanged;
|
||||||
FormContext.OnValidationStateChanged += ContextValidationChanged;
|
FormContext.OnValidationStateChanged += ContextValidationChanged!;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public partial class SystemUserViewEditPage : IDisposable
|
||||||
|
|
||||||
UserInfo = await UserRepo.GetUserInfo(UserId);
|
UserInfo = await UserRepo.GetUserInfo(UserId);
|
||||||
|
|
||||||
AssignedRoles = Utils.MapEditAssignedRoles(UserInfo);
|
AssignedRoles = Mapper.MapEditAssignedRoles(UserInfo);
|
||||||
|
|
||||||
UserEditContext = new EditContext(UserInfo);
|
UserEditContext = new EditContext(UserInfo);
|
||||||
PasswdContext = new EditContext(Passwords);
|
PasswdContext = new EditContext(Passwords);
|
||||||
|
@ -82,7 +82,7 @@ public partial class SystemUserViewEditPage : IDisposable
|
||||||
ReadOnly = true;
|
ReadOnly = true;
|
||||||
Working = true;
|
Working = true;
|
||||||
|
|
||||||
UserInfo.AssignedRoles = Utils.MapSaveAssignedRoles(AssignedRoles);
|
UserInfo.AssignedRoles = Mapper.MapSaveAssignedRoles(AssignedRoles);
|
||||||
|
|
||||||
Toaster.ShowInfo("Sender data til server ...");
|
Toaster.ShowInfo("Sender data til server ...");
|
||||||
await UserRepo.UpdateUserInfo(UserId, UserInfo);
|
await UserRepo.UpdateUserInfo(UserId, UserInfo);
|
||||||
|
|
Loading…
Reference in a new issue