Compare commits

..

No commits in common. "fec32f6642152dc22e0ec1c7aea2a07e9cb410ea" and "448428a756c98cd69bf5eace1c8fa201747589bb" have entirely different histories.

31 changed files with 484 additions and 393 deletions

View File

@ -12,7 +12,6 @@ using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
using AyCode.Core.Extensions; using AyCode.Core.Extensions;
using TIAM.Entities.ServiceProviders;
namespace TIAM.Database.Test namespace TIAM.Database.Test
{ {
@ -223,48 +222,6 @@ namespace TIAM.Database.Test
#endregion UserProductMapping #endregion UserProductMapping
#region Product
//[DataTestMethod]
//[DataRow(["e24f6942-2210-47d7-8660-ace0ef302bae", "8e6a4170-0e15-4f8a-bdd2-46f9dbc63b93", "540271F6-C604-4C16-8160-D5A7CAFEDF00", "49c7805b-d8cd-4308-b1c5-7a54e5ee6287"])]
public async Task ProductCrudTest(string[] productIdCompanyIdUserIdUserToCompanyIdStrings)
{
var productId = Guid.Parse(productIdCompanyIdUserIdUserToCompanyIdStrings[0]);
var companyId = Guid.Parse(productIdCompanyIdUserIdUserToCompanyIdStrings[1]);
var userId = Guid.Parse(productIdCompanyIdUserIdUserToCompanyIdStrings[2]); //test@tiam.hu
var userToCompanyId = Guid.Parse(productIdCompanyIdUserIdUserToCompanyIdStrings[3]);
await Dal.RemoveProductAsync(productId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
var company = new Company(companyId, "Test unit company...", null);
Assert.IsTrue(await Dal.AddCompanyAsync(company));
Assert.IsNotNull(company);
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNotNull(company);
Assert.IsTrue(company.UserToServiceProviders.Count == 0);
Assert.IsTrue(company.Id == companyId);
company.OwnerId = userId;
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNotNull(company);
Assert.IsNotNull(company.UserToServiceProviders);
Assert.IsTrue(company.UserToServiceProviders.Any(x=>x.UserId == userId && x.ServiceProviderId == companyId));
company.CommissionPercent = 5;
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
Assert.IsTrue(await Dal.RemoveCompanyAsync(company)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNull(company); //a korábbi törlés miatt NULL kell legyen - J.
}
#endregion Product
[DataTestMethod] [DataTestMethod]
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")] [DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
[DataRow("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd")] [DataRow("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd")]
@ -340,47 +297,6 @@ namespace TIAM.Database.Test
Assert.IsTrue(users.Count > 0); Assert.IsTrue(users.Count > 0);
} }
#region Company
[DataTestMethod]
[DataRow(["8e6a4170-0e15-4f8a-bdd2-46f9dbc63b93", "540271F6-C604-4C16-8160-D5A7CAFEDF00", "49c7805b-d8cd-4308-b1c5-7a54e5ee6287"])]
public async Task CompanyCrudTest(string[] companyIdUserIdUserToCompanyIdStrings)
{
var companyId = Guid.Parse(companyIdUserIdUserToCompanyIdStrings[0]);
var userId = Guid.Parse(companyIdUserIdUserToCompanyIdStrings[1]); //test@tiam.hu
var userToCompanyId = Guid.Parse(companyIdUserIdUserToCompanyIdStrings[2]);
await Dal.RemoveCompanyAsync(companyId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
var company = new Company(companyId, "Test unit company...", null);
Assert.IsTrue(await Dal.AddCompanyAsync(company));
Assert.IsNotNull(company);
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNotNull(company);
Assert.IsTrue(company.UserToServiceProviders.Count == 0);
Assert.IsTrue(company.Id == companyId);
company.OwnerId = userId;
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNotNull(company);
Assert.IsNotNull(company.UserToServiceProviders);
Assert.IsTrue(company.UserToServiceProviders.Any(x=>x.UserId == userId && x.ServiceProviderId == companyId));
company.CommissionPercent = 5;
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
Assert.IsTrue(await Dal.RemoveCompanyAsync(company)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNull(company); //a korábbi törlés miatt NULL kell legyen - J.
}
#endregion Company
#region Transfer #region Transfer
[DataTestMethod] [DataTestMethod]
[DataRow("6216f9fb-1dda-44bd-9d85-431f3cb09fde")] [DataRow("6216f9fb-1dda-44bd-9d85-431f3cb09fde")]

View File

@ -118,16 +118,14 @@ namespace TIAM.Database.DataLayers.Admins
public Task<bool> RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUser(userId)); public Task<bool> RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUser(userId));
public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers)); public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers));
public Task<Product?> GetProductByIdAsync(Guid contextId, bool includeUsers = true) => SessionAsync(ctx => ctx.GetProductById(contextId, includeUsers));
public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson()); public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson());
public List<Product> GetProductsByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByCompanyId(serviceProviderId, includeUsers).ToList()); public List<Product> GetProductsByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToList());
public string GetProductsJsonByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByCompanyId(serviceProviderId, includeUsers).ToJson()); public string GetProductsJsonByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToJson());
public Task<bool> AddProductAsync(Product product) => TransactionAsync(ctx => ctx.AddProduct(product)); public Task<bool> AddProductAsync(Product product) => TransactionAsync(ctx => ctx.AddProduct(product));
public Task<bool> UpdateProductAsync(Product product) => TransactionAsync(ctx => ctx.UpdateProduct(product)); public Task<bool> UpdateProductAsync(Product product) => TransactionAsync(ctx => ctx.UpdateProduct(product));
public Task<bool> RemoveProductAsync(Product product) => TransactionAsync(ctx => ctx.RemoveProduct(product)); public Task<bool> RemoveProductAsync(Product product) => TransactionAsync(ctx => ctx.RemoveProduct(product));
public Task<bool> RemoveProductAsync(Guid productId) => TransactionAsync(ctx => ctx.RemoveProduct(productId));
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude)); public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
public List<UserProductMapping>? GetAllUserProductMappings(bool autoInclude = true) => Session(ctx => ctx.UserProductMappings).ToList(); public List<UserProductMapping>? GetAllUserProductMappings(bool autoInclude = true) => Session(ctx => ctx.UserProductMappings).ToList();
@ -219,17 +217,26 @@ namespace TIAM.Database.DataLayers.Admins
#endregion EmailMessage #endregion EmailMessage
#region ServiceProviders
//15. (IServiceProviderDataService) Create service provider //15. (IServiceProviderDataService) Create service provider
public Task<bool> AddCompanyAsync(Company serviceProvider) => TransactionAsync(ctx => ctx.AddCompany<Company, Profile, Address>(serviceProvider)); public Task<bool> CreateServiceProviderAsync(Company serviceProvider) => TransactionAsync(ctx => ctx.AddServiceProvider<Company, Profile, Address>(serviceProvider));
public Task<List<Company>> GetCompaniesAsync() => SessionAsync(ctx => ctx.GetCompanies().ToList()); //public bool CreateProductAsync(Product product)
//{
// Context.CreateProduct(product);
// GlobalLogger.Info($@"Saving product to db {product.Id}, {product.Name}, {product.ServiceProviderId}");
// var result = Context.SaveChangesAsync();
// return result.Result > 0;
//}
public Task<string> GetCompaniesJsonAsync() => SessionAsync(ctx => ctx.Companies.ToJson()); public Task<List<Company>> GetServiceProvidersAsync() => SessionAsync(ctx => ctx.GetServiceProviders().ToList());
public string GetCompaniesJson() => Session(ctx => ctx.Companies.ToJson());
public Task<string> GetServiceProvidersJsonAsync() => SessionAsync(ctx => ctx.Companies.ToJson());
public string GetServiceProvidersJson() => Session(ctx => ctx.Companies.ToJson());
public virtual Task<Company?> GetCompanyByIdAsync(Guid id) => SessionAsync(ctx => ctx.GetCompanyById(id));
public virtual Task<List<Company>> GetCompaniesByOwnerIdAsync(Guid id) => SessionAsync(ctx => ctx.GetCompaniesByOwnerId(id));
public virtual Task<Company?> GetServiceProviderByIdAsync(Guid id) => SessionAsync(ctx => ctx.GetServiceProviderById(id));
public virtual Task<List<Company>> GetServiceProvidersByOwnerIdAsync(Guid id) => SessionAsync(ctx => ctx.GetServiceProvidersByOwnerId(id));
//public Task<UserProductMapping> CreateUserProductMappingAsync(UserProductMapping userProductMapping) //public Task<UserProductMapping> CreateUserProductMappingAsync(UserProductMapping userProductMapping)
//{ //{
@ -238,12 +245,17 @@ namespace TIAM.Database.DataLayers.Admins
// return Context.SaveChangesAsync().ContinueWith(x => userProductMapping); // return Context.SaveChangesAsync().ContinueWith(x => userProductMapping);
//} //}
//14. (IserviceProviderDataService) Update service provider #region ServiceProviders
public Task<bool> UpdateCompanyAsync(Company company) => TransactionAsync(ctx => ctx.UpdateCompany(company));
//13. (IserviceProviderDataService) delete service provider //14. (IserviceProviderDataService) Update service provider
public Task<bool> RemoveCompanyAsync(Guid companyId) => TransactionAsync(ctx => ctx.RemoveProductsByCompanyId(companyId) && ctx.RemoveCompany(companyId)); public Task<bool> UpdateCompanyAsync(Company company) => TransactionAsync(ctx => ctx.UpdateServiceProvider<Company, Profile, Address>(company));
//13. (IserviceProviderDataService) delete service provider
public Task<bool> RemoveCompanyAsync(Guid id) => TransactionAsync(ctx => ctx.RemoveServiceProvider(id));
public Task<bool> RemoveCompanyAsync(Company company) => TransactionAsync(ctx => ctx.RemoveServiceProvider(company));
public Task<bool> RemoveCompanyAsync(Company company) => RemoveCompanyAsync(company.Id);
#endregion #endregion
#region PermissionTypes #region PermissionTypes
@ -478,6 +490,17 @@ namespace TIAM.Database.DataLayers.Admins
#region Products #region Products
//* 21. (IServiceProviderDataService) delete product
public Task<bool> DeleteProductByIdAsync(Guid productId)
{
return TransactionAsync(ctx =>
{
ctx.DeleteProductById(productId);
return true;
});
}
//4. (IPermissionService) AssignPermissionToUserForContextAsync //4. (IPermissionService) AssignPermissionToUserForContextAsync
public Task<bool> AssignPermissionToUserForContextAsync(UserProductMapping userProductMapping, PermissionsType permission) public Task<bool> AssignPermissionToUserForContextAsync(UserProductMapping userProductMapping, PermissionsType permission)
{ {

View File

@ -21,9 +21,8 @@ namespace TIAM.Database.DbContexts.Admins
public DbSet<User> Users { get; set; } public DbSet<User> Users { get; set; }
public DbSet<Profile> Profiles { get; set; } public DbSet<Profile> Profiles { get; set; }
public DbSet<Company> Companies { get; set; } public DbSet<Company> Companies { get; set; }
public DbSet<UserToCompany> UserToCompanies { get; set; }
public DbSet<UserToken> UserTokens { get; set; } public DbSet<UserToken> UserTokens { get; set; }
public DbSet<TransferDestination> TransferDestinations { get; set; } public DbSet<TransferDestination> TransferDestinations { get; set; }
public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; } public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; }
public DbSet<Transfer> Transfers { get; set; } public DbSet<Transfer> Transfers { get; set; }

