Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Add store-scoped customer & address attribute management to Grand.Web.Store (#722)
Krzysztof Pajakbf8825aa1d4b
diff --git a/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeParser.cs b/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeParser.csindex a6a88e6b9..b472de2d3 100644--- a/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeParser.cs+++ b/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeParser.cs@@ -92,6 +92,18 @@ public class AddressAttributeParser : IAddressAttributeParser/// <param name="customAttributes">Attributes</param>/// <returns>Warnings</returns>public virtual async Task<IList<string>> GetAttributeWarnings(IList<CustomAttribute> customAttributes)+ {+ return await GetAttributeWarnings(customAttributes, string.Empty);+ }++ /// <summary>+ /// Validates address attributes limited to the specified store+ /// </summary>+ /// <param name="customAttributes">Attributes</param>+ /// <param name="storeId">Store identifier</param>+ /// <returns>Warnings</returns>+ public virtual async Task<IList<string>> GetAttributeWarnings(IList<CustomAttribute> customAttributes,+ string storeId){var warnings = new List<string>();@@ -99,7 +111,7 @@ public class AddressAttributeParser : IAddressAttributeParservar attributes1 = await ParseAddressAttributes(customAttributes);//validate required address attributes (whether they're chosen/selected/entered)- var attributes2 = await _addressAttributeService.GetAllAddressAttributes();+ var attributes2 = await _addressAttributeService.GetAllAddressAttributes(storeId ?? string.Empty);foreach (var a2 in attributes2){if (!a2.IsRequired) continue;diff --git a/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeService.cs b/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeService.csindex d806fdd9e..4d9f598b2 100644--- a/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeService.cs+++ b/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeService.cs@@ -3,6 +3,7 @@ using Grand.Data;using Grand.Domain.Common;using Grand.Infrastructure.Caching;using Grand.Infrastructure.Caching.Constants;+using Grand.Infrastructure.Configuration;using Grand.Infrastructure.Extensions;using MediatR;@@ -21,13 +22,16 @@ public class AddressAttributeService : IAddressAttributeService/// <param name="cacheBase">Cache manager</param>/// <param name="addressAttributeRepository">Address attribute repository</param>/// <param name="mediator">Mediator</param>+ /// <param name="accessControlConfig">Access control config</param>public AddressAttributeService(ICacheBase cacheBase,IRepository<AddressAttribute> addressAttributeRepository,- IMediator mediator)+ IMediator mediator,+ AccessControlConfig accessControlConfig){_cacheBase = cacheBase;_addressAttributeRepository = addressAttributeRepository;_mediator = mediator;+ _accessControlConfig = accessControlConfig;}#endregion@@ -37,6 +41,7 @@ public class AddressAttributeService : IAddressAttributeServiceprivate readonly IRepository<AddressAttribute> _addressAttributeRepository;private readonly IMediator _mediator;private readonly ICacheBase _cacheBase;+ private readonly AccessControlConfig _accessControlConfig;#endregion@@ -48,12 +53,32 @@ public class AddressAttributeService : IAddressAttributeService/// <returns>Address attributes</returns>public virtual async Task<IList<AddressAttribute>> GetAllAddressAttributes(){- var key = CacheKey.ADDRESSATTRIBUTES_ALL_KEY;+ return await GetAllAddressAttributes(string.Empty);+ }++ /// <summary>+ /// Gets all address attributes for the specified store+ /// </summary>+ /// <param name="storeId">Store identifier</param>+ /// <returns>Address attributes</returns>+ public virtual async Task<IList<AddressAttribute>> GetAllAddressAttributes(string storeId)+ {+ var key = string.IsNullOrEmpty(storeId)+ ? CacheKey.ADDRESSATTRIBUTES_ALL_KEY+ : $"{CacheKey.ADDRESSATTRIBUTES_ALL_KEY}.{storeId}";return await _cacheBase.GetAsync(key, async () =>{var query = from aa in _addressAttributeRepository.Table- orderby aa.DisplayOrderselect aa;++ query = query.OrderBy(aa => aa.DisplayOrder);++ //Store acl+ if (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations)+ query = from aa in query+ where !aa.LimitedToStores || aa.Stores.Contains(storeId)+ select aa;+return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Core/Interfaces/Common/Addresses/IAddressAttributeParser.cs b/src/Business/Grand.Business.Core/Interfaces/Common/Addresses/IAddressAttributeParser.csindex 0c074c2fe..27a1f0415 100644--- a/src/Business/Grand.Business.Core/Interfaces/Common/Addresses/IAddressAttributeParser.cs+++ b/src/Business/Grand.Business.Core/Interfaces/Common/Addresses/IAddressAttributeParser.cs@@ -39,6 +39,14 @@ public interface IAddressAttributeParser/// <returns>Warnings</returns>Task<IList<string>> GetAttributeWarnings(IList<CustomAttribute> customAttributes);+ /// <summary>+ /// Validates address attributes limited to the specified store+ /// </summary>+ /// <param name="customAttributes">Attributes</param>+ /// <param name="storeId">Store identifier</param>+ /// <returns>Warnings</returns>+ Task<IList<string>> GetAttributeWarnings(IList<CustomAttribute> customAttributes, string storeId);+/// <summary>/// Formats attributes/// </summary>diff --git a/src/Business/Grand.Business.Core/Interfaces/Common/Addresses/IAddressAttributeService.cs b/src/Business/Grand.Business.Core/Interfaces/Common/Addresses/IAddressAttributeService.csindex ad4223fba..4dfc6ed12 100644--- a/src/Business/Grand.Business.Core/Interfaces/Common/Addresses/IAddressAttributeService.cs+++ b/src/Business/Grand.Business.Core/Interfaces/Common/Addresses/IAddressAttributeService.cs@@ -13,6 +13,13 @@ public interface IAddressAttributeService/// <returns>Address attributes</returns>Task<IList<AddressAttribute>> GetAllAddressAttributes();+ /// <summary>+ /// Gets all address attributes for the specified store+ /// </summary>+ /// <param name="storeId">Store identifier</param>+ /// <returns>Address attributes</returns>+ Task<IList<AddressAttribute>> GetAllAddressAttributes(string storeId);+/// <summary>/// Gets an address attribute/// </summary>diff --git a/src/Business/Grand.Business.Core/Interfaces/Customers/ICustomerAttributeParser.cs b/src/Business/Grand.Business.Core/Interfaces/Customers/ICustomerAttributeParser.csindex 03752a0df..9b1e0ab51 100644--- a/src/Business/Grand.Business.Core/Interfaces/Customers/ICustomerAttributeParser.cs+++ b/src/Business/Grand.Business.Core/Interfaces/Customers/ICustomerAttributeParser.cs@@ -40,6 +40,14 @@ public interface ICustomerAttributeParser/// <returns>Warnings</returns>Task<IList<string>> GetAttributeWarnings(IList<CustomAttribute> customAttributes);+ /// <summary>+ /// Validates customer attributes limited to the specified store+ /// </summary>+ /// <param name="customAttributes">Attributes</param>+ /// <param name="storeId">Store identifier</param>+ /// <returns>Warnings</returns>+ Task<IList<string>> GetAttributeWarnings(IList<CustomAttribute> customAttributes, string storeId);+/// <summary>/// Formats attributes/// </summary>diff --git a/src/Business/Grand.Business.Core/Interfaces/Customers/ICustomerAttributeService.cs b/src/Business/Grand.Business.Core/Interfaces/Customers/ICustomerAttributeService.csindex f89872780..c94fd1ef3 100644--- a/src/Business/Grand.Business.Core/Interfaces/Customers/ICustomerAttributeService.cs+++ b/src/Business/Grand.Business.Core/Interfaces/Customers/ICustomerAttributeService.cs@@ -13,6 +13,13 @@ public interface ICustomerAttributeService/// <returns>Customer attributes</returns>Task<IList<CustomerAttribute>> GetAllCustomerAttributes();+ /// <summary>+ /// Gets all customer attributes for the specified store+ /// </summary>+ /// <param name="storeId">Store identifier</param>+ /// <returns>Customer attributes</returns>+ Task<IList<CustomerAttribute>> GetAllCustomerAttributes(string storeId);+/// <summary>/// Gets a customer attribute/// </summary>diff --git a/src/Business/Grand.Business.Customers/Services/CustomerAttributeParser.cs b/src/Business/Grand.Business.Customers/Services/CustomerAttributeParser.csindex 7b4f7ef67..421d34401 100644--- a/src/Business/Grand.Business.Customers/Services/CustomerAttributeParser.cs+++ b/src/Business/Grand.Business.Customers/Services/CustomerAttributeParser.cs@@ -93,6 +93,18 @@ public class CustomerAttributeParser : ICustomerAttributeParser/// <param name="customAttributes">Attributes</param>/// <returns>Warnings</returns>public virtual async Task<IList<string>> GetAttributeWarnings(IList<CustomAttribute> customAttributes)+ {+ return await GetAttributeWarnings(customAttributes, string.Empty);+ }++ /// <summary>+ /// Validates customer attributes limited to the specified store+ /// </summary>+ /// <param name="customAttributes">Attributes</param>+ /// <param name="storeId">Store identifier</param>+ /// <returns>Warnings</returns>+ public virtual async Task<IList<string>> GetAttributeWarnings(IList<CustomAttribute> customAttributes,+ string storeId){var warnings = new List<string>();@@ -103,7 +115,7 @@ public class CustomerAttributeParser : ICustomerAttributeParservar attributes1 = await ParseCustomerAttributes(customAttributes);//validate required customer attributes (whether they're chosen/selected/entered)- var attributes2 = await _customerAttributeService.GetAllCustomerAttributes();+ var attributes2 = await _customerAttributeService.GetAllCustomerAttributes(storeId ?? string.Empty);foreach (var a2 in attributes2){if (!a2.IsRequired) continue;diff --git a/src/Business/Grand.Business.Customers/Services/CustomerAttributeService.cs b/src/Business/Grand.Business.Customers/Services/CustomerAttributeService.csindex 74b57b653..3cf66a89b 100644--- a/src/Business/Grand.Business.Customers/Services/CustomerAttributeService.cs+++ b/src/Business/Grand.Business.Customers/Services/CustomerAttributeService.cs@@ -3,6 +3,7 @@ using Grand.Data;using Grand.Domain.Customers;using Grand.Infrastructure.Caching;using Grand.Infrastructure.Caching.Constants;+using Grand.Infrastructure.Configuration;using Grand.Infrastructure.Extensions;using MediatR;@@ -21,13 +22,16 @@ public class CustomerAttributeService : ICustomerAttributeService/// <param name="cacheBase">Cache manager</param>/// <param name="customerAttributeRepository">Customer attribute repository</param>/// <param name="mediator">Mediator</param>+ /// <param name="accessControlConfig">Access control config</param>public CustomerAttributeService(ICacheBase cacheBase,IRepository<CustomerAttribute> customerAttributeRepository,- IMediator mediator)+ IMediator mediator,+ AccessControlConfig accessControlConfig){_cacheBase = cacheBase;_customerAttributeRepository = customerAttributeRepository;_mediator = mediator;+ _accessControlConfig = accessControlConfig;}#endregion@@ -37,6 +41,7 @@ public class CustomerAttributeService : ICustomerAttributeServiceprivate readonly IRepository<CustomerAttribute> _customerAttributeRepository;private readonly IMediator _mediator;private readonly ICacheBase _cacheBase;+ private readonly AccessControlConfig _accessControlConfig;#endregion@@ -48,12 +53,32 @@ public class CustomerAttributeService : ICustomerAttributeService/// <returns>Customer attributes</returns>public virtual async Task<IList<CustomerAttribute>> GetAllCustomerAttributes(){- var key = CacheKey.CUSTOMERATTRIBUTES_ALL_KEY;+ return await GetAllCustomerAttributes(string.Empty);+ }++ /// <summary>+ /// Gets all customer attributes for the specified store+ /// </summary>+ /// <param name="storeId">Store identifier</param>+ /// <returns>Customer attributes</returns>+ public virtual async Task<IList<CustomerAttribute>> GetAllCustomerAttributes(string storeId)+ {+ var key = string.IsNullOrEmpty(storeId)+ ? CacheKey.CUSTOMERATTRIBUTES_ALL_KEY+ : $"{CacheKey.CUSTOMERATTRIBUTES_ALL_KEY}.{storeId}";return await _cacheBase.GetAsync(key, async () =>{var query = from ca in _customerAttributeRepository.Table- orderby ca.DisplayOrderselect ca;++ query = query.OrderBy(ca => ca.DisplayOrder);++ //Store acl+ if (!string.IsNullOrEmpty(storeId) && !_accessControlConfig.IgnoreStoreLimitations)+ query = from ca in query+ where !ca.LimitedToStores || ca.Stores.Contains(storeId)+ select ca;+return await Task.FromResult(query.ToList());});}diff --git a/src/Core/Grand.Domain/Common/AddressAttribute.cs b/src/Core/Grand.Domain/Common/AddressAttribute.csindex dddafe4e8..3ae14065c 100644--- a/src/Core/Grand.Domain/Common/AddressAttribute.cs+++ b/src/Core/Grand.Domain/Common/AddressAttribute.cs@@ -1,12 +1,13 @@using Grand.Domain.Catalog;using Grand.Domain.Localization;+using Grand.Domain.Stores;namespace Grand.Domain.Common;/// <summary>/// Represents an address attribute/// </summary>-public class AddressAttribute : BaseEntity, ITranslationEntity+public class AddressAttribute : BaseEntity, ITranslationEntity, IStoreLinkEntity{private ICollection<AddressAttributeValue> _addressAttributeValues;@@ -51,4 +52,11 @@ public class AddressAttribute : BaseEntity, ITranslationEntity/// Gets or sets the collection of locales/// </summary>public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();++ /// <summary>+ /// Gets or sets a value indicating whether the entity is limited/restricted to certain stores+ /// </summary>+ public bool LimitedToStores { get; set; }++ public IList<string> Stores { get; set; } = new List<string>();}\ No newline at end of filediff --git a/src/Core/Grand.Domain/Customers/CustomerAttribute.cs b/src/Core/Grand.Domain/Customers/CustomerAttribute.csindex 4965ab966..f28802132 100644--- a/src/Core/Grand.Domain/Customers/CustomerAttribute.cs+++ b/src/Core/Grand.Domain/Customers/CustomerAttribute.cs@@ -1,12 +1,13 @@using Grand.Domain.Catalog;using Grand.Domain.Localization;+using Grand.Domain.Stores;namespace Grand.Domain.Customers;/// <summary>/// Represents a customer attribute/// </summary>-public class CustomerAttribute : BaseEntity, ITranslationEntity+public class CustomerAttribute : BaseEntity, ITranslationEntity, IStoreLinkEntity{private ICollection<CustomerAttributeValue> _customerAttributeValues;@@ -47,4 +48,11 @@ public class CustomerAttribute : BaseEntity, ITranslationEntity/// Gets or sets the collection of locales/// </summary>public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();++ /// <summary>+ /// Gets or sets a value indicating whether the entity is limited/restricted to certain stores+ /// </summary>+ public bool LimitedToStores { get; set; }++ public IList<string> Stores { get; set; } = new List<string>();}\ No newline at end of filediff --git a/src/Tests/Grand.Business.Common.Tests/Services/Addresses/AddressAttributeServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Addresses/AddressAttributeServiceTests.csindex bbfa56180..9b74cb9f5 100644--- a/src/Tests/Grand.Business.Common.Tests/Services/Addresses/AddressAttributeServiceTests.cs+++ b/src/Tests/Grand.Business.Common.Tests/Services/Addresses/AddressAttributeServiceTests.cs@@ -3,6 +3,7 @@ using Grand.Data;using Grand.Data.Mongo;using Grand.Domain.Common;using Grand.Infrastructure.Caching;+using Grand.Infrastructure.Configuration;using Grand.Infrastructure.Events;using Grand.SharedKernel.Extensions;using MediatR;@@ -27,7 +28,8 @@ public class AddressAttributeServiceTests_cacheMock = new Mock<ICacheBase>();_repositoryMock = new Mock<MongoRepository<AddressAttribute>>(Mock.Of<IAuditInfoProvider>());_mediatorMock = new Mock<IMediator>();- _service = new AddressAttributeService(_cacheMock.Object, _repositoryMock.Object, _mediatorMock.Object);+ _service = new AddressAttributeService(_cacheMock.Object, _repositoryMock.Object, _mediatorMock.Object,+ new AccessControlConfig());}[TestMethod]diff --git a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerAttributeParserTests.cs b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerAttributeParserTests.csindex 1af4f1a29..9b05b7167 100644--- a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerAttributeParserTests.cs+++ b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerAttributeParserTests.cs@@ -99,7 +99,7 @@ public class CustomerAttributeParserTests[TestMethod]public async Task GetAttributeWarnings_Return_NoWarning(){- _customerAtrServiceMock.Setup(c => c.GetAllCustomerAttributes())+ _customerAtrServiceMock.Setup(c => c.GetAllCustomerAttributes(It.IsAny<string>())).Returns(() => Task.FromResult((IList<CustomerAttribute>)_customerAtr));_customerAtrServiceMock.Setup(c => c.GetCustomerAttributeById(It.IsAny<string>())).Returns((string w) =>Task.FromResult(_customerAtr.FirstOrDefault(a => a.Id.Equals(w))));@@ -111,7 +111,7 @@ public class CustomerAttributeParserTestspublic async Task GetAttributeWarnings_Return_WithWarning(){_customerAtr.FirstOrDefault(x => x.Id == "key5").IsRequired = true;- _customerAtrServiceMock.Setup(c => c.GetAllCustomerAttributes())+ _customerAtrServiceMock.Setup(c => c.GetAllCustomerAttributes(It.IsAny<string>())).Returns(() => Task.FromResult((IList<CustomerAttribute>)_customerAtr));_customerAtrServiceMock.Setup(c => c.GetCustomerAttributeById(It.IsAny<string>())).Returns((string w) =>Task.FromResult(_customerAtr.FirstOrDefault(a => a.Id.Equals(w))));diff --git a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerAttributeServiceTests.cs b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerAttributeServiceTests.csindex 0072e583d..e085167e3 100644--- a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerAttributeServiceTests.cs+++ b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerAttributeServiceTests.cs@@ -2,6 +2,7 @@using Grand.Data;using Grand.Domain.Customers;using Grand.Infrastructure.Caching;+using Grand.Infrastructure.Configuration;using Grand.Infrastructure.Events;using MediatR;using Microsoft.VisualStudio.TestTools.UnitTesting;@@ -23,7 +24,8 @@ public class CustomerAttributeServiceTests_cacheMock = new Mock<ICacheBase>();_repositoryMock = new Mock<IRepository<CustomerAttribute>>();_mediatorMock = new Mock<IMediator>();- _atrService = new CustomerAttributeService(_cacheMock.Object, _repositoryMock.Object, _mediatorMock.Object);+ _atrService = new CustomerAttributeService(_cacheMock.Object, _repositoryMock.Object, _mediatorMock.Object,+ new AccessControlConfig());}[TestMethod]diff --git a/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.AddressAttributeModel_ToDomain.verified.txt b/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.AddressAttributeModel_ToDomain.verified.txtindex 146d5dde0..981196b6b 100644--- a/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.AddressAttributeModel_ToDomain.verified.txt+++ b/src/Tests/Grand.Mapping.Tests/AdminShared/CommonMappingTests.AddressAttributeModel_ToDomain.verified.txt@@ -4,5 +4,6 @@AttributeControlTypeId: 1,DisplayOrder: 1,AttributeControlType: DropdownList,+ LimitedToStores: false,Id: ObjectId_1}\ No newline at end of filediff --git a/src/Tests/Grand.Mapping.Tests/AdminShared/CustomerMappingTests.CustomerAttributeModel_ToDomain.verified.txt b/src/Tests/Grand.Mapping.Tests/AdminShared/CustomerMappingTests.CustomerAttributeModel_ToDomain.verified.txtindex 60adbf5d0..68610d81c 100644--- a/src/Tests/Grand.Mapping.Tests/AdminShared/CustomerMappingTests.CustomerAttributeModel_ToDomain.verified.txt+++ b/src/Tests/Grand.Mapping.Tests/AdminShared/CustomerMappingTests.CustomerAttributeModel_ToDomain.verified.txt@@ -4,5 +4,6 @@IsReadOnly: false,AttributeControlTypeId: RadioList,DisplayOrder: 1,+ LimitedToStores: false,Id: ObjectId_1}\ No newline at end of filediff --git a/src/Tests/Grand.Web.Tests/Validators/Customer/CustomerValidatorsStoreScopingTests.cs b/src/Tests/Grand.Web.Tests/Validators/Customer/CustomerValidatorsStoreScopingTests.csindex 1994fb4a1..89017bcb7 100644--- a/src/Tests/Grand.Web.Tests/Validators/Customer/CustomerValidatorsStoreScopingTests.cs+++ b/src/Tests/Grand.Web.Tests/Validators/Customer/CustomerValidatorsStoreScopingTests.cs@@ -82,7 +82,7 @@ public class CustomerValidatorsStoreScopingTestsmediator.Setup(m => m.Send(It.IsAny<GetParseCustomAttributes>(), It.IsAny<CancellationToken>())).ReturnsAsync(new List<CustomAttribute>());var attrParser = new Mock<ICustomerAttributeParser>();- attrParser.Setup(p => p.GetAttributeWarnings(It.IsAny<IList<CustomAttribute>>()))+ attrParser.Setup(p => p.GetAttributeWarnings(It.IsAny<IList<CustomAttribute>>(), It.IsAny<string>())).ReturnsAsync(new List<string>());var validator = new RegisterValidator(@@ -139,7 +139,7 @@ public class CustomerValidatorsStoreScopingTestsmediator.Setup(m => m.Send(It.IsAny<GetParseCustomAttributes>(), It.IsAny<CancellationToken>())).ReturnsAsync(new List<CustomAttribute>());var attrParser = new Mock<ICustomerAttributeParser>();- attrParser.Setup(p => p.GetAttributeWarnings(It.IsAny<IList<CustomAttribute>>()))+ attrParser.Setup(p => p.GetAttributeWarnings(It.IsAny<IList<CustomAttribute>>(), It.IsAny<string>())).ReturnsAsync(new List<string>());var validator = new CustomerInfoValidator(diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/AddressAttribute/Partials/CreateOrUpdate.TabInfo.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/AddressAttribute/Partials/CreateOrUpdate.TabInfo.cshtmlindex 4270607f1..f966fb3cd 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/AddressAttribute/Partials/CreateOrUpdate.TabInfo.cshtml+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/AddressAttribute/Partials/CreateOrUpdate.TabInfo.cshtml@@ -68,6 +68,13 @@<span asp-validation-for="AttributeControlTypeId"></span></div></div>+ <div class="form-group">+ <admin-label asp-for="Stores"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="Stores"/>+ <span asp-validation-for="Stores"></span>+ </div>+ </div><div class="form-group"><admin-label asp-for="DisplayOrder"/><div class="col-md-9 col-sm-9">diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/CustomerAttribute/Partials/CreateOrUpdate.TabInfo.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/CustomerAttribute/Partials/CreateOrUpdate.TabInfo.cshtmlindex c96e862cc..b7a29b415 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/CustomerAttribute/Partials/CreateOrUpdate.TabInfo.cshtml+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/CustomerAttribute/Partials/CreateOrUpdate.TabInfo.cshtml@@ -92,6 +92,13 @@<span asp-validation-for="AttributeControlTypeId"></span></div></div>+ <div class="form-group">+ <admin-label asp-for="Stores"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="Stores"/>+ <span asp-validation-for="Stores"></span>+ </div>+ </div><div class="form-group"><admin-label asp-for="DisplayOrder"/><div class="col-md-9 col-sm-9">diff --git a/src/Web/Grand.Web.AdminShared/Mapper/AddressAttributeProfile.cs b/src/Web/Grand.Web.AdminShared/Mapper/AddressAttributeProfile.csindex 381e921cb..f13d2b7fa 100644--- a/src/Web/Grand.Web.AdminShared/Mapper/AddressAttributeProfile.cs+++ b/src/Web/Grand.Web.AdminShared/Mapper/AddressAttributeProfile.cs@@ -17,6 +17,7 @@ public class AddressAttributeProfile : Profile, IAutoMapperProfile.ForMember(dest => dest.Id, mo => mo.Ignore()).ForMember(dest => dest.Locales, mo => mo.MapFrom(x => x.Locales.ToTranslationProperty())).ForMember(dest => dest.AttributeControlType, mo => mo.Ignore())+ .ForMember(dest => dest.LimitedToStores, mo => mo.MapFrom(x => x.Stores != null && x.Stores.Any())).ForMember(dest => dest.AddressAttributeValues, mo => mo.Ignore());}diff --git a/src/Web/Grand.Web.AdminShared/Mapper/CustomerAttributeProfile.cs b/src/Web/Grand.Web.AdminShared/Mapper/CustomerAttributeProfile.csindex 73c274f66..5d0b07c1b 100644--- a/src/Web/Grand.Web.AdminShared/Mapper/CustomerAttributeProfile.cs+++ b/src/Web/Grand.Web.AdminShared/Mapper/CustomerAttributeProfile.cs@@ -17,6 +17,7 @@ public class CustomerAttributeProfile : Profile, IAutoMapperProfileCreateMap<CustomerAttributeModel, CustomerAttribute>().ForMember(dest => dest.Id, mo => mo.Ignore()).ForMember(dest => dest.Locales, mo => mo.MapFrom(x => x.Locales.ToTranslationProperty()))+ .ForMember(dest => dest.LimitedToStores, mo => mo.MapFrom(x => x.Stores != null && x.Stores.Any())).ForMember(dest => dest.CustomerAttributeValues, mo => mo.Ignore());}diff --git a/src/Web/Grand.Web.AdminShared/Models/Common/AddressAttributeModel.cs b/src/Web/Grand.Web.AdminShared/Models/Common/AddressAttributeModel.csindex 5e420e8f0..37f04b971 100644--- a/src/Web/Grand.Web.AdminShared/Models/Common/AddressAttributeModel.cs+++ b/src/Web/Grand.Web.AdminShared/Models/Common/AddressAttributeModel.cs@@ -1,10 +1,13 @@using Grand.Infrastructure.ModelBinding;using Grand.Infrastructure.Models;+using Grand.Web.Common.Link;using Grand.Web.Common.Models;+using System.ComponentModel.DataAnnotations;namespace Grand.Web.AdminShared.Models.Common;-public class AddressAttributeModel : BaseEntityModel, ILocalizedModel<AddressAttributeLocalizedModel>+public class AddressAttributeModel : BaseEntityModel, ILocalizedModel<AddressAttributeLocalizedModel>,+ IStoreLinkModel{[GrandResourceDisplayName("Admin.Address.AddressAttributes.Fields.Name")]@@ -23,6 +26,10 @@ public class AddressAttributeModel : BaseEntityModel, ILocalizedModel<AddressAtt[GrandResourceDisplayName("Admin.Address.AddressAttributes.Fields.DisplayOrder")]public int DisplayOrder { get; set; }+ //Store acl+ [GrandResourceDisplayName("Admin.Address.AddressAttributes.Fields.LimitedToStores")]+ [UIHint("Stores")]+ public string[] Stores { get; set; }public IList<AddressAttributeLocalizedModel> Locales { get; set; } = new List<AddressAttributeLocalizedModel>();}diff --git a/src/Web/Grand.Web.AdminShared/Models/Customers/CustomerAttributeModel.cs b/src/Web/Grand.Web.AdminShared/Models/Customers/CustomerAttributeModel.csindex 2b920b5d1..65a371870 100644--- a/src/Web/Grand.Web.AdminShared/Models/Customers/CustomerAttributeModel.cs+++ b/src/Web/Grand.Web.AdminShared/Models/Customers/CustomerAttributeModel.cs@@ -1,10 +1,13 @@using Grand.Infrastructure.ModelBinding;using Grand.Infrastructure.Models;+using Grand.Web.Common.Link;using Grand.Web.Common.Models;+using System.ComponentModel.DataAnnotations;namespace Grand.Web.AdminShared.Models.Customers;-public class CustomerAttributeModel : BaseEntityModel, ILocalizedModel<CustomerAttributeLocalizedModel>+public class CustomerAttributeModel : BaseEntityModel, ILocalizedModel<CustomerAttributeLocalizedModel>,+ IStoreLinkModel{[GrandResourceDisplayName("Admin.Customers.CustomerAttributes.Fields.Name")]public string Name { get; set; }@@ -25,6 +28,10 @@ public class CustomerAttributeModel : BaseEntityModel, ILocalizedModel<CustomerA[GrandResourceDisplayName("Admin.Customers.CustomerAttributes.Fields.DisplayOrder")]public int DisplayOrder { get; set; }+ //Store acl+ [GrandResourceDisplayName("Admin.Customers.CustomerAttributes.Fields.LimitedToStores")]+ [UIHint("Stores")]+ public string[] Stores { get; set; }public IList<CustomerAttributeLocalizedModel> Locales { get; set; } = new List<CustomerAttributeLocalizedModel>();}diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Create.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Create.cshtmlnew file mode 100644index 000000000..6c551d80a--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Create.cshtml@@ -0,0 +1,35 @@+@model AddressAttributeStoreModel+@{+ ViewBag.Title = Loc["Admin.Address.AddressAttributes.AddNew"];+}+<form asp-area="@Constants.AreaStore" asp-controller="AddressAttribute" asp-action="Create" method="post" id="addressattribute-form">++ <div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-list-alt"></i>+ @Loc["Admin.Address.AddressAttributes.AddNew"]+ <small>+ <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Address.AddressAttributes.BackToList"], "List")+ </small>+ </div>+ <div class="actions">+ <div class="btn-group btn-group-devided">+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]+ </button>+ <button class="btn btn-success" type="submit" name="save-continue">+ <i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]+ </button>+ </div>+ </div>+ </div>+ <div class="x_content form">+ <partial name="Partials/CreateOrUpdate" model="Model"/>+ </div>+ </div>+ </div>+ </div>+</form>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Edit.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Edit.cshtmlnew file mode 100644index 000000000..572cb4529--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Edit.cshtml@@ -0,0 +1,54 @@+@model AddressAttributeStoreModel+@{+ var isReadOnly = Model.IsGlobalAttribute;+ ViewBag.Title = Loc["Admin.Address.AddressAttributes.EditAttributeDetails"];+}+<form asp-area="@Constants.AreaStore" asp-controller="AddressAttribute" asp-action="Edit" method="post" id="addressattribute-form">++ <div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-list-alt"></i>+ @Loc["Admin.Address.AddressAttributes.EditAttributeDetails"] - @Model.Name+ <small>+ <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Address.AddressAttributes.BackToList"], "List")+ </small>+ </div>+ @if (!isReadOnly)+ {+ <div class="actions">+ <div class="btn-group btn-group-devided util-btn-margin-bottom-5">+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]+ </button>+ <button class="btn btn-success" type="submit" name="save-continue">+ <i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]+ </button>+ <span id="addressattribute-delete" class="btn red">+ <i class="fa fa-trash-o"></i> @Loc["Admin.Common.Delete"]+ </span>+ </div>+ </div>+ }+ else+ {+ <div class="actions">+ <div class="alert alert-info mb-0 py-2">+ <i class="fa fa-info-circle"></i> @Loc["Admin.Address.AddressAttributes.GlobalReadOnly"]+ </div>+ </div>+ }+ </div>+ <div class="x_content form">+ <partial name="Partials/CreateOrUpdate" model="Model"/>+ </div>+ </div>+ </div>+ </div>+</form>+@if (!isReadOnly)+{+ <admin-delete-confirmation button-id="addressattribute-delete"/>+}diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/List.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/List.cshtmlnew file mode 100644index 000000000..62ec137e6--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/List.cshtml@@ -0,0 +1,97 @@+@{+ ViewBag.Title = Loc["Admin.Address.AddressAttributes"];+}++<div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-list-alt"></i>+ @Loc["Admin.Address.AddressAttributes"]+ </div>+ <div class="actions btn-group btn-group-devided">+ <a href="@Url.Action("Create", new { area = Constants.AreaStore })" class="btn green">+ <i class="fa fa-plus"></i><span class="d-none d-sm-inline"> @Loc["Admin.Common.AddNew"] </span>+ </a>+ </div>+ </div>+ <div class="x_content form">+ <div class="form-horizontal">+ <div class="form-body">+ <div class="x_content">+ <div id="addressattributes-grid"></div>+ </div>+ </div>+ </div>+ </div>+ </div>+ </div>+</div>++<script>+ $(document).ready(function () {+ $("#addressattributes-grid").kendoGrid({+ dataSource: {+ transport: {+ read: {+ url: "@Html.Raw(Url.Action("List", "AddressAttribute", new { area = Constants.AreaStore }))",+ type: "POST",+ dataType: "json",+ data: addAntiForgeryToken+ }+ },+ schema: {+ data: "Data",+ total: "Total",+ errors: "Errors"+ },+ error: function(e) {+ display_kendoui_grid_error(e);+ this.cancelChanges();+ },+ serverPaging: true,+ serverFiltering: true,+ serverSorting: true+ },+ pageable: {+ refresh: true,+ numeric: false,+ previousNext: false,+ info: false+ },+ scrollable: false,+ columns: [{+ field: "Name",+ title: "@Loc["Admin.Address.AddressAttributes.Fields.Name"]",+ template: '<a class="k-link" href="Edit/#=Id#">#=kendo.htmlEncode(Name)#</a>'+ }, {+ field: "AttributeControlTypeName",+ title: "@Loc["Admin.Address.AddressAttributes.Fields.AttributeControlType"]",+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ width: 200,+ minScreenWidth: 750+ }, {+ field: "IsRequired",+ title: "@Loc["Admin.Address.AddressAttributes.Fields.IsRequired"]",+ width: 100,+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ template: '# if(IsRequired) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'+ }, {+ field: "DisplayOrder",+ title: "@Loc["Admin.Address.AddressAttributes.Fields.DisplayOrder"]",+ width: 100,+ minScreenWidth: 750+ }, {+ field: "IsGlobalAttribute",+ title: "@Loc["Admin.Common.View"]",+ width: 120,+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ template: '# if(IsGlobalAttribute) {# <span class="badge badge-secondary">@Loc["Admin.Common.View"]</span> #} else {# <span class="badge badge-success">@Loc["Admin.Common.Edit"]</span> #} #'+ }]+ });+ });+</script>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Partials/CreateOrUpdate.TabInfo.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Partials/CreateOrUpdate.TabInfo.cshtmlnew file mode 100644index 000000000..de254bef5--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Partials/CreateOrUpdate.TabInfo.cshtml@@ -0,0 +1,81 @@+@using Microsoft.AspNetCore.Mvc.Razor+@model AddressAttributeStoreModel+@{+ var isReadOnly = Model.IsGlobalAttribute;+}+<script>+ $(document).ready(function () {+ $("#@Html.IdFor(model => model.AttributeControlTypeId)").change(toggleAttributeControlType);+ toggleAttributeControlType();++ });+ function toggleAttributeControlType() {+ var selectedAttributeControlTypeId = $("#@Html.IdFor(model => model.AttributeControlTypeId)").val();+ if (selectedAttributeControlTypeId == @(((int)AttributeControlType.TextBox).ToString())) {+ $('#tab-addressattributesvalues').hide();+ } else if (selectedAttributeControlTypeId == @(((int)AttributeControlType.MultilineTextbox).ToString())) {+ $('#tab-addressattributesvalues').hide();+ } else {+ $('#tab-addressattributesvalues').show();+ }+ }++</script>+@{+ Func<int, HelperResult>+ template = @<div class="form-body">+ <div class="form-group">+ <admin-label asp-for="@Model.Locales[item].Name"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="@Model.Locales[item].Name" disabled="@isReadOnly"/>+ <span asp-validation-for="@Model.Locales[item].Name"></span>+ </div>+ </div>+ <input type="hidden" asp-for="@Model.Locales[item].LanguageId"/>+ </div>;+}++<div class="form-horizontal">+ <localized-editor localized-template="@template" name="addressattribute-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">+ <div class="form-body">+ <div class="form-group">+ <admin-label asp-for="Name"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="Name" disabled="@isReadOnly"/>+ <span asp-validation-for="Name"></span>+ </div>+ </div>+ </div>+ </localized-editor>+ <div class="form-body">+ <div class="form-group">+ <admin-label asp-for="IsRequired"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="IsRequired" disabled="@isReadOnly"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="IsRequired"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="AttributeControlTypeId"/>+ <div class="col-md-9 col-sm-9">+ @{+ var attributeControlTypes = EnumTranslationService.ToSelectList(((AttributeControlType)Model.AttributeControlTypeId), valuesToExclude:+ //custom address attributes don't support some attribute control types+ [(int)AttributeControlType.Hidden, (int)AttributeControlType.FileUpload, (int)AttributeControlType.Datepicker, (int)AttributeControlType.ColorSquares, (int)AttributeControlType.ImageSquares]);+ }+ <admin-select asp-for="AttributeControlTypeId" asp-items="attributeControlTypes" disabled="@isReadOnly"/>+ <span asp-validation-for="AttributeControlTypeId"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="DisplayOrder"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="DisplayOrder" disabled="@isReadOnly"/>+ <span asp-validation-for="DisplayOrder"></span>+ </div>+ </div>+ </div>+</div>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Partials/CreateOrUpdate.TabValues.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Partials/CreateOrUpdate.TabValues.cshtmlnew file mode 100644index 000000000..cca808934--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Partials/CreateOrUpdate.TabValues.cshtml@@ -0,0 +1,182 @@+@model AddressAttributeStoreModel+@{+ var isReadOnly = Model.IsGlobalAttribute;++ if (!string.IsNullOrEmpty(Model.Id))+ {+ <div class="panel panel-default">+ <div class="panel-body">+ <div id="addressattributevalues-grid"></div>+ </div>+ @if (!isReadOnly)+ {+ <div class="panel-footer">+ <a id="btnAddNewValue" href="@(Url.Action("ValueCreatePopup", "AddressAttribute", new { addressAttributeId = Model.Id, area = Constants.AreaStore }))" class="k-button"><i class="fa fa-plus"></i> @Loc["Admin.Address.AddressAttributes.Values.AddNew"]</a>+ <input type="submit" id="btnRefresh" style="display: none"/>+ </div>+ }+ else+ {+ <input type="submit" id="btnRefresh" style="display: none"/>+ }+ </div>++ if (!isReadOnly)+ {+ <script>+ $(document).ready(function () {+ $('#btnAddNewValue').magnificPopup({+ type: 'ajax',+ settings: { cache: false, async: false },+ midClick: true,+ callbacks: {+ parseAjax: function (mfpResponse) {+ mfpResponse.data = $('<div></div>').html(mfpResponse.data);+ },+ ajaxContentAdded: function () {+ $('.mfp-wrap').removeAttr('tabindex');+ }+ }+ });++ $("#addressattributevalues-grid").kendoGrid({+ dataBound: function () {+ $('.editvalue').magnificPopup({+ type: 'ajax',+ settings: { cache: false, async: false },+ midClick: true,+ callbacks: {+ parseAjax: function (mfpResponse) {+ mfpResponse.data = $('<div></div>').html(mfpResponse.data);+ },+ ajaxContentAdded: function () {+ $('.mfp-wrap').removeAttr('tabindex');+ }+ }+ });+ },+ dataSource: {+ transport: {+ read: {+ url: "@Html.Raw(Url.Action("ValueList", "AddressAttribute", new { addressAttributeId = Model.Id, area = Constants.AreaStore }))",+ type: "POST",+ dataType: "json",+ data: addAntiForgeryToken+ },+ destroy: {+ url: "@Html.Raw(Url.Action("ValueDelete", "AddressAttribute", new { area = Constants.AreaStore }))",+ type: "POST",+ dataType: "json",+ data: addAntiForgeryToken+ }+ },+ schema: {+ data: "Data",+ total: "Total",+ errors: "Errors",+ model: { id: "Id", fields: { AddressAttributeId: { editable: false } } }+ },+ error: function(e) {+ display_kendoui_grid_error(e);+ this.cancelChanges();+ },+ serverPaging: true,+ serverFiltering: true,+ serverSorting: true+ },+ pageable: { refresh: true, numeric: false, previousNext: false, info: false },+ editable: { confirmation: true, mode: "inline" },+ scrollable: false,+ columns: [{+ field: "Name",+ title: "@Loc["Admin.Address.AddressAttributes.Values.Fields.Name"]",+ template: "<a class='k-link editvalue' href=\"@Url.Action("ValueEditPopup", "AddressAttribute", new { area = Constants.AreaStore })/#=Id#[email protected]\">#=kendo.htmlEncode(Name)#</a>"+ }, {+ field: "IsPreSelected",+ title: "@Loc["Admin.Address.AddressAttributes.Values.Fields.IsPreSelected"]",+ width: 100,+ minScreenWidth: 500,+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ template: '# if(IsPreSelected) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'+ }, {+ field: "DisplayOrder",+ title: "@Loc["Admin.Address.AddressAttributes.Values.Fields.DisplayOrder"]",+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ width: 100+ }, {+ command: { name: "destroy", text: "@Loc["Admin.Common.Delete"]" },+ title: "@Loc["Admin.Common.Delete"]",+ width: 100+ }]+ });++ $('#btnRefresh').click(function () {+ var grid = $("#addressattributevalues-grid").data('kendoGrid');+ grid.dataSource.read();+ return false;+ });+ });+ </script>+ }+ else+ {+ <script>+ $(document).ready(function () {+ $("#addressattributevalues-grid").kendoGrid({+ dataSource: {+ transport: {+ read: {+ url: "@Html.Raw(Url.Action("ValueList", "AddressAttribute", new { addressAttributeId = Model.Id, area = Constants.AreaStore }))",+ type: "POST",+ dataType: "json",+ data: addAntiForgeryToken+ }+ },+ schema: {+ data: "Data",+ total: "Total",+ errors: "Errors",+ model: { id: "Id" }+ },+ error: function(e) {+ display_kendoui_grid_error(e);+ this.cancelChanges();+ },+ serverPaging: true,+ serverFiltering: true,+ serverSorting: true+ },+ pageable: { refresh: true, numeric: false, previousNext: false, info: false },+ scrollable: false,+ columns: [{+ field: "Name",+ title: "@Loc["Admin.Address.AddressAttributes.Values.Fields.Name"]"+ }, {+ field: "IsPreSelected",+ title: "@Loc["Admin.Address.AddressAttributes.Values.Fields.IsPreSelected"]",+ width: 100,+ minScreenWidth: 500,+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ template: '# if(IsPreSelected) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'+ }, {+ field: "DisplayOrder",+ title: "@Loc["Admin.Address.AddressAttributes.Values.Fields.DisplayOrder"]",+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ width: 100+ }]+ });+ });+ </script>+ }+ }+ else+ {+ <div class="note note-info">+ @Loc["Admin.Address.AddressAttributes.Values.SaveBeforeEdit"]+ </div>+ }+}diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Partials/CreateOrUpdate.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Partials/CreateOrUpdate.cshtmlnew file mode 100644index 000000000..dad3a2e0b--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Partials/CreateOrUpdate.cshtml@@ -0,0 +1,23 @@+@model AddressAttributeStoreModel++<div asp-validation-summary="All"></div>+<input asp-for="Id" type="hidden"/>++<admin-tabstrip name="addressattribute-edit">+ <items>+ <tabstrip-item text="@Loc["Admin.Address.AddressAttributes.Info"]" tab-index="0">+ <content>+ <div>+ <partial name="Partials/CreateOrUpdate.TabInfo" model="Model"/>+ </div>+ </content>+ </tabstrip-item>+ <tabstrip-item text="@Loc["Admin.Address.AddressAttributes.Values"]" tab-index="1" id="tab-addressattributesvalues">+ <content>+ <div>+ <partial name="Partials/CreateOrUpdate.TabValues" model="Model"/>+ </div>+ </content>+ </tabstrip-item>+ </items>+</admin-tabstrip>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Partials/CreateOrUpdateValue.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Partials/CreateOrUpdateValue.cshtmlnew file mode 100644index 000000000..32471312e--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/Partials/CreateOrUpdateValue.cshtml@@ -0,0 +1,58 @@+@using Microsoft.AspNetCore.Mvc.Razor+@model AddressAttributeValueModel+<div asp-validation-summary="All"></div>+<input asp-for="Id" type="hidden"/>+<input asp-for="AddressAttributeId" type="hidden"/>++@{+ Func<int, HelperResult>+ template = @<div class="form-body">+ <div class="form-group">+ <admin-label asp-for="@Model.Locales[item].Name"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="@Model.Locales[item].Name"/>+ <span asp-validation-for="@Model.Locales[item].Name"></span>+ </div>+ </div>+ <input type="hidden" asp-for="@Model.Locales[item].LanguageId"/>+ </div>;+}+<div class="form-horizontal">+ <localized-editor localized-template="@template" name="addressattributevalue-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">+ <div class="form-body">+ <div class="form-group">+ <admin-label asp-for="Name"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="Name"/>+ <span asp-validation-for="Name"></span>+ </div>+ </div>+ </div>+ </localized-editor>+ <div class="form-body">+ <div class="form-group">+ <admin-label asp-for="IsPreSelected"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="IsPreSelected"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="IsPreSelected"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="DisplayOrder"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="DisplayOrder"/>+ <span asp-validation-for="DisplayOrder"></span>+ </div>+ </div>+ <div class="form-group">+ <div class="offset-sm-3 offset-md-3 col-md-9 col-sm-9">+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]+ </button>+ </div>+ </div>+ </div>+</div>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/ValueCreatePopup.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/ValueCreatePopup.cshtmlnew file mode 100644index 000000000..8467d7e42--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/ValueCreatePopup.cshtml@@ -0,0 +1,54 @@+@using Grand.Web.Common.Extensions+@model AddressAttributeValueModel+@{+ Layout = "";+}+<form id="ValueCreatePopup" asp-area="@Constants.AreaStore" asp-controller="AddressAttribute" asp-action="ValueCreatePopup"+ asp-route-addressAttributeId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["addressAttributeId"])">+ <div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-list-alt"></i>+ @Loc["Admin.Address.AddressAttributes.Values.AddNew"]+ </div>+ </div>+ <div class="x_content form">+ <partial name="Partials/CreateOrUpdateValue" model="Model"/>+ </div>+ </div>+ </div>+ </div>+ <script>+ var mfp = $.magnificPopup.instance;+ $("#ValueCreatePopup").submit(function (e) {+ e.preventDefault();+ var form = $(this);+ var url = form.attr('action');+ $.ajax({+ type: "POST",+ url: url,+ data: form.serialize(),+ success: function (data) {+ if (data == "") {+ mfp.close();+ $('#btnRefresh').click();+ } else {+ $.magnificPopup.open({+ items: {+ src: data,+ type: 'inline'+ },+ callbacks: {+ open: function () {+ $('.mfp-wrap').removeAttr('tabindex');+ }+ }+ });+ }+ }+ });+ });+ </script>+</form>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/ValueEditPopup.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/ValueEditPopup.cshtmlnew file mode 100644index 000000000..c2b9bd21c--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/AddressAttribute/ValueEditPopup.cshtml@@ -0,0 +1,54 @@+@using Grand.Web.Common.Extensions+@model AddressAttributeValueModel+@{+ Layout = "";+}+<form id="ValueEditPopup" asp-area="@Constants.AreaStore" asp-controller="AddressAttribute" asp-action="ValueEditPopup"+ asp-route-addressAttributeId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["addressAttributeId"])">+ <div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-list-alt"></i>+ @Loc["Admin.Address.AddressAttributes.Values.EditValueDetails"]+ </div>+ </div>+ <div class="x_content form">+ <partial name="Partials/CreateOrUpdateValue" model="Model"/>+ </div>+ </div>+ </div>+ </div>+ <script>+ var mfp = $.magnificPopup.instance;+ $("#ValueEditPopup").submit(function (e) {+ e.preventDefault();+ var form = $(this);+ var url = form.attr('action');+ $.ajax({+ type: "POST",+ url: url,+ data: form.serialize(),+ success: function (data) {+ if (data == "") {+ mfp.close();+ $('#btnRefresh').click();+ } else {+ $.magnificPopup.open({+ items: {+ src: data,+ type: 'inline'+ },+ callbacks: {+ open: function () {+ $('.mfp-wrap').removeAttr('tabindex');+ }+ }+ });+ }+ }+ });+ });+ </script>+</form>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Create.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Create.cshtmlnew file mode 100644index 000000000..4d8872d79--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Create.cshtml@@ -0,0 +1,35 @@+@model CustomerAttributeStoreModel+@{+ ViewBag.Title = Loc["Admin.Customers.CustomerAttributes.AddNew"];+}+<form asp-area="@Constants.AreaStore" asp-controller="CustomerAttribute" asp-action="Create" method="post" id="customerattribute-form">++ <div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-list-alt"></i>+ @Loc["Admin.Customers.CustomerAttributes.AddNew"]+ <small>+ <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Customers.CustomerAttributes.BackToList"], "List")+ </small>+ </div>+ <div class="actions">+ <div class="btn-group btn-group-devided">+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]+ </button>+ <button class="btn btn-success" type="submit" name="save-continue">+ <i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]+ </button>+ </div>+ </div>+ </div>+ <div class="x_content form">+ <partial name="Partials/CreateOrUpdate" model="Model"/>+ </div>+ </div>+ </div>+ </div>+</form>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Edit.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Edit.cshtmlnew file mode 100644index 000000000..9723f0252--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Edit.cshtml@@ -0,0 +1,54 @@+@model CustomerAttributeStoreModel+@{+ var isReadOnly = Model.IsGlobalAttribute;+ ViewBag.Title = Loc["Admin.Customers.CustomerAttributes.EditAttributeDetails"];+}+<form asp-area="@Constants.AreaStore" asp-controller="CustomerAttribute" asp-action="Edit" method="post" id="customerattribute-form">++ <div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-list-alt"></i>+ @Loc["Admin.Customers.CustomerAttributes.EditAttributeDetails"] - @Model.Name+ <small>+ <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Customers.CustomerAttributes.BackToList"], "List")+ </small>+ </div>+ @if (!isReadOnly)+ {+ <div class="actions">+ <div class="btn-group btn-group-devided util-btn-margin-bottom-5">+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]+ </button>+ <button class="btn btn-success" type="submit" name="save-continue">+ <i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]+ </button>+ <span id="customerattribute-delete" class="btn red">+ <i class="fa fa-trash-o"></i> @Loc["Admin.Common.Delete"]+ </span>+ </div>+ </div>+ }+ else+ {+ <div class="actions">+ <div class="alert alert-info mb-0 py-2">+ <i class="fa fa-info-circle"></i> @Loc["Admin.Customers.CustomerAttributes.GlobalReadOnly"]+ </div>+ </div>+ }+ </div>+ <div class="x_content form">+ <partial name="Partials/CreateOrUpdate" model="Model"/>+ </div>+ </div>+ </div>+ </div>+</form>+@if (!isReadOnly)+{+ <admin-delete-confirmation button-id="customerattribute-delete"/>+}diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/List.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/List.cshtmlnew file mode 100644index 000000000..567e5f7f1--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/List.cshtml@@ -0,0 +1,97 @@+@{+ ViewBag.Title = Loc["Admin.Customers.CustomerAttributes"];+}++<div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-list-alt"></i>+ @Loc["Admin.Customers.CustomerAttributes"]+ </div>+ <div class="actions btn-group btn-group-devided">+ <a href="@Url.Action("Create", new { area = Constants.AreaStore })" class="btn green">+ <i class="fa fa-plus"></i><span class="d-none d-sm-inline"> @Loc["Admin.Common.AddNew"] </span>+ </a>+ </div>+ </div>+ <div class="x_content form">+ <div class="form-horizontal">+ <div class="form-body">+ <div class="x_content">+ <div id="customerattributes-grid"></div>+ </div>+ </div>+ </div>+ </div>+ </div>+ </div>+</div>++<script>+ $(document).ready(function () {+ $("#customerattributes-grid").kendoGrid({+ dataSource: {+ transport: {+ read: {+ url: "@Html.Raw(Url.Action("List", "CustomerAttribute", new { area = Constants.AreaStore }))",+ type: "POST",+ dataType: "json",+ data: addAntiForgeryToken+ }+ },+ schema: {+ data: "Data",+ total: "Total",+ errors: "Errors"+ },+ error: function(e) {+ display_kendoui_grid_error(e);+ this.cancelChanges();+ },+ serverPaging: true,+ serverFiltering: true,+ serverSorting: true+ },+ pageable: {+ refresh: true,+ numeric: false,+ previousNext: false,+ info: false+ },+ scrollable: false,+ columns: [{+ field: "Name",+ title: "@Loc["Admin.Customers.CustomerAttributes.Fields.Name"]",+ template: '<a class="k-link" href="Edit/#=Id#">#=kendo.htmlEncode(Name)#</a>'+ }, {+ field: "AttributeControlTypeName",+ title: "@Loc["Admin.Customers.CustomerAttributes.Fields.AttributeControlType"]",+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ width: 200,+ minScreenWidth: 750+ }, {+ field: "IsRequired",+ title: "@Loc["Admin.Customers.CustomerAttributes.Fields.IsRequired"]",+ width: 100,+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ template: '# if(IsRequired) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'+ }, {+ field: "DisplayOrder",+ title: "@Loc["Admin.Customers.CustomerAttributes.Fields.DisplayOrder"]",+ width: 100,+ minScreenWidth: 750+ }, {+ field: "IsGlobalAttribute",+ title: "@Loc["Admin.Common.View"]",+ width: 120,+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ template: '# if(IsGlobalAttribute) {# <span class="badge badge-secondary">@Loc["Admin.Common.View"]</span> #} else {# <span class="badge badge-success">@Loc["Admin.Common.Edit"]</span> #} #'+ }]+ });+ });+</script>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Partials/CreateOrUpdate.TabInfo.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Partials/CreateOrUpdate.TabInfo.cshtmlnew file mode 100644index 000000000..426e0c99f--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Partials/CreateOrUpdate.TabInfo.cshtml@@ -0,0 +1,104 @@+@using Microsoft.AspNetCore.Mvc.Razor+@model CustomerAttributeStoreModel+@{+ var isReadOnly = Model.IsGlobalAttribute;+}++<script>+ $(document).ready(function () {+ $("#@Html.IdFor(model => model.AttributeControlTypeId)").change(toggleAttributeControlType);+ toggleAttributeControlType();+ $("#@Html.IdFor(model => model.IsReadOnly)").click(toggleIsReadOnly);+ toggleIsReadOnly();+ });++ function toggleIsReadOnly() {+ if ($('#@Html.IdFor(model => model.IsReadOnly)').is(':checked')) {+ $('#pnlIsRequired').hide();+ } else {+ $('#pnlIsRequired').show();+ }+ }++ function toggleAttributeControlType() {+ var selectedAttributeControlTypeId = $("#@Html.IdFor(model => model.AttributeControlTypeId)").val();+ if (selectedAttributeControlTypeId == @(((int)AttributeControlType.TextBox).ToString()) || selectedAttributeControlTypeId == @(((int)AttributeControlType.Hidden).ToString())) {+ $('#tab-customerattributesvalues').hide();+ } else if (selectedAttributeControlTypeId == @(((int)AttributeControlType.MultilineTextbox).ToString())) {+ $('#tab-customerattributesvalues').hide();+ } else {+ $('#tab-customerattributesvalues').show();+ }+ }++</script>++@{+ Func<int, HelperResult>+ template = @<div class="form-body">+ <div class="form-group">+ <admin-label asp-for="@Model.Locales[item].Name"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="@Model.Locales[item].Name" disabled="@isReadOnly"/>+ <span asp-validation-for="@Model.Locales[item].Name"></span>+ </div>+ </div>+ <input type="hidden" asp-for="@Model.Locales[item].LanguageId"/>+ </div>;+}++<div class="form-horizontal">+ <localized-editor localized-template="@template" name="customerattribute-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">+ <div class="form-body">+ <div class="form-group">+ <admin-label asp-for="Name"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="Name" disabled="@isReadOnly"/>+ <span asp-validation-for="Name"></span>+ </div>+ </div>+ </div>+ </localized-editor>+ <div class="form-body">+ <div class="form-group">+ <admin-label asp-for="IsReadOnly"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="IsReadOnly" disabled="@isReadOnly"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="IsReadOnly"></span>+ </div>+ </div>+ <div class="form-group" id="pnlIsRequired">+ <admin-label asp-for="IsRequired"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="IsRequired" disabled="@isReadOnly"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="IsRequired"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="AttributeControlTypeId"/>+ <div class="col-md-9 col-sm-9">+ @{+ var attributeControlTypes =+ EnumTranslationService.ToSelectList(+ ((AttributeControlType)Model.AttributeControlTypeId), valuesToExclude: //custom customer attributes don't support some attribute control types+ [(int)AttributeControlType.FileUpload, (int)AttributeControlType.Datepicker, (int)AttributeControlType.ColorSquares, (int)AttributeControlType.ImageSquares, (int)AttributeControlType.ReadonlyCheckboxes]);+ }+ <admin-select asp-for="AttributeControlTypeId" asp-items="attributeControlTypes" disabled="@isReadOnly"/>+ <span asp-validation-for="AttributeControlTypeId"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="DisplayOrder"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="DisplayOrder" disabled="@isReadOnly"/>+ <span asp-validation-for="DisplayOrder"></span>+ </div>+ </div>+ </div>+</div>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Partials/CreateOrUpdate.TabValues.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Partials/CreateOrUpdate.TabValues.cshtmlnew file mode 100644index 000000000..515719983--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Partials/CreateOrUpdate.TabValues.cshtml@@ -0,0 +1,182 @@+@model CustomerAttributeStoreModel+@{+ var isReadOnly = Model.IsGlobalAttribute;++ if (!string.IsNullOrEmpty(Model.Id))+ {+ <div class="panel panel-default">+ <div class="panel-body">+ <div id="customerattributevalues-grid"></div>+ </div>+ @if (!isReadOnly)+ {+ <div class="panel-footer">+ <a id="btnAddNewValue" href="@(Url.Action("ValueCreatePopup", "CustomerAttribute", new { customerAttributeId = Model.Id, area = Constants.AreaStore }))" class="k-button"><i class="fa fa-plus"></i> @Loc["Admin.Customers.CustomerAttributes.Values.AddNew"]</a>+ <input type="submit" id="btnRefresh" style="display: none"/>+ </div>+ }+ else+ {+ <input type="submit" id="btnRefresh" style="display: none"/>+ }+ </div>++ if (!isReadOnly)+ {+ <script>+ $(document).ready(function () {+ $('#btnAddNewValue').magnificPopup({+ type: 'ajax',+ settings: { cache: false, async: false },+ midClick: true,+ callbacks: {+ parseAjax: function (mfpResponse) {+ mfpResponse.data = $('<div></div>').html(mfpResponse.data);+ },+ ajaxContentAdded: function () {+ $('.mfp-wrap').removeAttr('tabindex');+ }+ }+ });++ $("#customerattributevalues-grid").kendoGrid({+ dataBound: function () {+ $('.editvalue').magnificPopup({+ type: 'ajax',+ settings: { cache: false, async: false },+ midClick: true,+ callbacks: {+ parseAjax: function (mfpResponse) {+ mfpResponse.data = $('<div></div>').html(mfpResponse.data);+ },+ ajaxContentAdded: function () {+ $('.mfp-wrap').removeAttr('tabindex');+ }+ }+ });+ },+ dataSource: {+ transport: {+ read: {+ url: "@Html.Raw(Url.Action("ValueList", "CustomerAttribute", new { customerAttributeId = Model.Id, area = Constants.AreaStore }))",+ type: "POST",+ dataType: "json",+ data: addAntiForgeryToken+ },+ destroy: {+ url: "@Html.Raw(Url.Action("ValueDelete", "CustomerAttribute", new { area = Constants.AreaStore }))",+ type: "POST",+ dataType: "json",+ data: addAntiForgeryToken+ }+ },+ schema: {+ data: "Data",+ total: "Total",+ errors: "Errors",+ model: { id: "Id", fields: { CustomerAttributeId: { editable: false } } }+ },+ error: function(e) {+ display_kendoui_grid_error(e);+ this.cancelChanges();+ },+ serverPaging: true,+ serverFiltering: true,+ serverSorting: true+ },+ pageable: { refresh: true, numeric: false, previousNext: false, info: false },+ editable: { confirmation: true, mode: "inline" },+ scrollable: false,+ columns: [{+ field: "Name",+ title: "@Loc["Admin.Customers.CustomerAttributes.Values.Fields.Name"]",+ template: "<a class='k-link editvalue' href=\"@Url.Action("ValueEditPopup", "CustomerAttribute", new { area = Constants.AreaStore })/#=Id#[email protected]\">#=kendo.htmlEncode(Name)#</a>"+ }, {+ field: "IsPreSelected",+ title: "@Loc["Admin.Customers.CustomerAttributes.Values.Fields.IsPreSelected"]",+ width: 100,+ minScreenWidth: 500,+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ template: '# if(IsPreSelected) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'+ }, {+ field: "DisplayOrder",+ title: "@Loc["Admin.Customers.CustomerAttributes.Values.Fields.DisplayOrder"]",+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ width: 100+ }, {+ command: { name: "destroy", text: "@Loc["Admin.Common.Delete"]" },+ title: "@Loc["Admin.Common.Delete"]",+ width: 100+ }]+ });++ $('#btnRefresh').click(function () {+ var grid = $("#customerattributevalues-grid").data('kendoGrid');+ grid.dataSource.read();+ return false;+ });+ });+ </script>+ }+ else+ {+ <script>+ $(document).ready(function () {+ $("#customerattributevalues-grid").kendoGrid({+ dataSource: {+ transport: {+ read: {+ url: "@Html.Raw(Url.Action("ValueList", "CustomerAttribute", new { customerAttributeId = Model.Id, area = Constants.AreaStore }))",+ type: "POST",+ dataType: "json",+ data: addAntiForgeryToken+ }+ },+ schema: {+ data: "Data",+ total: "Total",+ errors: "Errors",+ model: { id: "Id" }+ },+ error: function(e) {+ display_kendoui_grid_error(e);+ this.cancelChanges();+ },+ serverPaging: true,+ serverFiltering: true,+ serverSorting: true+ },+ pageable: { refresh: true, numeric: false, previousNext: false, info: false },+ scrollable: false,+ columns: [{+ field: "Name",+ title: "@Loc["Admin.Customers.CustomerAttributes.Values.Fields.Name"]"+ }, {+ field: "IsPreSelected",+ title: "@Loc["Admin.Customers.CustomerAttributes.Values.Fields.IsPreSelected"]",+ width: 100,+ minScreenWidth: 500,+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ template: '# if(IsPreSelected) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'+ }, {+ field: "DisplayOrder",+ title: "@Loc["Admin.Customers.CustomerAttributes.Values.Fields.DisplayOrder"]",+ headerAttributes: { style: "text-align:center" },+ attributes: { style: "text-align:center" },+ width: 100+ }]+ });+ });+ </script>+ }+ }+ else+ {+ <div class="note note-info">+ @Loc["Admin.Customers.CustomerAttributes.Values.SaveBeforeEdit"]+ </div>+ }+}diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Partials/CreateOrUpdate.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Partials/CreateOrUpdate.cshtmlnew file mode 100644index 000000000..6fae17d89--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Partials/CreateOrUpdate.cshtml@@ -0,0 +1,23 @@+@model CustomerAttributeStoreModel++<div asp-validation-summary="All"></div>+<input asp-for="Id" type="hidden"/>++<admin-tabstrip name="customerattribute-edit">+ <items>+ <tabstrip-item text="@Loc["Admin.Customers.CustomerAttributes.Info"]" tab-index="0">+ <content>+ <div>+ <partial name="Partials/CreateOrUpdate.TabInfo" model="Model"/>+ </div>+ </content>+ </tabstrip-item>+ <tabstrip-item text="@Loc["Admin.Customers.CustomerAttributes.Values"]" tab-index="1" id="tab-customerattributesvalues">+ <content>+ <div>+ <partial name="Partials/CreateOrUpdate.TabValues" model="Model"/>+ </div>+ </content>+ </tabstrip-item>+ </items>+</admin-tabstrip>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Partials/CreateOrUpdateValue.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Partials/CreateOrUpdateValue.cshtmlnew file mode 100644index 000000000..6c6432520--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/Partials/CreateOrUpdateValue.cshtml@@ -0,0 +1,58 @@+@using Microsoft.AspNetCore.Mvc.Razor+@model CustomerAttributeValueModel+<div asp-validation-summary="All"></div>+<input asp-for="Id" type="hidden"/>+<input asp-for="CustomerAttributeId" type="hidden"/>++@{+ Func<int, HelperResult>+ template = @<div class="form-body">+ <div class="form-group">+ <admin-label asp-for="@Model.Locales[item].Name"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="@Model.Locales[item].Name"/>+ <span asp-validation-for="@Model.Locales[item].Name"></span>+ </div>+ </div>+ <input type="hidden" asp-for="@Model.Locales[item].LanguageId"/>+ </div>;+}+<div class="form-horizontal">+ <localized-editor localized-template="@template" name="customerattributevalue-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">+ <div class="form-body">+ <div class="form-group">+ <admin-label asp-for="Name"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="Name"/>+ <span asp-validation-for="Name"></span>+ </div>+ </div>+ </div>+ </localized-editor>+ <div class="form-body">+ <div class="form-group">+ <admin-label asp-for="IsPreSelected"/>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="IsPreSelected"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="IsPreSelected"></span>+ </div>+ </div>+ <div class="form-group">+ <admin-label asp-for="DisplayOrder"/>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="DisplayOrder"/>+ <span asp-validation-for="DisplayOrder"></span>+ </div>+ </div>+ <div class="form-group">+ <div class="offset-sm-3 offset-md-3 col-md-9 col-sm-9">+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]+ </button>+ </div>+ </div>+ </div>+</div>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/ValueCreatePopup.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/ValueCreatePopup.cshtmlnew file mode 100644index 000000000..805a709a5--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/ValueCreatePopup.cshtml@@ -0,0 +1,54 @@+@using Grand.Web.Common.Extensions+@model CustomerAttributeValueModel+@{+ Layout = "";+}+<form id="ValueCreatePopup" asp-area="@Constants.AreaStore" asp-controller="CustomerAttribute" asp-action="ValueCreatePopup"+ asp-route-customerAttributeId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["customerAttributeId"])">+ <div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-list-alt"></i>+ @Loc["Admin.Customers.CustomerAttributes.Values.AddNew"]+ </div>+ </div>+ <div class="x_content form">+ <partial name="Partials/CreateOrUpdateValue" model="Model"/>+ </div>+ </div>+ </div>+ </div>+ <script>+ var mfp = $.magnificPopup.instance;+ $("#ValueCreatePopup").submit(function (e) {+ e.preventDefault();+ var form = $(this);+ var url = form.attr('action');+ $.ajax({+ type: "POST",+ url: url,+ data: form.serialize(),+ success: function (data) {+ if (data == "") {+ mfp.close();+ $('#btnRefresh').click();+ } else {+ $.magnificPopup.open({+ items: {+ src: data,+ type: 'inline'+ },+ callbacks: {+ open: function () {+ $('.mfp-wrap').removeAttr('tabindex');+ }+ }+ });+ }+ }+ });+ });+ </script>+</form>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/ValueEditPopup.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/ValueEditPopup.cshtmlnew file mode 100644index 000000000..44d941ce1--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/CustomerAttribute/ValueEditPopup.cshtml@@ -0,0 +1,54 @@+@using Grand.Web.Common.Extensions+@model CustomerAttributeValueModel+@{+ Layout = "";+}+<form id="ValueEditPopup" asp-area="@Constants.AreaStore" asp-controller="CustomerAttribute" asp-action="ValueEditPopup"+ asp-route-customerAttributeId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["customerAttributeId"])">+ <div class="row">+ <div class="col-md-12">+ <div class="x_panel light form-fit">+ <div class="x_title">+ <div class="caption">+ <i class="fa fa-list-alt"></i>+ @Loc["Admin.Customers.CustomerAttributes.Values.EditValueDetails"]+ </div>+ </div>+ <div class="x_content form">+ <partial name="Partials/CreateOrUpdateValue" model="Model"/>+ </div>+ </div>+ </div>+ </div>+ <script>+ var mfp = $.magnificPopup.instance;+ $("#ValueEditPopup").submit(function (e) {+ e.preventDefault();+ var form = $(this);+ var url = form.attr('action');+ $.ajax({+ type: "POST",+ url: url,+ data: form.serialize(),+ success: function (data) {+ if (data == "") {+ mfp.close();+ $('#btnRefresh').click();+ } else {+ $.magnificPopup.open({+ items: {+ src: data,+ type: 'inline'+ },+ callbacks: {+ open: function () {+ $('.mfp-wrap').removeAttr('tabindex');+ }+ }+ });+ }+ }+ });+ });+ </script>+</form>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/_ViewImports.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/_ViewImports.cshtmlindex 38a41e485..a35e3b263 100644--- a/src/Web/Grand.Web.Store/Areas/Store/Views/_ViewImports.cshtml+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/_ViewImports.cshtml@@ -39,6 +39,8 @@@using Grand.Web.AdminShared.Models.Discounts@using Grand.Web.AdminShared.Models.Tax@using Grand.Web.Store.Models.Messages+@using Grand.Web.Store.Models.Customers+@using Grand.Web.Store.Models.Common@inject LocService Loc@inject IEnumTranslationService EnumTranslationService\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Controllers/AddressAttributeController.cs b/src/Web/Grand.Web.Store/Controllers/AddressAttributeController.csnew file mode 100644index 000000000..2b68b5dd4--- /dev/null+++ b/src/Web/Grand.Web.Store/Controllers/AddressAttributeController.cs@@ -0,0 +1,297 @@+using Grand.Business.Core.Extensions;+using Grand.Business.Core.Interfaces.Common.Addresses;+using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Domain.Common;+using Grand.Domain.Permissions;+using Grand.Infrastructure;+using Grand.Infrastructure.Mapper;+using Grand.Web.AdminShared.Extensions;+using Grand.Web.AdminShared.Interfaces;+using Grand.Web.AdminShared.Models.Common;+using Grand.Web.Store.Models.Common;+using Grand.Web.Common.DataSource;+using Grand.Web.Common.Filters;+using Grand.Web.Common.Security.Authorization;+using Microsoft.AspNetCore.Mvc;++namespace Grand.Web.Store.Controllers;++[PermissionAuthorize(PermissionSystemName.AddressAttributes)]+public class AddressAttributeController : BaseStoreController+{+ private readonly IAddressAttributeViewModelService _addressAttributeViewModelService;+ private readonly IAddressAttributeService _addressAttributeService;+ private readonly ILanguageService _languageService;+ private readonly ITranslationService _translationService;+ private readonly IContextAccessor _contextAccessor;++ public AddressAttributeController(+ IAddressAttributeViewModelService addressAttributeViewModelService,+ IAddressAttributeService addressAttributeService,+ ILanguageService languageService,+ ITranslationService translationService,+ IContextAccessor contextAccessor)+ {+ _addressAttributeViewModelService = addressAttributeViewModelService;+ _addressAttributeService = addressAttributeService;+ _languageService = languageService;+ _translationService = translationService;+ _contextAccessor = contextAccessor;+ }++ private string CurrentStoreId => _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;++ private bool IsVisibleToStore(AddressAttribute attr) =>+ !attr.LimitedToStores || attr.Stores.Contains(CurrentStoreId);++ #region Address attributes++ public IActionResult Index()+ {+ return RedirectToAction("List");+ }++ public IActionResult List()+ {+ return View();+ }++ [HttpPost]+ [PermissionAuthorizeAction(PermissionActionName.List)]+ public async Task<IActionResult> List(DataSourceRequest command)+ {+ var storeId = CurrentStoreId;+ var (addressAttributes, _) = await _addressAttributeViewModelService.PrepareAddressAttributes();+ var visibleAttributes = addressAttributes+ .Where(x => x.Stores == null || x.Stores.Length == 0 || x.Stores.Contains(storeId))+ .ToList();+ var gridModel = new DataSourceResult {+ Data = visibleAttributes.Select(x => new {+ x.Id,+ x.Name,+ x.AttributeControlTypeName,+ x.IsRequired,+ x.DisplayOrder,+ IsGlobalAttribute = !(x.Stores is { Length: 1 } && x.Stores.Contains(storeId))+ }).ToList(),+ Total = visibleAttributes.Count+ };+ return Json(gridModel);+ }++ [PermissionAuthorizeAction(PermissionActionName.Create)]+ public async Task<IActionResult> Create()+ {+ var model = new AddressAttributeStoreModel();+ await AddLocales(_languageService, model.Locales);+ return View(model);+ }++ [HttpPost]+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]+ [PermissionAuthorizeAction(PermissionActionName.Create)]+ public async Task<IActionResult> Create(AddressAttributeStoreModel model, bool continueEditing)+ {+ if (ModelState.IsValid)+ {+ model.Stores = [CurrentStoreId];+ var addressAttribute = await _addressAttributeViewModelService.InsertAddressAttributeModel(model);+ Success(_translationService.GetResource("Admin.Address.AddressAttributes.Added"));+ return continueEditing+ ? RedirectToAction("Edit", new { id = addressAttribute.Id })+ : RedirectToAction("List");+ }++ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.Preview)]+ public async Task<IActionResult> Edit(string id)+ {+ var addressAttribute = await _addressAttributeService.GetAddressAttributeById(id);+ if (addressAttribute == null || !IsVisibleToStore(addressAttribute))+ return RedirectToAction("List");++ var model = addressAttribute.MapTo<AddressAttribute, AddressAttributeStoreModel>();+ model.IsGlobalAttribute = !addressAttribute.AccessToEntityByStore(CurrentStoreId);+ await AddLocales(_languageService, model.Locales, (locale, languageId) =>+ {+ locale.Name = addressAttribute.GetTranslation(x => x.Name, languageId, false);+ });++ return View(model);+ }++ [HttpPost]+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]+ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ public async Task<IActionResult> Edit(AddressAttributeModel model, bool continueEditing)+ {+ var addressAttribute = await _addressAttributeService.GetAddressAttributeById(model.Id);+ if (addressAttribute == null)+ return RedirectToAction("List");++ if (!addressAttribute.AccessToEntityByStore(CurrentStoreId))+ return RedirectToAction("List");++ if (ModelState.IsValid)+ {+ model.Stores = [CurrentStoreId];+ addressAttribute =+ await _addressAttributeViewModelService.UpdateAddressAttributeModel(model, addressAttribute);+ Success(_translationService.GetResource("Admin.Address.AddressAttributes.Updated"));+ if (continueEditing)+ {+ await SaveSelectedTabIndex();+ return RedirectToAction("Edit", new { id = addressAttribute.Id });+ }++ return RedirectToAction("List");+ }++ var storeModel = addressAttribute.MapTo<AddressAttribute, AddressAttributeStoreModel>();+ storeModel.IsGlobalAttribute = false;+ await AddLocales(_languageService, storeModel.Locales, (locale, languageId) =>+ {+ locale.Name = addressAttribute.GetTranslation(x => x.Name, languageId, false);+ });+ return View(storeModel);+ }++ [HttpPost]+ [PermissionAuthorizeAction(PermissionActionName.Delete)]+ public async Task<IActionResult> Delete(string id)+ {+ var addressAttribute = await _addressAttributeService.GetAddressAttributeById(id);+ if (addressAttribute == null)+ return RedirectToAction("List");++ if (!addressAttribute.AccessToEntityByStore(CurrentStoreId))+ return RedirectToAction("Edit", new { id });++ if (ModelState.IsValid)+ {+ await _addressAttributeService.DeleteAddressAttribute(addressAttribute);+ Success(_translationService.GetResource("Admin.Address.AddressAttributes.Deleted"));+ return RedirectToAction("List");+ }++ Error(ModelState);+ return RedirectToAction("Edit", new { id });+ }++ #endregion++ #region Address attribute values++ [HttpPost]+ [PermissionAuthorizeAction(PermissionActionName.Preview)]+ public async Task<IActionResult> ValueList(string addressAttributeId, DataSourceRequest command)+ {+ var addressAttribute = await _addressAttributeService.GetAddressAttributeById(addressAttributeId);+ if (addressAttribute == null || !IsVisibleToStore(addressAttribute))+ return new JsonResult(new DataSourceResult { Errors = "Access denied" });++ var (addressAttributeValues, totalCount) =+ await _addressAttributeViewModelService.PrepareAddressAttributeValues(addressAttributeId);+ var gridModel = new DataSourceResult {+ Data = addressAttributeValues.ToList(),+ Total = totalCount+ };+ return Json(gridModel);+ }++ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ public async Task<IActionResult> ValueCreatePopup(string addressAttributeId)+ {+ var addressAttribute = await _addressAttributeService.GetAddressAttributeById(addressAttributeId);+ if (addressAttribute == null || !addressAttribute.AccessToEntityByStore(CurrentStoreId))+ return RedirectToAction("List");++ var model = _addressAttributeViewModelService.PrepareAddressAttributeValueModel(addressAttributeId);+ await AddLocales(_languageService, model.Locales);+ return View(model);+ }++ [HttpPost]+ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ public async Task<IActionResult> ValueCreatePopup(AddressAttributeValueModel model)+ {+ var addressAttribute = await _addressAttributeService.GetAddressAttributeById(model.AddressAttributeId);+ if (addressAttribute == null || !addressAttribute.AccessToEntityByStore(CurrentStoreId))+ return RedirectToAction("List");++ if (ModelState.IsValid)+ {+ await _addressAttributeViewModelService.InsertAddressAttributeValueModel(model);+ return Content("");+ }++ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ public async Task<IActionResult> ValueEditPopup(string id, string addressAttributeId)+ {+ var addressAttribute = await _addressAttributeService.GetAddressAttributeById(addressAttributeId);+ if (addressAttribute == null || !addressAttribute.AccessToEntityByStore(CurrentStoreId))+ return RedirectToAction("List");++ var cav = addressAttribute.AddressAttributeValues.FirstOrDefault(x => x.Id == id);+ if (cav == null)+ return RedirectToAction("List");++ var model = _addressAttributeViewModelService.PrepareAddressAttributeValueModel(cav);+ await AddLocales(_languageService, model.Locales, (locale, languageId) =>+ {+ locale.Name = cav.GetTranslation(x => x.Name, languageId, false);+ });++ return View(model);+ }++ [HttpPost]+ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ public async Task<IActionResult> ValueEditPopup(AddressAttributeValueModel model)+ {+ var addressAttribute = await _addressAttributeService.GetAddressAttributeById(model.AddressAttributeId);+ if (addressAttribute == null || !addressAttribute.AccessToEntityByStore(CurrentStoreId))+ return RedirectToAction("List");++ var cav = addressAttribute.AddressAttributeValues.FirstOrDefault(x => x.Id == model.Id);+ if (cav == null)+ return RedirectToAction("List");++ if (ModelState.IsValid)+ {+ await _addressAttributeViewModelService.UpdateAddressAttributeValueModel(model, cav);+ return Content("");+ }++ return View(model);+ }++ [HttpPost]+ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ public async Task<IActionResult> ValueDelete(AddressAttributeValueModel model)+ {+ var addressAttribute = await _addressAttributeService.GetAddressAttributeById(model.AddressAttributeId);+ if (addressAttribute == null || !addressAttribute.AccessToEntityByStore(CurrentStoreId))+ return new JsonResult(new DataSourceResult { Errors = "Access denied" });++ var cav = addressAttribute.AddressAttributeValues.FirstOrDefault(x => x.Id == model.Id);+ if (cav == null)+ return new JsonResult(new DataSourceResult+ { Errors = "No address attribute value found with the specified id" });++ if (ModelState.IsValid)+ {+ await _addressAttributeService.DeleteAddressAttributeValue(cav);+ return new JsonResult("");+ }++ return ErrorForKendoGridJson(ModelState);+ }++ #endregion+}diff --git a/src/Web/Grand.Web.Store/Controllers/CustomerAttributeController.cs b/src/Web/Grand.Web.Store/Controllers/CustomerAttributeController.csnew file mode 100644index 000000000..b93bc625a--- /dev/null+++ b/src/Web/Grand.Web.Store/Controllers/CustomerAttributeController.cs@@ -0,0 +1,294 @@+using Grand.Business.Core.Extensions;+using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Interfaces.Customers;+using Grand.Domain.Customers;+using Grand.Domain.Permissions;+using Grand.Infrastructure;+using Grand.Infrastructure.Mapper;+using Grand.Web.AdminShared.Extensions;+using Grand.Web.AdminShared.Interfaces;+using Grand.Web.AdminShared.Models.Customers;+using Grand.Web.Store.Models.Customers;+using Grand.Web.Common.DataSource;+using Grand.Web.Common.Filters;+using Grand.Web.Common.Security.Authorization;+using Microsoft.AspNetCore.Mvc;++namespace Grand.Web.Store.Controllers;++[PermissionAuthorize(PermissionSystemName.CustomerAttributes)]+public class CustomerAttributeController : BaseStoreController+{+ private readonly ICustomerAttributeViewModelService _customerAttributeViewModelService;+ private readonly ICustomerAttributeService _customerAttributeService;+ private readonly ILanguageService _languageService;+ private readonly ITranslationService _translationService;+ private readonly IContextAccessor _contextAccessor;++ public CustomerAttributeController(+ ICustomerAttributeViewModelService customerAttributeViewModelService,+ ICustomerAttributeService customerAttributeService,+ ILanguageService languageService,+ ITranslationService translationService,+ IContextAccessor contextAccessor)+ {+ _customerAttributeViewModelService = customerAttributeViewModelService;+ _customerAttributeService = customerAttributeService;+ _languageService = languageService;+ _translationService = translationService;+ _contextAccessor = contextAccessor;+ }++ private string CurrentStoreId => _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;++ private bool IsVisibleToStore(CustomerAttribute attr) =>+ !attr.LimitedToStores || attr.Stores.Contains(CurrentStoreId);++ #region Customer attributes++ public IActionResult Index()+ {+ return RedirectToAction("List");+ }++ public IActionResult List()+ {+ return View();+ }++ [HttpPost]+ [PermissionAuthorizeAction(PermissionActionName.List)]+ public async Task<IActionResult> List(DataSourceRequest command)+ {+ var storeId = CurrentStoreId;+ var customerAttributes = (await _customerAttributeViewModelService.PrepareCustomerAttributes())+ .Where(x => x.Stores == null || x.Stores.Length == 0 || x.Stores.Contains(storeId))+ .ToList();+ var gridModel = new DataSourceResult {+ Data = customerAttributes.Select(x => new {+ x.Id,+ x.Name,+ x.AttributeControlTypeName,+ x.IsRequired,+ x.DisplayOrder,+ IsGlobalAttribute = !(x.Stores is { Length: 1 } && x.Stores.Contains(storeId))+ }).ToList(),+ Total = customerAttributes.Count+ };+ return Json(gridModel);+ }++ [PermissionAuthorizeAction(PermissionActionName.Create)]+ public async Task<IActionResult> Create()+ {+ var model = new CustomerAttributeStoreModel();+ await AddLocales(_languageService, model.Locales);+ return View(model);+ }++ [HttpPost]+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]+ [PermissionAuthorizeAction(PermissionActionName.Create)]+ public async Task<IActionResult> Create(CustomerAttributeStoreModel model, bool continueEditing)+ {+ if (ModelState.IsValid)+ {+ model.Stores = [CurrentStoreId];+ var customerAttribute = await _customerAttributeViewModelService.InsertCustomerAttributeModel(model);+ Success(_translationService.GetResource("Admin.Customers.CustomerAttributes.Added"));+ return continueEditing+ ? RedirectToAction("Edit", new { id = customerAttribute.Id })+ : RedirectToAction("List");+ }++ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.Preview)]+ public async Task<IActionResult> Edit(string id)+ {+ var customerAttribute = await _customerAttributeService.GetCustomerAttributeById(id);+ if (customerAttribute == null || !IsVisibleToStore(customerAttribute))+ return RedirectToAction("List");++ var model = customerAttribute.MapTo<CustomerAttribute, CustomerAttributeStoreModel>();+ model.IsGlobalAttribute = !customerAttribute.AccessToEntityByStore(CurrentStoreId);+ await AddLocales(_languageService, model.Locales, (locale, languageId) =>+ {+ locale.Name = customerAttribute.GetTranslation(x => x.Name, languageId, false);+ });++ return View(model);+ }++ [HttpPost]+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]+ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ public async Task<IActionResult> Edit(CustomerAttributeModel model, bool continueEditing)+ {+ var customerAttribute = await _customerAttributeService.GetCustomerAttributeById(model.Id);+ if (customerAttribute == null)+ return RedirectToAction("List");++ if (!customerAttribute.AccessToEntityByStore(CurrentStoreId))+ return RedirectToAction("List");++ if (ModelState.IsValid)+ {+ model.Stores = [CurrentStoreId];+ customerAttribute =+ await _customerAttributeViewModelService.UpdateCustomerAttributeModel(model, customerAttribute);+ Success(_translationService.GetResource("Admin.Customers.CustomerAttributes.Updated"));+ if (continueEditing)+ {+ await SaveSelectedTabIndex();+ return RedirectToAction("Edit", new { id = customerAttribute.Id });+ }++ return RedirectToAction("List");+ }++ var storeModel = customerAttribute.MapTo<CustomerAttribute, CustomerAttributeStoreModel>();+ storeModel.IsGlobalAttribute = false;+ await AddLocales(_languageService, storeModel.Locales, (locale, languageId) =>+ {+ locale.Name = customerAttribute.GetTranslation(x => x.Name, languageId, false);+ });+ return View(storeModel);+ }++ [HttpPost]+ [PermissionAuthorizeAction(PermissionActionName.Delete)]+ public async Task<IActionResult> Delete(string id)+ {+ var customerAttribute = await _customerAttributeService.GetCustomerAttributeById(id);+ if (customerAttribute == null)+ return RedirectToAction("List");++ if (!customerAttribute.AccessToEntityByStore(CurrentStoreId))+ return RedirectToAction("Edit", new { id });++ if (ModelState.IsValid)+ {+ await _customerAttributeViewModelService.DeleteCustomerAttribute(id);+ Success(_translationService.GetResource("Admin.Customers.CustomerAttributes.Deleted"));+ return RedirectToAction("List");+ }++ Error(ModelState);+ return RedirectToAction("Edit", new { id });+ }++ #endregion++ #region Customer attribute values++ [HttpPost]+ [PermissionAuthorizeAction(PermissionActionName.Preview)]+ public async Task<IActionResult> ValueList(string customerAttributeId, DataSourceRequest command)+ {+ var customerAttribute = await _customerAttributeService.GetCustomerAttributeById(customerAttributeId);+ if (customerAttribute == null || !IsVisibleToStore(customerAttribute))+ return new JsonResult(new DataSourceResult { Errors = "Access denied" });++ var values = await _customerAttributeViewModelService.PrepareCustomerAttributeValues(customerAttributeId);+ var gridModel = new DataSourceResult {+ Data = values.ToList(),+ Total = values.Count()+ };+ return Json(gridModel);+ }++ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ public async Task<IActionResult> ValueCreatePopup(string customerAttributeId)+ {+ var customerAttribute = await _customerAttributeService.GetCustomerAttributeById(customerAttributeId);+ if (customerAttribute == null || !customerAttribute.AccessToEntityByStore(CurrentStoreId))+ return RedirectToAction("List");++ var model = _customerAttributeViewModelService.PrepareCustomerAttributeValueModel(customerAttributeId);+ await AddLocales(_languageService, model.Locales);+ return View(model);+ }++ [HttpPost]+ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ public async Task<IActionResult> ValueCreatePopup(CustomerAttributeValueModel model)+ {+ var customerAttribute = await _customerAttributeService.GetCustomerAttributeById(model.CustomerAttributeId);+ if (customerAttribute == null || !customerAttribute.AccessToEntityByStore(CurrentStoreId))+ return RedirectToAction("List");++ if (ModelState.IsValid)+ {+ await _customerAttributeViewModelService.InsertCustomerAttributeValueModel(model);+ return Content("");+ }++ return View(model);+ }++ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ public async Task<IActionResult> ValueEditPopup(string id, string customerAttributeId)+ {+ var customerAttribute = await _customerAttributeService.GetCustomerAttributeById(customerAttributeId);+ if (customerAttribute == null || !customerAttribute.AccessToEntityByStore(CurrentStoreId))+ return RedirectToAction("List");++ var cav = customerAttribute.CustomerAttributeValues.FirstOrDefault(x => x.Id == id);+ if (cav == null)+ return RedirectToAction("List");++ var model = _customerAttributeViewModelService.PrepareCustomerAttributeValueModel(cav);+ await AddLocales(_languageService, model.Locales, (locale, languageId) =>+ {+ locale.Name = cav.GetTranslation(x => x.Name, languageId, false);+ });++ return View(model);+ }++ [HttpPost]+ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ public async Task<IActionResult> ValueEditPopup(CustomerAttributeValueModel model)+ {+ var customerAttribute = await _customerAttributeService.GetCustomerAttributeById(model.CustomerAttributeId);+ if (customerAttribute == null || !customerAttribute.AccessToEntityByStore(CurrentStoreId))+ return RedirectToAction("List");++ var cav = customerAttribute.CustomerAttributeValues.FirstOrDefault(x => x.Id == model.Id);+ if (cav == null)+ return RedirectToAction("List");++ if (ModelState.IsValid)+ {+ await _customerAttributeViewModelService.UpdateCustomerAttributeValueModel(model, cav);+ return Content("");+ }++ return View(model);+ }++ [HttpPost]+ [PermissionAuthorizeAction(PermissionActionName.Edit)]+ public async Task<IActionResult> ValueDelete(CustomerAttributeValueModel model)+ {+ var customerAttribute = await _customerAttributeService.GetCustomerAttributeById(model.CustomerAttributeId);+ if (customerAttribute == null || !customerAttribute.AccessToEntityByStore(CurrentStoreId))+ return new JsonResult(new DataSourceResult { Errors = "Access denied" });++ if (customerAttribute.CustomerAttributeValues.All(x => x.Id != model.Id))+ return new JsonResult(new DataSourceResult+ { Errors = "No customer attribute value found with the specified id" });++ if (ModelState.IsValid)+ {+ await _customerAttributeViewModelService.DeleteCustomerAttributeValue(model);+ return new JsonResult("");+ }++ return ErrorForKendoGridJson(ModelState);+ }++ #endregion+}diff --git a/src/Web/Grand.Web.Store/Mapper/AddressAttributeStoreProfile.cs b/src/Web/Grand.Web.Store/Mapper/AddressAttributeStoreProfile.csnew file mode 100644index 000000000..d1ead6dff--- /dev/null+++ b/src/Web/Grand.Web.Store/Mapper/AddressAttributeStoreProfile.cs@@ -0,0 +1,19 @@+using Grand.Domain.Common;+using Grand.Infrastructure.Mapper;+using Grand.Mapping;+using Grand.Web.Store.Models.Common;++namespace Grand.Web.Store.Mapper;++public class AddressAttributeStoreProfile : Profile, IAutoMapperProfile+{+ public AddressAttributeStoreProfile()+ {+ CreateMap<AddressAttribute, AddressAttributeStoreModel>()+ .ForMember(dest => dest.Locales, mo => mo.Ignore())+ .ForMember(dest => dest.AttributeControlTypeName, mo => mo.Ignore())+ .ForMember(dest => dest.IsGlobalAttribute, mo => mo.Ignore());+ }++ public int Order => 0;+}diff --git a/src/Web/Grand.Web.Store/Mapper/CustomerAttributeStoreProfile.cs b/src/Web/Grand.Web.Store/Mapper/CustomerAttributeStoreProfile.csnew file mode 100644index 000000000..8300b3e95--- /dev/null+++ b/src/Web/Grand.Web.Store/Mapper/CustomerAttributeStoreProfile.cs@@ -0,0 +1,19 @@+using Grand.Domain.Customers;+using Grand.Infrastructure.Mapper;+using Grand.Mapping;+using Grand.Web.Store.Models.Customers;++namespace Grand.Web.Store.Mapper;++public class CustomerAttributeStoreProfile : Profile, IAutoMapperProfile+{+ public CustomerAttributeStoreProfile()+ {+ CreateMap<CustomerAttribute, CustomerAttributeStoreModel>()+ .ForMember(dest => dest.Locales, mo => mo.Ignore())+ .ForMember(dest => dest.AttributeControlTypeName, mo => mo.Ignore())+ .ForMember(dest => dest.IsGlobalAttribute, mo => mo.Ignore());+ }++ public int Order => 0;+}diff --git a/src/Web/Grand.Web.Store/Models/Common/AddressAttributeStoreModel.cs b/src/Web/Grand.Web.Store/Models/Common/AddressAttributeStoreModel.csnew file mode 100644index 000000000..67799d7ed--- /dev/null+++ b/src/Web/Grand.Web.Store/Models/Common/AddressAttributeStoreModel.cs@@ -0,0 +1,8 @@+using Grand.Web.AdminShared.Models.Common;++namespace Grand.Web.Store.Models.Common;++public class AddressAttributeStoreModel : AddressAttributeModel+{+ public bool IsGlobalAttribute { get; set; }+}diff --git a/src/Web/Grand.Web.Store/Models/Customers/CustomerAttributeStoreModel.cs b/src/Web/Grand.Web.Store/Models/Customers/CustomerAttributeStoreModel.csnew file mode 100644index 000000000..5ba547754--- /dev/null+++ b/src/Web/Grand.Web.Store/Models/Customers/CustomerAttributeStoreModel.cs@@ -0,0 +1,8 @@+using Grand.Web.AdminShared.Models.Customers;++namespace Grand.Web.Store.Models.Customers;++public class CustomerAttributeStoreModel : CustomerAttributeModel+{+ public bool IsGlobalAttribute { get; set; }+}diff --git a/src/Web/Grand.Web.Store/Validators/AddressAttributeStoreValidator.cs b/src/Web/Grand.Web.Store/Validators/AddressAttributeStoreValidator.csnew file mode 100644index 000000000..e37cdd198--- /dev/null+++ b/src/Web/Grand.Web.Store/Validators/AddressAttributeStoreValidator.cs@@ -0,0 +1,17 @@+using FluentValidation;+using Grand.Infrastructure.Validators;+using Grand.Web.AdminShared.Models.Common;+using Grand.Web.Store.Models.Common;++namespace Grand.Web.Store.Validators;++public class AddressAttributeStoreValidator : BaseGrandValidator<AddressAttributeStoreModel>+{+ public AddressAttributeStoreValidator(+ IEnumerable<IValidatorConsumer<AddressAttributeStoreModel>> validators,+ IValidator<AddressAttributeModel> baseValidator)+ : base(validators)+ {+ Include(baseValidator);+ }+}diff --git a/src/Web/Grand.Web.Store/Validators/CustomerAttributeStoreValidator.cs b/src/Web/Grand.Web.Store/Validators/CustomerAttributeStoreValidator.csnew file mode 100644index 000000000..49dd0d035--- /dev/null+++ b/src/Web/Grand.Web.Store/Validators/CustomerAttributeStoreValidator.cs@@ -0,0 +1,17 @@+using FluentValidation;+using Grand.Infrastructure.Validators;+using Grand.Web.AdminShared.Models.Customers;+using Grand.Web.Store.Models.Customers;++namespace Grand.Web.Store.Validators;++public class CustomerAttributeStoreValidator : BaseGrandValidator<CustomerAttributeStoreModel>+{+ public CustomerAttributeStoreValidator(+ IEnumerable<IValidatorConsumer<CustomerAttributeStoreModel>> validators,+ IValidator<CustomerAttributeModel> baseValidator)+ : base(validators)+ {+ Include(baseValidator);+ }+}diff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xmlindex 0b432bbbc..722947333 100644Binary files a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml and b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml differdiff --git a/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.csindex 93ab6dd4e..8bf0078a6 100644--- a/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs+++ b/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs@@ -170,7 +170,7 @@ public class CustomerRegisteredCommandHandler : IRequestHandler<CustomerRegisterFaxNumber = request.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.Fax)};- if (await IsAddressValid(defaultAddress))+ if (await IsAddressValid(defaultAddress, request.Store?.Id)){//set default addressrequest.Customer.Addresses.Add(defaultAddress);@@ -197,8 +197,9 @@ public class CustomerRegisteredCommandHandler : IRequestHandler<CustomerRegister/// Gets a value indicating whether address is valid (can be saved)/// </summary>/// <param name="address">Address to validate</param>+ /// <param name="storeId">Store identifier</param>/// <returns>Result</returns>- private async Task<bool> IsAddressValid(Address address)+ private async Task<bool> IsAddressValid(Address address, string storeId){ArgumentNullException.ThrowIfNull(address);@@ -276,7 +277,7 @@ public class CustomerRegisteredCommandHandler : IRequestHandler<CustomerRegisterstring.IsNullOrWhiteSpace(address.FaxNumber))return false;- var attributes = await _addressAttributeService.GetAllAddressAttributes();+ var attributes = await _addressAttributeService.GetAllAddressAttributes(storeId ?? string.Empty);return !attributes.Any(x => x.IsRequired);}}\ No newline at end of filediff --git a/src/Web/Grand.Web/Features/Handlers/Common/GetAddressModelHandler.cs b/src/Web/Grand.Web/Features/Handlers/Common/GetAddressModelHandler.csindex 48dc80747..66a7e8bca 100644--- a/src/Web/Grand.Web/Features/Handlers/Common/GetAddressModelHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Common/GetAddressModelHandler.cs@@ -50,7 +50,7 @@ public class GetAddressModelHandler : IRequestHandler<GetAddressModel, AddressMo//customer attribute servicesawait PrepareCustomAddressAttributes(model, request.Address, request.Language,- request.OverrideAttributes);+ request.OverrideAttributes, request.Store?.Id);if (request.Address != null)model.FormattedCustomAddressAttributes =@@ -173,9 +173,9 @@ public class GetAddressModelHandler : IRequestHandler<GetAddressModel, AddressMo}private async Task PrepareCustomAddressAttributes(AddressModel model, Address address,- Language language, IList<CustomAttribute> overrideAttributes)+ Language language, IList<CustomAttribute> overrideAttributes, string storeId){- var attributes = await _addressAttributeService.GetAllAddressAttributes();+ var attributes = await _addressAttributeService.GetAllAddressAttributes(storeId ?? string.Empty);foreach (var attribute in attributes){var attributeModel = new AddressAttributeModel {diff --git a/src/Web/Grand.Web/Features/Handlers/Common/GetParseCustomAddressAttributesHandler.cs b/src/Web/Grand.Web/Features/Handlers/Common/GetParseCustomAddressAttributesHandler.csindex 5f1a8e25b..933b38933 100644--- a/src/Web/Grand.Web/Features/Handlers/Common/GetParseCustomAddressAttributesHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Common/GetParseCustomAddressAttributesHandler.cs@@ -1,6 +1,7 @@using Grand.Business.Core.Interfaces.Common.Addresses;using Grand.Domain.Catalog;using Grand.Domain.Common;+using Grand.Infrastructure;using Grand.Web.Features.Models.Common;using MediatR;@@ -11,13 +12,16 @@ public class{private readonly IAddressAttributeParser _addressAttributeParser;private readonly IAddressAttributeService _addressAttributeService;+ private readonly IContextAccessor _contextAccessor;public GetParseCustomAddressAttributesHandler(IAddressAttributeService addressAttributeService,- IAddressAttributeParser addressAttributeParser)+ IAddressAttributeParser addressAttributeParser,+ IContextAccessor contextAccessor){_addressAttributeService = addressAttributeService;_addressAttributeParser = addressAttributeParser;+ _contextAccessor = contextAccessor;}public async Task<IList<CustomAttribute>> Handle(GetParseCustomAddressAttributes request,@@ -26,7 +30,8 @@ public classArgumentNullException.ThrowIfNull(request.SelectedAttributes);var customAttributes = new List<CustomAttribute>();- var attributes = await _addressAttributeService.GetAllAddressAttributes();+ var attributes =+ await _addressAttributeService.GetAllAddressAttributes(_contextAccessor.StoreContext.CurrentStore.Id);foreach (var attribute in attributes)switch (attribute.AttributeControlType){diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetCustomAttributesHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetCustomAttributesHandler.csindex 155fa067a..dbd46195c 100644--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetCustomAttributesHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetCustomAttributesHandler.cs@@ -2,6 +2,7 @@using Grand.Business.Core.Interfaces.Customers;using Grand.Domain.Catalog;using Grand.Domain.Customers;+using Grand.Infrastructure;using Grand.Web.Features.Models.Customers;using Grand.Web.Models.Customer;using MediatR;@@ -12,12 +13,15 @@ public class GetCustomAttributesHandler : IRequestHandler<GetCustomAttributes, I{private readonly ICustomerAttributeParser _customerAttributeParser;private readonly ICustomerAttributeService _customerAttributeService;+ private readonly IContextAccessor _contextAccessor;public GetCustomAttributesHandler(ICustomerAttributeService customerAttributeService,- ICustomerAttributeParser customerAttributeParser)+ ICustomerAttributeParser customerAttributeParser,+ IContextAccessor contextAccessor){_customerAttributeService = customerAttributeService;_customerAttributeParser = customerAttributeParser;+ _contextAccessor = contextAccessor;}public async Task<IList<CustomerAttributeModel>> Handle(GetCustomAttributes request,@@ -25,7 +29,8 @@ public class GetCustomAttributesHandler : IRequestHandler<GetCustomAttributes, I{var result = new List<CustomerAttributeModel>();- var customerAttributes = await _customerAttributeService.GetAllCustomerAttributes();+ var customerAttributes =+ await _customerAttributeService.GetAllCustomerAttributes(_contextAccessor.StoreContext.CurrentStore.Id);foreach (var attribute in customerAttributes){var attributeModel = new CustomerAttributeModel {diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetParseCustomAttributesHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetParseCustomAttributesHandler.csindex 58dbf36f6..5e3a7b546 100644--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetParseCustomAttributesHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetParseCustomAttributesHandler.cs@@ -1,6 +1,7 @@using Grand.Business.Core.Interfaces.Customers;using Grand.Domain.Catalog;using Grand.Domain.Common;+using Grand.Infrastructure;using Grand.Web.Features.Models.Customers;using MediatR;@@ -10,19 +11,23 @@ public class GetParseCustomAttributesHandler : IRequestHandler<GetParseCustomAtt{private readonly ICustomerAttributeParser _customerAttributeParser;private readonly ICustomerAttributeService _customerAttributeService;+ private readonly IContextAccessor _contextAccessor;public GetParseCustomAttributesHandler(ICustomerAttributeService customerAttributeService,- ICustomerAttributeParser customerAttributeParser)+ ICustomerAttributeParser customerAttributeParser,+ IContextAccessor contextAccessor){_customerAttributeService = customerAttributeService;_customerAttributeParser = customerAttributeParser;+ _contextAccessor = contextAccessor;}public async Task<IList<CustomAttribute>> Handle(GetParseCustomAttributes request,CancellationToken cancellationToken){var customAttributes = new List<CustomAttribute>();- var attributes = await _customerAttributeService.GetAllCustomerAttributes();+ var attributes =+ await _customerAttributeService.GetAllCustomerAttributes(_contextAccessor.StoreContext.CurrentStore.Id);foreach (var attribute in attributes){if (attribute.IsReadOnly)diff --git a/src/Web/Grand.Web/Validators/Common/AddressValidator.cs b/src/Web/Grand.Web/Validators/Common/AddressValidator.csindex 7557b8895..9d972e025 100644--- a/src/Web/Grand.Web/Validators/Common/AddressValidator.cs+++ b/src/Web/Grand.Web/Validators/Common/AddressValidator.cs@@ -3,6 +3,7 @@ using Grand.Business.Core.Interfaces.Common.Addresses;using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Domain.Common;+using Grand.Infrastructure;using Grand.Infrastructure.Validators;using Grand.Web.Features.Models.Common;using Grand.Web.Models.Common;@@ -17,7 +18,8 @@ public class AddressValidator : BaseGrandValidator<AddressModel>IMediator mediator, IAddressAttributeParser addressAttributeParser,ITranslationService translationService,ICountryService countryService,- AddressSettings addressSettings)+ AddressSettings addressSettings,+ IContextAccessor contextAccessor): base(validators){RuleFor(x => x.FirstName)@@ -79,7 +81,8 @@ public class AddressValidator : BaseGrandValidator<AddressModel>{var customAttributes = await mediator.Send(new GetParseCustomAddressAttributes{ SelectedAttributes = x.SelectedAttributes });- var customAttributeWarnings = await addressAttributeParser.GetAttributeWarnings(customAttributes);+ var customAttributeWarnings = await addressAttributeParser.GetAttributeWarnings(customAttributes,+ contextAccessor.StoreContext.CurrentStore.Id);foreach (var error in customAttributeWarnings) context.AddFailure(error);});}diff --git a/src/Web/Grand.Web/Validators/Customer/CheckoutBillingAddressValidator.cs b/src/Web/Grand.Web/Validators/Customer/CheckoutBillingAddressValidator.csindex cdd38adae..243906f4b 100644--- a/src/Web/Grand.Web/Validators/Customer/CheckoutBillingAddressValidator.cs+++ b/src/Web/Grand.Web/Validators/Customer/CheckoutBillingAddressValidator.cs@@ -2,6 +2,7 @@using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Domain.Common;+using Grand.Infrastructure;using Grand.Infrastructure.Validators;using Grand.Web.Models.Checkout;using Grand.Web.Models.Common;@@ -18,10 +19,11 @@ public class CheckoutBillingAddressValidator : BaseGrandValidator<CheckoutBillinIMediator mediator, IAddressAttributeParser addressAttributeParser,ITranslationService translationService,ICountryService countryService,- AddressSettings addressSettings)+ AddressSettings addressSettings,+ IContextAccessor contextAccessor): base(validators){RuleFor(x => x.BillingNewAddress).SetValidator(new AddressValidator(addressValidators, mediator,- addressAttributeParser, translationService, countryService, addressSettings));+ addressAttributeParser, translationService, countryService, addressSettings, contextAccessor));}}\ No newline at end of filediff --git a/src/Web/Grand.Web/Validators/Customer/CheckoutShippingAddressValidator.cs b/src/Web/Grand.Web/Validators/Customer/CheckoutShippingAddressValidator.csindex 83a81fc4a..a47274e2b 100644--- a/src/Web/Grand.Web/Validators/Customer/CheckoutShippingAddressValidator.cs+++ b/src/Web/Grand.Web/Validators/Customer/CheckoutShippingAddressValidator.cs@@ -2,6 +2,7 @@using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Domain.Common;+using Grand.Infrastructure;using Grand.Infrastructure.Validators;using Grand.Web.Models.Checkout;using Grand.Web.Models.Common;@@ -18,10 +19,11 @@ public class CheckoutShippingAddressValidator : BaseGrandValidator<CheckoutShippIMediator mediator, IAddressAttributeParser addressAttributeParser,ITranslationService translationService,ICountryService countryService,- AddressSettings addressSettings)+ AddressSettings addressSettings,+ IContextAccessor contextAccessor): base(validators){RuleFor(x => x.ShippingNewAddress).SetValidator(new AddressValidator(addressValidators, mediator,- addressAttributeParser, translationService, countryService, addressSettings));+ addressAttributeParser, translationService, countryService, addressSettings, contextAccessor));}}\ No newline at end of filediff --git a/src/Web/Grand.Web/Validators/Customer/CustomerAddressEditValidator.cs b/src/Web/Grand.Web/Validators/Customer/CustomerAddressEditValidator.csindex 4cef431f9..78c6d63df 100644--- a/src/Web/Grand.Web/Validators/Customer/CustomerAddressEditValidator.cs+++ b/src/Web/Grand.Web/Validators/Customer/CustomerAddressEditValidator.cs@@ -2,6 +2,7 @@using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Domain.Common;+using Grand.Infrastructure;using Grand.Infrastructure.Validators;using Grand.Web.Models.Common;using Grand.Web.Models.Customer;@@ -18,10 +19,11 @@ public class CustomerAddressEditValidator : BaseGrandValidator<CustomerAddressEdIMediator mediator, IAddressAttributeParser addressAttributeParser,ITranslationService translationService,ICountryService countryService,- AddressSettings addressSettings)+ AddressSettings addressSettings,+ IContextAccessor contextAccessor): base(validators){RuleFor(x => x.Address).SetValidator(new AddressValidator(addressValidators, mediator, addressAttributeParser,- translationService, countryService, addressSettings));+ translationService, countryService, addressSettings, contextAccessor));}}\ No newline at end of filediff --git a/src/Web/Grand.Web/Validators/Customer/CustomerInfoValidator.cs b/src/Web/Grand.Web/Validators/Customer/CustomerInfoValidator.csindex 214f5fea5..e302bff96 100644--- a/src/Web/Grand.Web/Validators/Customer/CustomerInfoValidator.cs+++ b/src/Web/Grand.Web/Validators/Customer/CustomerInfoValidator.cs@@ -122,7 +122,8 @@ public class CustomerInfoValidator : BaseGrandValidator<CustomerInfoModel>{var customerAttributes = await mediator.Send(new GetParseCustomAttributes{ SelectedAttributes = x.SelectedAttributes }, _);- var customerAttributeWarnings = await customerAttributeParser.GetAttributeWarnings(customerAttributes);+ var customerAttributeWarnings = await customerAttributeParser.GetAttributeWarnings(customerAttributes,+ contextAccessor.StoreContext.CurrentStore.Id);foreach (var error in customerAttributeWarnings) context.AddFailure(error);if (contextAccessor.WorkContext.CurrentCustomer.Email != x.Email.ToLower() && customerSettings.AllowUsersToChangeEmail)diff --git a/src/Web/Grand.Web/Validators/Customer/RegisterValidator.cs b/src/Web/Grand.Web/Validators/Customer/RegisterValidator.csindex ff41ee029..bc088eee9 100644--- a/src/Web/Grand.Web/Validators/Customer/RegisterValidator.cs+++ b/src/Web/Grand.Web/Validators/Customer/RegisterValidator.cs@@ -137,7 +137,8 @@ public class RegisterValidator : BaseGrandValidator<RegisterModel>RuleFor(x => x).CustomAsync(async (x, context, _) =>{var customerAttributes = await mediator.Send(new GetParseCustomAttributes { SelectedAttributes = x.SelectedAttributes }, _);- var customerAttributeWarnings = await customerAttributeParser.GetAttributeWarnings(customerAttributes);+ var customerAttributeWarnings = await customerAttributeParser.GetAttributeWarnings(customerAttributes,+ contextAccessor.StoreContext.CurrentStore.Id);foreach (var error in customerAttributeWarnings) context.AddFailure(error);if (await groupService.IsRegistered(contextAccessor.WorkContext.CurrentCustomer))diff --git a/src/Web/Grand.Web/Validators/Orders/MerchandiseReturnValidator.cs b/src/Web/Grand.Web/Validators/Orders/MerchandiseReturnValidator.csindex fc5d441a7..ed1533238 100644--- a/src/Web/Grand.Web/Validators/Orders/MerchandiseReturnValidator.cs+++ b/src/Web/Grand.Web/Validators/Orders/MerchandiseReturnValidator.cs@@ -4,6 +4,7 @@ using Grand.Business.Core.Interfaces.Checkout.Orders;using Grand.Business.Core.Interfaces.Common.Addresses;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Domain.Orders;+using Grand.Infrastructure;using Grand.Infrastructure.Validators;using Grand.Web.Features.Models.Common;using Grand.Web.Models.Orders;@@ -17,7 +18,8 @@ public class MerchandiseReturnValidator : BaseGrandValidator<MerchandiseReturnMoIEnumerable<IValidatorConsumer<MerchandiseReturnModel>> validators,OrderSettings orderSettings, IOrderService orderService, IProductService productService,IMediator mediator, IAddressAttributeParser addressAttributeParser,- ITranslationService translationService)+ ITranslationService translationService,+ IContextAccessor contextAccessor): base(validators){RuleFor(x => x).CustomAsync(async (x, context, _) =>@@ -29,7 +31,8 @@ public class MerchandiseReturnValidator : BaseGrandValidator<MerchandiseReturnMoawait mediator.Send(new GetParseCustomAddressAttributes{ SelectedAttributes = x.MerchandiseReturnNewAddress.SelectedAttributes }, _);- var customAttributeWarnings = await addressAttributeParser.GetAttributeWarnings(customAttributes);+ var customAttributeWarnings = await addressAttributeParser.GetAttributeWarnings(customAttributes,+ contextAccessor.StoreContext.CurrentStore.Id);foreach (var error in customAttributeWarnings) context.AddFailure(error);if (!x.Items.Any(x => x.Quantity > 0))