View File

@ -93,39 +93,39 @@ namespace TIAM.Database.DbContexts.Admins
return true; return true;
} }
//public static bool CreateProduct(this IAdminDbContext ctx, Product myproduct) public static bool CreateProduct(this IAdminDbContext ctx, Product myproduct)
//{ {
// if (myproduct == null) return false; if (myproduct == null) return false;
// //Automatically add assigneduser for owner //Automatically add assigneduser for owner
// Company? company = ctx.Companies.FirstOrDefault(x => x.Id == myproduct.ServiceProviderId); Company? company = ctx.Companies.FirstOrDefault(x => x.Id == myproduct.ServiceProviderId);
// if (company == null || company.OwnerId.IsNullOrEmpty()) return false; if (company == null || company.OwnerId.IsNullOrEmpty()) return false;
// var userProductMapping = new UserProductMapping(myproduct.Id, company.OwnerId.Value); var userProductMapping = new UserProductMapping(myproduct.Id, company.OwnerId.Value);
// ctx.CreateAssignedUser(userProductMapping); ctx.CreateAssignedUser(userProductMapping);
// ctx.AddProduct(myproduct); ctx.AddProduct(myproduct);
// return true; return true;
//} }
//public static bool CreateAssignedUser(this IAdminDbContext ctx, UserProductMapping userProductMapping) public static bool CreateAssignedUser(this IAdminDbContext ctx, UserProductMapping userProductMapping)
//{ {
// if (userProductMapping == null) return false; if (userProductMapping == null) return false;
// ctx.UserProductMappings.Add(userProductMapping); ctx.UserProductMappings.Add(userProductMapping);
// return true; return true;
//} }
//public static Company CreateServiceProvider(this IAdminDbContext ctx, Company serviceProvider) public static Company CreateServiceProvider(this IAdminDbContext ctx, Company serviceProvider)
//{ {
// if (serviceProvider == null || serviceProvider.OwnerId.IsNullOrEmpty()) return null; if (serviceProvider == null || serviceProvider.OwnerId.IsNullOrEmpty()) return null;
// ctx.Companies.Add(serviceProvider); ctx.Companies.Add(serviceProvider);
// var userProductMapping = new UserProductMapping(serviceProvider.Id, serviceProvider.OwnerId.Value); var userProductMapping = new UserProductMapping(serviceProvider.Id, serviceProvider.OwnerId.Value);
// ctx.CreateAssignedUser(userProductMapping); ctx.CreateAssignedUser(userProductMapping);
// return serviceProvider; return serviceProvider;
//} }
} }
} }

View File

@ -17,7 +17,6 @@ namespace TIAM.Database.DbContexts.ServiceProviders
public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; } public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; }
public DbSet<Company> Companies { get; set; } public DbSet<Company> Companies { get; set; }
public DbSet<UserToCompany> UserToCompanies { get; set; }
public DbSet<Profile> Profiles { get; set; } public DbSet<Profile> Profiles { get; set; }
public DbSet<User> Users { get; set; } public DbSet<User> Users { get; set; }

View File

@ -1,12 +1,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TIAM.Database.DbSets.Profiles;
using TIAM.Database.DbSets.Users;
using TIAM.Entities.Addresses;
using TIAM.Entities.Products; using TIAM.Entities.Products;
namespace TIAM.Database.DbSets.Products; namespace TIAM.Database.DbSets.Products;
public interface IProductDbSet : IProfileDbSet, IUserProductMappingDbSet public interface IProductDbSet
{ {
public DbSet<Product> Products { get; set; } public DbSet<Product> Products { get; set; }
} }

View File

@ -1,11 +1,6 @@
using AyCode.Core.Extensions; using AyCode.Core.Extensions;
using AyCode.Database.DbSets.Profiles;
using AyCode.Interfaces.Addresses;
using AyCode.Interfaces.Profiles;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TIAM.Entities.Addresses;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Profiles;
namespace TIAM.Database.DbSets.Products; namespace TIAM.Database.DbSets.Products;
@ -24,29 +19,8 @@ public static class ProductDbSetExtensions
=> ctx.Products.Update(product).State == EntityState.Modified; => ctx.Products.Update(product).State == EntityState.Modified;
public static bool RemoveProduct(this IProductDbSet ctx, Product product) public static bool RemoveProduct(this IProductDbSet ctx, Product product)
{ => ctx.Products.Remove(product).State == EntityState.Deleted;
ctx.RemoveProfile(product.ProfileId);
ctx.UserProductMappings.RemoveRange(ctx.UserProductMappings.Where(x => x.ProductId == product.Id));
//TODO: Transfer, etc... - J.
return ctx.Products.Remove(product).State == EntityState.Deleted;
}
public static bool RemoveProduct(this IProductDbSet ctx, Guid productId)
{
var product = ctx.GetProductById(productId);
return product == null || ctx.RemoveProduct(product);
}
public static bool RemoveProductsByCompanyId(this IProductDbSet ctx, Guid companyId)
{
var products = ctx.GetProductsByCompanyId(companyId);
foreach (var product in products)
ctx.RemoveProduct(product);
return true;
}
#endregion Add, Update, Remove #endregion Add, Update, Remove
public static IQueryable<Product> ProductsWithUserRelations(this IProductDbSet ctx, bool autoInclude = true) public static IQueryable<Product> ProductsWithUserRelations(this IProductDbSet ctx, bool autoInclude = true)
@ -59,7 +33,7 @@ public static class ProductDbSetExtensions
public static Product? GetProductById(this IProductDbSet ctx, Guid productId, bool includeUsers = true) public static Product? GetProductById(this IProductDbSet ctx, Guid productId, bool includeUsers = true)
=> ctx.ProductsWithUserRelations(includeUsers).FirstOrDefault(x => x.Id == productId); => ctx.ProductsWithUserRelations(includeUsers).FirstOrDefault(x => x.Id == productId);
public static IQueryable<Product> GetProductsByCompanyId(this IProductDbSet ctx, Guid serviceProviderId, bool includeUsers = true) public static IQueryable<Product> GetProductsByServiceProviderId(this IProductDbSet ctx, Guid serviceProviderId, bool includeUsers = true)
=> ctx.ProductsWithUserRelations(includeUsers).Where(x => x.ServiceProviderId == serviceProviderId); => ctx.ProductsWithUserRelations(includeUsers).Where(x => x.ServiceProviderId == serviceProviderId);
} }

View File

@ -1,10 +0,0 @@
using AyCode.Database.DbSets.Profiles;
using TIAM.Database.DbSets.Addresses;
using TIAM.Entities.Addresses;
using TIAM.Entities.Profiles;
namespace TIAM.Database.DbSets.Profiles;
public interface IProfileDbSet : IAcProfileDbSetBase<Profile, Address>, IAddressDbSet
{
}

View File

@ -2,10 +2,9 @@
using TIAM.Entities.Addresses; using TIAM.Entities.Addresses;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
namespace TIAM.Database.DbSets.ServiceProvider; namespace TIAM.Database.DbSets.ServiceProvider;
public interface ICompanyDbSet : IAcCompanyDbSetBase<Company, Profile, Address, UserToCompany> public interface ICompanyDbSet : IAcCompanyDbSetBase<Company, Profile, Address>
{ {
} }

View File

@ -7,7 +7,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MessagePack.Annotations" Version="2.5.168" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />

View File

@ -19,11 +19,10 @@ public class SignalRTags : AcSignalRTags
public const int GetCompany = 12; public const int GetCompany = 12;
public const int GetCompanies = 13; public const int GetCompanies = 13;
public const int GetCompaniesById = 14; public const int GetCompaniesByContextId = 14;
public const int GetCompaniesByContextId = 15; public const int UpdateCompany = 15;
public const int UpdateCompany = 16; public const int AddCompany = 16;
public const int AddCompany = 17; public const int RemoveCompany = 17;
public const int RemoveCompany = 18;
public const int GetTransferToDriver = 22; public const int GetTransferToDriver = 22;
//public const int GetTransferToDrivers = 23; //public const int GetTransferToDrivers = 23;

View File

@ -225,6 +225,7 @@ else
<div class="card-footer p-4"> <div class="card-footer p-4">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<DxButton Click="@((e) => UpdateTransferEventHandler(e, true))">Save Changes</DxButton> <DxButton Click="@((e) => UpdateTransferEventHandler(e, true))">Save Changes</DxButton>
</div> </div>
</div> </div>
</div> </div>
@ -233,6 +234,8 @@ else
</div> </div>
</div> </div>
</section> </section>
} }
</DxTabPage> </DxTabPage>

View File

@ -29,14 +29,14 @@
OnGridEditModelSaving="DataItemSaving" OnGridEditModelSaving="DataItemSaving"
OnGridItemDeleting="DataItemDeleting" OnGridItemDeleting="DataItemDeleting"
OnGridItemChanged="DataItemChanged" OnGridItemChanged="DataItemChanged"
PageSize="5"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled" KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id" KeyFieldName="Id"
ValidationEnabled="false" ValidationEnabled="false"
TextWrapEnabled="false"
AutoExpandAllGroupRows="true"
EditMode="GridEditMode.EditForm" EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn" ColumnResizeMode="GridColumnResizeMode.NextColumn"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"> ShowFilterRow="false">
<Columns> <Columns>
<DxGridCommandColumn NewButtonVisible="false" DeleteButtonVisible="false" Width="70" MinWidth="70" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn NewButtonVisible="false" DeleteButtonVisible="false" Width="70" MinWidth="70" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" /> <DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
@ -62,7 +62,6 @@
[Parameter] public IAcAddressRelation<Address> ParentData { get; set; } = null!; [Parameter] public IAcAddressRelation<Address> ParentData { get; set; } = null!;
[Parameter] public IList<Address>? DataSource { get; set; } [Parameter] public IList<Address>? DataSource { get; set; }
[Parameter] public EventCallback<Address> OnAddressChanged { get; set; } [Parameter] public EventCallback<Address> OnAddressChanged { get; set; }
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private Guid? _contextId = null!; private Guid? _contextId = null!;
private AddressDetailGrid _addressGrid = null!; private AddressDetailGrid _addressGrid = null!;

View File

@ -18,7 +18,7 @@
<CarDetailGrid Logger="_logger" <CarDetailGrid Logger="_logger"
ContextIds="new [] {ContextId}" ContextIds="ContextIds"
GetAllMessageTag="GetAllTag" GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient" SignalRClient="AdminSignalRClient"
PageSize="10" PageSize="10"
@ -29,11 +29,10 @@
CustomizeEditModel="CustomizeEditModel" CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm" EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn" ColumnResizeMode="GridColumnResizeMode.NextColumn"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
ShowFilterRow="true"> ShowFilterRow="true">
<Columns> <Columns>
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" /> <DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="UserProductMappingId" /> <DxGridDataColumn FieldName="UserProductMappingId" />
<DxGridDataColumn FieldName="CountryCode"/> <DxGridDataColumn FieldName="CountryCode"/>
<DxGridDataColumn FieldName="LicencePlate"/> <DxGridDataColumn FieldName="LicencePlate"/>
@ -46,65 +45,88 @@
</Columns> </Columns>
<DetailRowTemplate> <DetailRowTemplate>
@{ @{
<DxTabs> if (ShowNestedRows)
{
<DxTabs>
<DxTabPage Text="Driving permissions assigned"> <DxTabPage Text="Driving permissions assigned">
<UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingById" ContextIds="new[] { ((Car)context.DataItem).UserProductMappingId }" KeyboardNavigationEnabled="true"/> <UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingById" ContextId="((Car)context.DataItem).UserProductMappingId" KeyboardNavigationEnabled="true" />
</DxTabPage> </DxTabPage>
</DxTabs> </DxTabs>
}
} }
</DetailRowTemplate> </DetailRowTemplate>
<EditFormTemplate Context="userEditFormContext"> <EditFormTemplate Context="UserEditFormContext">
@{ @{
var car = (Car)userEditFormContext.EditModel; var car = (Car)UserEditFormContext.EditModel;
} }
<DxFormLayout CssClass="w-100"> <DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="Country code" ColSpanMd="4"> <DxFormLayoutItem Caption="Country code" ColSpanMd="4">
@userEditFormContext.GetEditor("CountryCode") @UserEditFormContext.GetEditor("CountryCode")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4"> <DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@userEditFormContext.GetEditor("LicencePlate") @UserEditFormContext.GetEditor("LicencePlate")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Color" ColSpanMd="4"> <DxFormLayoutItem Caption="Color" ColSpanMd="4">
@userEditFormContext.GetEditor("Color") @UserEditFormContext.GetEditor("Color")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Manufacturer" ColSpanMd="4"> <DxFormLayoutItem Caption="Manufacturer" ColSpanMd="4">
@userEditFormContext.GetEditor("Manufacture") @UserEditFormContext.GetEditor("Manufacture")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Car model" ColSpanMd="4"> <DxFormLayoutItem Caption="Car model" ColSpanMd="4">
@userEditFormContext.GetEditor("CarModel") @UserEditFormContext.GetEditor("CarModel")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Year of make" ColSpanMd="4"> <DxFormLayoutItem Caption="Year of make" ColSpanMd="4">
@userEditFormContext.GetEditor("YearOfMake") @UserEditFormContext.GetEditor("YearOfMake")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Seat number" ColSpanMd="4"> <DxFormLayoutItem Caption="Seat number" ColSpanMd="4">
@userEditFormContext.GetEditor("SeatNumber") @UserEditFormContext.GetEditor("SeatNumber")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Motor type" ColSpanMd="4"> <DxFormLayoutItem Caption="Motor type" ColSpanMd="4">
@userEditFormContext.GetEditor("CarMotorType") @UserEditFormContext.GetEditor("CarMotorType")
</DxFormLayoutItem> </DxFormLayoutItem>
</DxFormLayout> </DxFormLayout>
</EditFormTemplate> </EditFormTemplate>
</CarDetailGrid> </CarDetailGrid>
@code { @code {
[Parameter] public Guid ContextId { get; set; } [Parameter]
[Parameter] public bool KeyboardNavigationEnabled { get; set; } public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public ICarRelation ParentData { get; set; } = null!; [Parameter] public ICarRelation ParentData { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllCars; [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllCars;
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private LoggerClient<CarDetailGridComponent> _logger = null!; [Parameter] public bool ShowNestedRows { get; set; } = false;
protected override void OnInitialized() [Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
private LoggerClient<CarDetailGridComponent> _logger;
protected override void OnParametersSet()
{
if (ContextId != null)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId;
}
base.OnParametersSet();
}
protected override async Task OnInitializedAsync()
{ {
_logger = new LoggerClient<CarDetailGridComponent>(LogWriters.ToArray()); _logger = new LoggerClient<CarDetailGridComponent>(LogWriters.ToArray());
base.OnInitialized();
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
} }
void CustomizeEditModel(GridCustomizeEditModelEventArgs e) void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
@ -112,25 +134,53 @@
if (e.IsNew) if (e.IsNew)
{ {
var newCar = new Car var newCar = new Car
{ {
Id = Guid.NewGuid(), Id = Guid.NewGuid(),
UserProductMappingId = ContextId!, UserProductMappingId = (Guid)ContextId,
CountryCode = 1, CountryCode = 1,
LicencePlate = "ABC123", LicencePlate = "ABC123",
Color = "White", Color = "White",
Manufacture = "Manufacturer", Manufacture = "Manufacturer",
CarModel = "Car model", CarModel = "Car model",
YearOfMake = DateTime.Now.Year, YearOfMake = DateTime.Now.Year,
SeatNumber = 5, SeatNumber = 5,
CarMotorType = TIAM.Core.Enums.CarMotorType.Electric CarMotorType = TIAM.Core.Enums.CarMotorType.Electric
}; };
e.EditModel = newCar; e.EditModel = newCar;
} }
else else
{ {
// //
} }
}
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
_logger.Info("New orderData added");
else
_logger.Info("orderData updated");
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
_logger.Info("orderData deleted");
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
} }
} }

View File

@ -18,7 +18,7 @@
<CarGrid Logger="_logger" <CarGrid Logger="_logger"
ContextIds="new [] {ContextId}" ContextIds="ContextIds"
GetAllMessageTag="GetAllTag" GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient" SignalRClient="AdminSignalRClient"
PageSize="10" PageSize="10"
@ -29,11 +29,10 @@
CustomizeEditModel="CustomizeEditModel" CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm" EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn" ColumnResizeMode="GridColumnResizeMode.NextColumn"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
ShowFilterRow="true"> ShowFilterRow="true">
<Columns> <Columns>
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" /> <DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="UserProductMappingId" /> <DxGridDataColumn FieldName="UserProductMappingId" />
<DxGridDataColumn FieldName="CountryCode"/> <DxGridDataColumn FieldName="CountryCode"/>
<DxGridDataColumn FieldName="LicencePlate"/> <DxGridDataColumn FieldName="LicencePlate"/>
@ -46,69 +45,127 @@
</Columns> </Columns>
<DetailRowTemplate> <DetailRowTemplate>
@{ @{
<DxTabs> if (ShowNestedRows)
{
<DxTabs>
<DxTabPage Text="Driving permissions assigned"> <DxTabPage Text="Driving permissions assigned">
<UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingById" ContextIds="new[] { ((Car)context.DataItem).UserProductMappingId }" KeyboardNavigationEnabled="true"/> <UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingById" ContextId="((Car)context.DataItem).UserProductMappingId" KeyboardNavigationEnabled="true" />
</DxTabPage> </DxTabPage>
</DxTabs> </DxTabs>
}
} }
</DetailRowTemplate> </DetailRowTemplate>
<EditFormTemplate Context="userEditFormContext"> <EditFormTemplate Context="UserEditFormContext">
@{ @{
var car = (Car)userEditFormContext.EditModel; var car = (Car)UserEditFormContext.EditModel;
} }
<DxFormLayout CssClass="w-100"> <DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="Country code" ColSpanMd="4"> <DxFormLayoutItem Caption="Country code" ColSpanMd="4">
@userEditFormContext.GetEditor("CountryCode") @UserEditFormContext.GetEditor("CountryCode")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4"> <DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@userEditFormContext.GetEditor("LicencePlate") @UserEditFormContext.GetEditor("LicencePlate")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Color" ColSpanMd="4"> <DxFormLayoutItem Caption="Color" ColSpanMd="4">
@userEditFormContext.GetEditor("Color") @UserEditFormContext.GetEditor("Color")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Manufacturer" ColSpanMd="4"> <DxFormLayoutItem Caption="Manufacturer" ColSpanMd="4">
@userEditFormContext.GetEditor("Manufacture") @UserEditFormContext.GetEditor("Manufacture")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4"> <DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@userEditFormContext.GetEditor("CarModel") @UserEditFormContext.GetEditor("CarModel")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4"> <DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@userEditFormContext.GetEditor("YearOfMake") @UserEditFormContext.GetEditor("YearOfMake")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4"> <DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@userEditFormContext.GetEditor("SeatNumber") @UserEditFormContext.GetEditor("SeatNumber")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4"> <DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@userEditFormContext.GetEditor("CarMotorType") @UserEditFormContext.GetEditor("CarMotorType")
</DxFormLayoutItem> </DxFormLayoutItem>
</DxFormLayout> </DxFormLayout>
</EditFormTemplate> </EditFormTemplate>
</CarGrid> </CarGrid>
@code { @code {
[Parameter] public Guid ContextId { get; set; } [Parameter]
[Parameter] public bool KeyboardNavigationEnabled { get; set; } public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public ICarRelation ParentData { get; set; } = null!; [Parameter] public ICarRelation ParentData { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllCars; [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllCars;
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private LoggerClient<CarGridComponent> _logger = null!; [Parameter] public bool ShowNestedRows { get; set; } = false;
protected override void OnInitialized() [Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
private LoggerClient<CarGridComponent> _logger;
protected override void OnParametersSet()
{
if (ContextId != null)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId;
}
base.OnParametersSet();
}
protected override async Task OnInitializedAsync()
{ {
_logger = new LoggerClient<CarGridComponent>(LogWriters.ToArray()); _logger = new LoggerClient<CarGridComponent>(LogWriters.ToArray());
base.OnInitialized();
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
} }
void CustomizeEditModel(GridCustomizeEditModelEventArgs e) void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{ {
if (!e.IsNew) return; if (!e.IsNew) return;
// var newProductMapping = new UserProductMapping
// {
// ProductId = Guid.NewGuid(),
// UserId = UserModelDtoDetail.Id,
// Permissions = 1
// };
//e.EditModel = newProductMapping;
}
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
_logger.Info("New orderData added");
else
_logger.Info("orderData updated");
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
_logger.Info("orderData deleted");
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
} }
} }

View File

@ -12,7 +12,6 @@
@using AyCode.Core.Loggers @using AyCode.Core.Loggers
@using AyCode.Services.Loggers @using AyCode.Services.Loggers
@using AyCode.Core @using AyCode.Core
@using AyCode.Core.Extensions
@inject IServiceProviderDataService ServiceProviderDataService @inject IServiceProviderDataService ServiceProviderDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters @inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient @inject AdminSignalRClient AdminSignalRClient
@ -32,14 +31,14 @@
<label for="emailID" class="demo-text mt-4 mb-1"> <label for="emailID" class="demo-text mt-4 mb-1">
Put user email here Put user email here
</label> </label>
<DxMaskedInput @ref="_emailInput" <DxMaskedInput @ref="emailInput"
@bind-Value="@Email" @bind-Value="@Email"
CssClass="cw-320" CssClass="cw-320"
Mask="@EmailMask" Mask="@EmailMask"
InputId="emailID" InputId="emailID"
MaskMode="MaskMode.RegEx" /> MaskMode="MaskMode.RegEx" />
<DxButton @ref="_button1" CssClass="popup-button my-1 ms-2" Visible="true" RenderStyle="ButtonRenderStyle.Primary" Text="Find user" Click="@FindUser" /> <DxButton @ref="button1" CssClass="popup-button my-1 ms-2" Visible="true" RenderStyle="ButtonRenderStyle.Primary" Text="Find user" Click="@FindUser" />
<div style="@_errorCss" @ref="_errorMessage"><p>User not found, type another email please</p></div> <div style="@errorCss" @ref="errorMessage"><p>User not found, type another email please</p></div>
<DxGrid Data="@FoundUsers" RowClick="@OnRowClick"> <DxGrid Data="@FoundUsers" RowClick="@OnRowClick">
<Columns> <Columns>
<DxGridDataColumn FieldName="Id" Caption="ID" /> <DxGridDataColumn FieldName="Id" Caption="ID" />
@ -55,10 +54,9 @@
</div> </div>
</FooterContentTemplate> </FooterContentTemplate>
</DxPopup> </DxPopup>
<UserProductMappingDriverGrid Logger="_logger" <UserProductMappingDriverGrid Logger="_logger"
@ref="_driverGrid" @ref="_driverGrid"
ContextIds="new [] {ContextId}" ContextIds="ContextIds"
GetAllMessageTag="GetAllTag" GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient" SignalRClient="AdminSignalRClient"
PageSize="10" PageSize="10"
@ -70,17 +68,18 @@
CustomizeEditModel="CustomizeEditModel" CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm" EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn" ColumnResizeMode="GridColumnResizeMode.NextColumn"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
ShowFilterRow="true"> ShowFilterRow="true">
<Columns> <Columns>
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" /> <DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="UserId" /> <DxGridDataColumn FieldName="UserId" />
<DxGridDataColumn FieldName="ProductId" Width="40%" /> <DxGridDataColumn FieldName="ProductId" Width="40%" />
<DxGridDataColumn FieldName="Permissions" /> <DxGridDataColumn FieldName="Permissions" />
</Columns> </Columns>
<DetailRowTemplate> <DetailRowTemplate>
@{ @{
if (ShowNestedRows)
{
<DxTabs> <DxTabs>
<DxTabPage Text="Products"> <DxTabPage Text="Products">
@ -90,6 +89,7 @@
<CarDetailGridComponent GetAllTag="SignalRTags.GetCarsForUserProductMapping" ContextId="((UserProductMapping)context.DataItem).Id" KeyboardNavigationEnabled="true" /> <CarDetailGridComponent GetAllTag="SignalRTags.GetCarsForUserProductMapping" ContextId="((UserProductMapping)context.DataItem).Id" KeyboardNavigationEnabled="true" />
</DxTabPage> </DxTabPage>
</DxTabs> </DxTabs>
}
} }
</DetailRowTemplate> </DetailRowTemplate>
@ -122,76 +122,114 @@
</UserProductMappingDriverGrid> </UserProductMappingDriverGrid>
@code { @code {
[Parameter] public Guid ContextId { get; set; } [Parameter]
[Parameter] public bool KeyboardNavigationEnabled { get; set; } public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public IProductRelation ParentData { get; set; } = null!; [Parameter] public IProductRelation ParentData { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings; [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings;
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
[Parameter] public bool ShowNestedRows { get; set; } = false;
[Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
private LoggerClient<UserProductMappingGridComponent> _logger; private LoggerClient<UserProductMappingGridComponent> _logger;
List<Product> _availableProducts; List<Product> _availableProducts;
private UserProductMappingDriverGrid _driverGrid; private UserProductMappingDriverGrid _driverGrid;
private UserProductMapping _tempProductMapping; private UserProductMapping tempProductMapping;
bool PopupVisible { get; set; } bool PopupVisible { get; set; }
private DxMaskedInput<string> _emailInput; private DxMaskedInput<string> emailInput;
private DxButton _button1; private DxButton button1;
private ElementReference _errorMessage; private ElementReference errorMessage;
private string _errorCss = "display: none;"; private string errorCss = "display: none;";
private List<UserModelDto> FoundUsers { get; set; } = new List<UserModelDto>(); private List<UserModelDto> FoundUsers { get; set; } = new List<UserModelDto>();
private string Email { get; set; } = "email@email.com"; private string Email { get; set; } = "email@email.com";
string EmailMask { get; set; } = @"(\w|[.-])+@(\w|-)+\.(\w|-){2,4}"; string EmailMask { get; set; } = @"(\w|[.-])+@(\w|-)+\.(\w|-){2,4}";
UserModelDto _chosenUser = null!; UserModelDto ChosenUser = null;
protected override void OnInitialized() protected override void OnParametersSet()
{
if (ContextId != null)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId;
}
base.OnParametersSet();
}
protected override async Task OnInitializedAsync()
{ {
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray()); _logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
base.OnInitialized();
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
} }
void CustomizeEditModel(GridCustomizeEditModelEventArgs e) void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{ {
if (!e.IsNew) return; if (!e.IsNew) return;
UserProductMapping newUPM = (UserProductMapping)e.EditModel;
if (ContextId.IsNullOrEmpty()) newUPM.ProductId = (Guid)ContextId!;
{
_logger.Warning($"ContextId.IsNullOrEmpty()");
return;
}
var newUpm = (UserProductMapping)e.EditModel;
newUpm.ProductId = ContextId;
var newProductMapping = new UserProductMapping var newProductMapping = new UserProductMapping
{ {
Id = Guid.NewGuid(), Id = Guid.NewGuid(),
ProductId = (Guid)ContextId, ProductId = (Guid)ContextId,
Permissions = 2 Permissions = 2
}; };
//e.EditModel = newProductMapping; //e.EditModel = newProductMapping;
} }
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
_logger.Info("New orderData added");
else
_logger.Info("orderData updated");
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
_logger.Info("orderData deleted");
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
}
async Task FindUser() async Task FindUser()
{ {
var userModelDto = await UserDataService.GetUserByEmailAsync(Email); var userModelDto = await UserDataService.GetUserByEmailAsync(Email);
if (userModelDto != null) if (userModelDto != null)
{ {
_chosenUser = userModelDto; ChosenUser = userModelDto;
FoundUsers.Add(_chosenUser); FoundUsers.Add(ChosenUser);
_emailInput.Enabled = false; emailInput.Enabled = false;
_button1.Visible = false; button1.Visible = false;
} }
else else
{ {
_emailInput.Value = "email@email.com"; emailInput.Value = "email@email.com";
_errorCss = "display: block"; errorCss = "display: block";
} }
} }
@ -211,18 +249,17 @@
} }
public Task SubmitForm(object result) public async Task SubmitForm(object result)
{ {
_logger.Info($"Submitted nested form: {result.GetType().FullName}"); _logger.Info($"Submitted nested form: {result.GetType().FullName}");
return Task.CompletedTask;
} }
public Task ShowPopup(UserProductMapping emptyProductMapping) public async Task ShowPopup(UserProductMapping emptyProductMapping)
{ {
_tempProductMapping = emptyProductMapping; tempProductMapping = emptyProductMapping;
PopupVisible = true; PopupVisible = true;
return Task.CompletedTask;
} }
private async Task OnUserSelected(Guid userId) private async Task OnUserSelected(Guid userId)
@ -232,15 +269,13 @@
} }
private async Task OnRowClick(GridRowClickEventArgs e) private async Task OnRowClick(GridRowClickEventArgs e)
{ {
await SelectUser((Guid)e.Grid.GetRowValue(e.VisibleIndex, "Id")); await SelectUser((Guid)e.Grid.GetRowValue(e.VisibleIndex, "Id"));
} }
private async Task SelectUser(Guid id) private async Task SelectUser(Guid id)
{ {
PopupVisible = false; PopupVisible = false;
_tempProductMapping.UserId = id; tempProductMapping.UserId = id;
await OnUserSelected(id); await OnUserSelected(id);
} }
@ -248,7 +283,7 @@
{ {
if (e.ElementType == GridElementType.DataRow && (int)e.Grid.GetRowValue(e.VisibleIndex, "Permissions") == 1) if (e.ElementType == GridElementType.DataRow && (int)e.Grid.GetRowValue(e.VisibleIndex, "Permissions") == 1)
{ {
e.Style = "display: none"; e.Style="display: none";
} }
// else if (e.ElementType == GridElementType.HeaderCell) // else if (e.ElementType == GridElementType.HeaderCell)
// { // {
@ -256,4 +291,7 @@
// } // }
} }
} }

View File

@ -37,7 +37,7 @@
Click="ColumnChooserButton_Click" /> Click="ColumnChooserButton_Click" />
</div> </div>
<CarGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" GetAllTag="SignalRTags.GetAllCars"></CarGridComponent> <CarGridComponent ShowNestedRows="true" GetAllTag="SignalRTags.GetAllCars"></CarGridComponent>
</div> </div>

View File

@ -37,7 +37,7 @@
Click="ColumnChooserButton_Click" /> Click="ColumnChooserButton_Click" />
</div> </div>
<DriverGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" ContextId="Guid.Parse(TransferProductId)" GetAllTag="SignalRTags.GetUserProductMappingsByProductId"></DriverGridComponent> <DriverGridComponent ShowNestedRows="true" ContextId="Guid.Parse(TransferProductId)" GetAllTag="SignalRTags.GetUserProductMappingsByProductId"></DriverGridComponent>
</div> </div>

View File

@ -16,7 +16,6 @@
@using AyCode.Core @using AyCode.Core
@using TIAM.Entities.Products @using TIAM.Entities.Products
@using TIAM.Entities.Users @using TIAM.Entities.Users
@using TIAM.Services
@layout AdminLayout @layout AdminLayout
@inject IEnumerable<IAcLogWriterClientBase> LogWriters @inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject IStringLocalizer<TIAMResources> localizer @inject IStringLocalizer<TIAMResources> localizer
@ -134,7 +133,7 @@
<ProfileGridComponent ParentData="((Company)context.DataItem)" KeyboardNavigationEnabled="true" /> <ProfileGridComponent ParentData="((Company)context.DataItem)" KeyboardNavigationEnabled="true" />
</DxTabPage> </DxTabPage>
<DxTabPage Text="Products"> <DxTabPage Text="Products">
<ProductDetailGridComponent @ref="_productDetailGridComponent" DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" GetAllTag="SignalRTags.GetProductsByOwnerId" OnGridEditModelSaving="OnProductGridItemSaving" ContextId="((Company)context.DataItem).Id" ParentData="(Company)context.DataItem" KeyboardNavigationEnabled="true" /> <ProductDetailGridComponent @ref="_productDetailGridComponent" GetAllTag="SignalRTags.GetProductsByOwnerId" OnGridEditModelSaving="OnProductGridItemSaving" ContextId="((Company)context.DataItem).Id" ParentData="(Company)context.DataItem" KeyboardNavigationEnabled="true" />
</DxTabPage> </DxTabPage>
<DxTabPage Text="Address"> <DxTabPage Text="Address">
<AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" /> <AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" />

View File

@ -37,7 +37,7 @@
Click="ColumnChooserButton_Click" /> Click="ColumnChooserButton_Click" />
</div> </div>
<UserProductMappingGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" GetAllTag="SignalRTags.GetAllUserProductMappings"></UserProductMappingGridComponent> <UserProductMappingGridComponent ShowNestedRows="true" GetAllTag="SignalRTags.GetAllUserProductMappings"></UserProductMappingGridComponent>
</div> </div>

View File

@ -16,7 +16,6 @@
@using TIAMWebApp.Shared.Application.Services @using TIAMWebApp.Shared.Application.Services
@using AyCode.Interfaces.Addresses @using AyCode.Interfaces.Addresses
@using TIAM.Entities.Emails @using TIAM.Entities.Emails
@using AyCode.Blazor.Components.Services
@inject IEnumerable<IAcLogWriterClientBase> LogWriters @inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient; @inject AdminSignalRClient AdminSignalRClient;
@ -25,7 +24,6 @@
Logger="_logger" Logger="_logger"
SignalRClient="AdminSignalRClient" SignalRClient="AdminSignalRClient"
ContextIds="new[] {ContextId}" ContextIds="new[] {ContextId}"
KeyFieldName="Id"
CustomizeElement="CustomizeElement" CustomizeElement="CustomizeElement"
TextWrapEnabled="false"> TextWrapEnabled="false">
@ -51,9 +49,9 @@
if (!emailMessage.IsReaded) if (!emailMessage.IsReaded)
{ {
emailMessage.IsReaded = true; emailMessage.IsReaded = true;
_messageGrid.UpdateDataItemAsync(emailMessage).Forget(); _messageGrid.UpdateDataItemAsync(emailMessage).Forget();
//InvokeAsync(StateHasChanged).ContinueWith(x => _messageGrid.UpdateDataItemAsync(emailMessage).Forget());
InvokeAsync(StateHasChanged).Forget();
} }
} }
</DetailRowTemplate> </DetailRowTemplate>

View File

@ -18,26 +18,30 @@
@using AyCode.Interfaces.Addresses @using AyCode.Interfaces.Addresses
@using AyCode.Core @using AyCode.Core
@inject IStringLocalizer<TIAMResources> Localizer @inject IStringLocalizer<TIAMResources> Localizer
@inject IServiceProviderDataService serviceProviderDataService
@inject IUserDataService userDataService
@inject ITransferDataService transferDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters @inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient; @inject AdminSignalRClient AdminSignalRClient;
<ProductDetailGrid @ref="_productGrid" <ProductDetailGrid @ref="_productGrid"
ContextIds="new[] {ContextId}" GetAllMessageTag="GetAllTag"
DataSource="ParentData?.Products ?? []" DataSource = "productList"
GetAllMessageTag="GetAllTag" ContextIds="new[] {(Guid)ContextId}"
Logger="_logger" Logger="_logger"
SignalRClient="AdminSignalRClient" SignalRClient="AdminSignalRClient"
OnGridEditModelSaving="DataItemSaving" OnGridEditModelSaving="DataItemSaving"
OnGridItemDeleting="DataItemDeleting" OnGridItemDeleting="DataItemDeleting"
OnGridItemChanged="DataItemChanged" OnGridItemChanged="DataItemChanged"
TextWrapEnabled="false" PageSize="5"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled" KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id" KeyFieldName="Id"
ValidationEnabled="false" ValidationEnabled="false"
EditMode="GridEditMode.EditForm" EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn" ColumnResizeMode="GridColumnResizeMode.NextColumn"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"> ShowFilterRow="true">
<Columns> <Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn NewButtonVisible="true" Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N"/> <DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N"/>
@ -51,7 +55,7 @@
<DetailRowTemplate> <DetailRowTemplate>
<DxTabs> <DxTabs>
<DxTabPage Text="Permissions"> <DxTabPage Text="Permissions">
<UserProductMappingGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Never" ContextIds="new [] {((Product)context.DataItem).Id}" GetAllTag="SignalRTags.GetUserProductMappingsByProductId"> <UserProductMappingGridComponent ShowNestedRows="false" ContextId="((Product)context.DataItem).Id" GetAllTag="SignalRTags.GetUserProductMappingsByProductId">
</UserProductMappingGridComponent> </UserProductMappingGridComponent>
</DxTabPage> </DxTabPage>
<DxTabPage Text="Profile"> <DxTabPage Text="Profile">
@ -59,22 +63,22 @@
</DxTabPage> </DxTabPage>
</DxTabs> </DxTabs>
</DetailRowTemplate> </DetailRowTemplate>
<EditFormTemplate Context="editFormContext"> <EditFormTemplate Context="EditFormContext">
@{ @{
var transfer2 = (Product)editFormContext.EditModel; var transfer2 = (Product)EditFormContext.EditModel;
} }
<DxFormLayout CssClass="w-100"> <DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductName) ColSpanMd="4"> <DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductName) ColSpanMd="4">
@editFormContext.GetEditor("Name") @EditFormContext.GetEditor("Name")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductType) ColSpanMd="4"> <DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductType) ColSpanMd="4">
@editFormContext.GetEditor("ProductType") @EditFormContext.GetEditor("ProductType")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.Price) ColSpanMd="4"> <DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.Price) ColSpanMd="4">
@editFormContext.GetEditor("Price") @EditFormContext.GetEditor("Price")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductDescription) ColSpanMd="4"> <DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductDescription) ColSpanMd="4">
@editFormContext.GetEditor("Description") @EditFormContext.GetEditor("Description")
</DxFormLayoutItem> </DxFormLayoutItem>
@ -84,14 +88,14 @@
</ProductDetailGrid> </ProductDetailGrid>
@code { @code {
[Parameter] public bool KeyboardNavigationEnabled { get; set; } [Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public Guid ContextId { get; set; } [Parameter] public Guid? ContextId { get; set; } = null;
[Parameter] public IProductsRelation? ParentData { get; set; } = null!; [Parameter] public IProductsRelation ParentData { get; set; } = null!;
[Parameter] public EventCallback<GridEditModelSavingEventArgs> OnGridEditModelSaving { get; set; } [Parameter] public EventCallback<GridEditModelSavingEventArgs> OnGridEditModelSaving { get; set; }
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetProductsByContextId; [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetProductsByContextId;
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private ProductDetailGrid _productGrid = null!; private ProductDetailGrid _productGrid;
private List<Product> productList = new List<Product>();
private LoggerClient<ProductDetailGridComponent> _logger = null!; private LoggerClient<ProductDetailGridComponent> _logger = null!;
protected override void OnInitialized() protected override void OnInitialized()
{ {
@ -117,12 +121,31 @@
// } // }
// else // else
await base.OnParametersSetAsync(); base.OnParametersSet();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
// if(firstRender)
// {
// _productGrid.GetAllMessageTag = GetAllTag;
// // if (ParentData != null)
// // {
// // _productGrid.DataSource = new List<Product>();
// // _productGrid.DataSource = ParentData.Products;
// // }
// }
} }
private void DataItemChanged(GridDataItemChangedEventArgs<Product> args) private void DataItemChanged(GridDataItemChangedEventArgs<Product> args)
{ {
_logger.Debug($"Saving: {args.DataItem.Name}, {args.DataItem.ServiceProviderId}"); _logger.Debug($"Saving: {args.DataItem.Name}, {args.DataItem.ServiceProviderId}");
//ProductGrid.SaveChangesAsync();
} }
public async Task DataItemSaving(GridEditModelSavingEventArgs e) public async Task DataItemSaving(GridEditModelSavingEventArgs e)

View File

@ -12,6 +12,8 @@
@using TIAM.Entities.Addresses @using TIAM.Entities.Addresses
@using TIAM.Entities.Profiles @using TIAM.Entities.Profiles
@using Profile = TIAM.Entities.Profiles.Profile @using Profile = TIAM.Entities.Profiles.Profile
@inject IServiceProviderDataService serviceProviderDataService
@inject IUserDataService userDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters @inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient @inject AdminSignalRClient AdminSignalRClient
@ -19,14 +21,14 @@
ContextIds="new[] {ParentData.ProfileId}" ContextIds="new[] {ParentData.ProfileId}"
Logger="_logger" Logger="_logger"
SignalRClient="AdminSignalRClient" SignalRClient="AdminSignalRClient"
PageSize="5"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled" KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id" KeyFieldName="Id"
ValidationEnabled="false" ValidationEnabled="false"
TextWrapEnabled="false"
AutoExpandAllGroupRows="true"
EditMode="GridEditMode.EditForm" EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn" ColumnResizeMode="GridColumnResizeMode.NextColumn"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"> ShowFilterRow="false">
<Columns> <Columns>
<DxGridCommandColumn NewButtonVisible="false" DeleteButtonVisible="false" Width="70" MinWidth="70" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn NewButtonVisible="false" DeleteButtonVisible="false" Width="70" MinWidth="70" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" /> <DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
@ -46,8 +48,9 @@
</ProfileDetailGrid> </ProfileDetailGrid>
@code { @code {
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; [Parameter]
[Parameter] public bool KeyboardNavigationEnabled { get; set; } public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public IProfileForeignKey ParentData { get; set; } = null!; [Parameter] public IProfileForeignKey ParentData { get; set; } = null!;
private ProfileDetailGrid _profileGrid = null!; private ProfileDetailGrid _profileGrid = null!;
@ -61,8 +64,6 @@
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
_logger.DebugConditional(ParentData.ProfileId.ToString()); _logger.DebugConditional(ParentData.ProfileId.ToString());
base.OnParametersSet(); base.OnParametersSet();
} }
} }

View File

@ -29,40 +29,47 @@
CustomizeEditModel="CustomizeEditModel" CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm" EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn" ColumnResizeMode="GridColumnResizeMode.NextColumn"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
ShowFilterRow="true"> ShowFilterRow="true">
<Columns> <Columns>
<DxGridCommandColumn Width="135" MinWidth="135" DeleteButtonVisible="AcDomain.IsDeveloperVersion" EditButtonVisible="AcDomain.IsDeveloperVersion" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" /> <DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="UserId" /> <DxGridDataColumn FieldName="UserId" />
<DxGridDataColumn FieldName="ProductId" Width="40%" /> <DxGridDataColumn FieldName="ProductId" Width="40%" />
<DxGridDataColumn FieldName="Permissions" /> <DxGridDataColumn FieldName="Permissions" />
</Columns> </Columns>
<DetailRowTemplate> <DetailRowTemplate>
@{ @{
<DxTabs> if (ShowNestedRows)
<DxTabPage Text="Products"> {
<ProductDetailGridComponent GetAllTag="SignalRTags.GetProductsById" ContextId="((UserProductMapping)context.DataItem).ProductId" KeyboardNavigationEnabled="true"/> <DxTabs>
</DxTabPage>
</DxTabs> <DxTabPage Text="Products">
<ProductDetailGridComponent GetAllTag="SignalRTags.GetProductsById" ContextId="((UserProductMapping)context.DataItem).ProductId" KeyboardNavigationEnabled="true" />
</DxTabPage>
</DxTabs>
}
} }
</DetailRowTemplate> </DetailRowTemplate>
<EditFormTemplate Context="userEditFormContext"> <EditFormTemplate Context="UserEditFormContext">
@{ @{
var transfer2 = (UserProductMapping)userEditFormContext.EditModel; var transfer2 = (UserProductMapping)UserEditFormContext.EditModel;
} }
<DxFormLayout CssClass="w-100"> <DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="UserId" ColSpanMd="4"> <DxFormLayoutItem Caption="UserId" ColSpanMd="4">
@userEditFormContext.GetEditor("UserId") @UserEditFormContext.GetEditor("UserId")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Product:" ColSpanMd="4"> <DxFormLayoutItem Caption="Product:" ColSpanMd="4">
<DxComboBox Data="@_availableProducts" TextFieldName="Name" @bind-Value="((UserProductMapping)userEditFormContext.EditModel).ProductId" /> <DxComboBox Data="@_availableProducts" TextFieldName="Name" @bind-Value="((UserProductMapping)UserEditFormContext.EditModel).ProductId" />
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption="Permissions" ColSpanMd="4"> <DxFormLayoutItem Caption="Permissions" ColSpanMd="4">
@userEditFormContext.GetEditor("Permissions") @UserEditFormContext.GetEditor("Permissions")
</DxFormLayoutItem> </DxFormLayoutItem>
</DxFormLayout> </DxFormLayout>
</EditFormTemplate> </EditFormTemplate>
@ -76,9 +83,11 @@
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings; [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings;
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; [Parameter] public bool ShowNestedRows { get; set; } = false;
[Parameter] public Guid[]? ContextIds { get; set; } [Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
private LoggerClient<UserProductMappingGridComponent> _logger; private LoggerClient<UserProductMappingGridComponent> _logger;
@ -86,12 +95,22 @@
private ProductDetailGridComponent bleh; private ProductDetailGridComponent bleh;
protected override void OnParametersSet()
{
if (ContextId != null)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId;
}
base.OnParametersSet();
}
protected override void OnInitialized() protected override async Task OnInitializedAsync()
{ {
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray()); _logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
base.OnInitialized();
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
} }
void CustomizeEditModel(GridCustomizeEditModelEventArgs e) void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
@ -107,4 +126,30 @@
//e.EditModel = newProductMapping; //e.EditModel = newProductMapping;
} }
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
_logger.Info("New orderData added");
else
_logger.Info("orderData updated");
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
_logger.Info("orderData deleted");
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
}
} }

View File

@ -101,12 +101,7 @@ namespace TIAMSharedUI.Shared.Components.Grids
var changedEventArgs = new GridDataItemChangedEventArgs<TDataItem>(this, args.Item, args.TrackingState); var changedEventArgs = new GridDataItemChangedEventArgs<TDataItem>(this, args.Item, args.TrackingState);
await OnGridItemChanged.InvokeAsync(changedEventArgs); await OnGridItemChanged.InvokeAsync(changedEventArgs);
if (!changedEventArgs.CancelStateChangeInvoke) await InvokeAsync(StateHasChanged);
{
//BeginUpdate();
await InvokeAsync(StateHasChanged); //TODO: bezárja a DetailRow-t! pl: az email-nél IsReaded=true update... - J.
//EndUpdate();
}
} }
private Task OnDataSourceLoaded() private Task OnDataSourceLoaded()
@ -174,7 +169,7 @@ namespace TIAMSharedUI.Shared.Components.Grids
{ {
Logger.Error($"{_gridLogName} SaveChangesToServerAsync->SaveChangesAsync error!", ex); Logger.Error($"{_gridLogName} SaveChangesToServerAsync->SaveChangesAsync error!", ex);
} }
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -316,6 +311,5 @@ namespace TIAMSharedUI.Shared.Components.Grids
public TiamGrid<TDataItem> Grid { get; } public TiamGrid<TDataItem> Grid { get; }
public TDataItem DataItem { get; } public TDataItem DataItem { get; }
public TrackingState TrackingState { get; } public TrackingState TrackingState { get; }
public bool CancelStateChangeInvoke { get; set; }
} }
} }

View File

@ -98,8 +98,6 @@ namespace TIAMWebApp.Server.Controllers
return messages.ToJson(); return messages.ToJson();
} }
[NonAction]
[ApiExplorerSettings(IgnoreApi = true)]
[SignalR(SignalRTags.UpdateMessage)] [SignalR(SignalRTags.UpdateMessage)]
public async Task<EmailMessage?> UpdateMessages([FromBody] EmailMessage message) public async Task<EmailMessage?> UpdateMessages([FromBody] EmailMessage message)
{ {

View File

@ -49,10 +49,10 @@ namespace TIAMWebApp.Server.Controllers
//if (company.OwnerId.IsNullOrEmpty()) company.OwnerId = Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00"); //TESZT - J. //if (company.OwnerId.IsNullOrEmpty()) company.OwnerId = Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00"); //TESZT - J.
//company.SetProfile(new Profile(Guid.NewGuid(), company.Name)); company.SetProfile(new Profile(Guid.NewGuid(), company.Name));
//company.Profile.SetAddress(new Address(Guid.NewGuid(), "Controller AddCompanyAsync; address text...")); company.Profile.SetAddress(new Address(Guid.NewGuid(), "Controller AddCompanyAsync; address text..."));
return await adminDal.AddCompanyAsync(company); return await adminDal.CreateServiceProviderAsync(company);
case TrackingState.Update: case TrackingState.Update:
return await adminDal.UpdateCompanyAsync(company); return await adminDal.UpdateCompanyAsync(company);
@ -106,7 +106,7 @@ namespace TIAMWebApp.Server.Controllers
[SignalR(SignalRTags.GetCompanies)] [SignalR(SignalRTags.GetCompanies)]
public async Task<string> GetServiceProviders() public async Task<string> GetServiceProviders()
{ {
return await adminDal.GetCompaniesJsonAsync(); return await adminDal.GetServiceProvidersJsonAsync();
} }
//18. //18.
@ -114,23 +114,15 @@ namespace TIAMWebApp.Server.Controllers
[HttpPost] [HttpPost]
[Route(APIUrls.GetServiceProviderByIdRouteName)] [Route(APIUrls.GetServiceProviderByIdRouteName)]
[SignalR(SignalRTags.GetCompany)] [SignalR(SignalRTags.GetCompany)]
public Task<Company?> GetServiceProviderById([FromBody] Guid id) public async Task<string> GetServiceProviderById([FromBody] Guid id)
{ {
_logger.Info($@"GetServiceProviderById called with id: {id}"); _logger.Info($@"GetServiceProviderById called with id: {id}");
List<Company> compList = new List<Company>();
return adminDal.GetCompanyByIdAsync(id); var result = await adminDal.GetServiceProviderByIdAsync(id);
compList.Add(result);
return compList.ToJson();
} }
[NonAction]
[ApiExplorerSettings(IgnoreApi = true)]
[SignalR(SignalRTags.GetCompaniesById)]
public async Task<List<Company>> GetServiceProvidersById(Guid id)
{
_logger.Info($@"GetServiceProvidersById called with id: {id}");
var company = await GetServiceProviderById(id);
return company == null ? [] : [company];
}
//17. //17.
[Authorize] [Authorize]
@ -142,7 +134,7 @@ namespace TIAMWebApp.Server.Controllers
{ {
_logger.Info($@"GetServiceProvidersByOwnerId called with ownerId: {ownerId}"); _logger.Info($@"GetServiceProvidersByOwnerId called with ownerId: {ownerId}");
var serviceProviders = await adminDal.GetCompaniesAsync(); var serviceProviders = await adminDal.GetServiceProvidersAsync();
//return serviceProviders.Where(x => x.OwnerId == ownerId).ToList(); //return serviceProviders.Where(x => x.OwnerId == ownerId).ToList();
var myServiceproviders = serviceProviders.Where(x => x.OwnerId == ownerId).ToDictionary(x => x.Id, x => x.Name); var myServiceproviders = serviceProviders.Where(x => x.OwnerId == ownerId).ToDictionary(x => x.Id, x => x.Name);
@ -160,7 +152,7 @@ namespace TIAMWebApp.Server.Controllers
{ {
_logger.Info($@"GetServiceProvidersByOwnerId called with ownerId: {ownerId}"); _logger.Info($@"GetServiceProvidersByOwnerId called with ownerId: {ownerId}");
var serviceProviders = await adminDal.GetCompaniesByOwnerIdAsync(ownerId); var serviceProviders = await adminDal.GetServiceProvidersByOwnerIdAsync(ownerId);
//return serviceProviders.Where(x => x.OwnerId == ownerId).ToList(); //return serviceProviders.Where(x => x.OwnerId == ownerId).ToList();
//var myServiceproviders = serviceProviders.Where(x => x.OwnerId == ownerId).ToDictionary(x => x.Id, x => x.Name); //var myServiceproviders = serviceProviders.Where(x => x.OwnerId == ownerId).ToDictionary(x => x.Id, x => x.Name);
@ -486,11 +478,14 @@ namespace TIAMWebApp.Server.Controllers
[Route(APIUrls.GetProductByIdRouteName)] [Route(APIUrls.GetProductByIdRouteName)]
[Tags("In-Progress", "Product")] [Tags("In-Progress", "Product")]
[SignalR(SignalRTags.GetProductById)] [SignalR(SignalRTags.GetProductById)]
public Task<Product?> GetProductById(Guid productId) public async Task<Product> GetProductById(Guid productId)
{ {
_logger.Info("GetAllProducts called"); _logger.Info("GetAllProducts called");
return adminDal.GetProductByIdAsync(productId); var products = adminDal.GetProductById(productId);
return products;
} }
@ -500,9 +495,14 @@ namespace TIAMWebApp.Server.Controllers
public async Task<List<Product>> GetProductsById(Guid productId) public async Task<List<Product>> GetProductsById(Guid productId)
{ {
_logger.Info("GetAllProducts called"); _logger.Info("GetAllProducts called");
var product = await GetProductById(productId); var product = await GetProductById(productId);
return product == null ? [] : [product]; var products = new List<Product>();
if (product != null) {
products.Add(product);
}
return products;
} }
} }
} }

View File

@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.6" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="8.0.6" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.15" /> <PackageReference Include="Microsoft.OpenApi" Version="1.6.14" />
<PackageReference Include="QRCoderNetCore" Version="1.0.0" /> <PackageReference Include="QRCoderNetCore" Version="1.0.0" />
<PackageReference Include="SendGrid" Version="9.29.3" /> <PackageReference Include="SendGrid" Version="9.29.3" />
<PackageReference Include="SkiaSharp" Version="2.88.8" /> <PackageReference Include="SkiaSharp" Version="2.88.8" />

View File

@ -121,8 +121,6 @@ namespace TIAMWebApp.Shared.Application.Services
_logger.DetailConditional($"companyPropertiesByOwner async: {string.Join("; ", response.ResponseData!.Values)}"); _logger.DetailConditional($"companyPropertiesByOwner async: {string.Join("; ", response.ResponseData!.Values)}");
callback.Invoke(response.ResponseData); callback.Invoke(response.ResponseData);
return Task.CompletedTask;
}, id); }, id);
} }

View File

@ -50,8 +50,6 @@ namespace Tiam.Services.Client.Tests
Assert.IsTrue(response.Status == SignalResponseStatus.Success); Assert.IsTrue(response.Status == SignalResponseStatus.Success);
company = response.ResponseData; company = response.ResponseData;
return Task.CompletedTask;
}, companyId); }, companyId);
await TaskHelper.WaitToAsync(() => company != null, 5000, 50); await TaskHelper.WaitToAsync(() => company != null, 5000, 50);
@ -79,8 +77,6 @@ namespace Tiam.Services.Client.Tests
Assert.IsTrue(response.Status == SignalResponseStatus.Success); Assert.IsTrue(response.Status == SignalResponseStatus.Success);
companies = response.ResponseData; companies = response.ResponseData;
return Task.CompletedTask;
}); });
await TaskHelper.WaitToAsync(() => companies != null, 5000, 50); await TaskHelper.WaitToAsync(() => companies != null, 5000, 50);

View File

@ -10,13 +10,10 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2"> <PackageReference Include="coverlet.collector" Version="6.0.0" />
<PrivateAssets>all</PrivateAssets> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
</PackageReference> <PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>