diff --git a/src/VirtoCommerce.CustomerReviews.Core/ModuleConstants.cs b/src/VirtoCommerce.CustomerReviews.Core/ModuleConstants.cs index 28a4966..71b446b 100644 --- a/src/VirtoCommerce.CustomerReviews.Core/ModuleConstants.cs +++ b/src/VirtoCommerce.CustomerReviews.Core/ModuleConstants.cs @@ -68,7 +68,8 @@ public static class General Name = "CustomerReviews.CustomerReviewsEnabled", GroupName = "Store|Product Reviews", ValueType = SettingValueType.Boolean, - DefaultValue = false + DefaultValue = false, + IsPublic = true, }; public static readonly SettingDescriptor CustomerReviewsEnabledForAnonymous = new SettingDescriptor @@ -76,7 +77,8 @@ public static class General Name = "CustomerReviews.CustomerReviewsEnabledForAnonymous", GroupName = "Store|Product Reviews", ValueType = SettingValueType.Boolean, - DefaultValue = false + DefaultValue = false, + IsPublic = true, }; public static readonly SettingDescriptor CanSubmitReviewWhenHasOrder = new SettingDescriptor @@ -85,12 +87,13 @@ public static class General GroupName = "Store|Product Reviews", ValueType = SettingValueType.Boolean, DefaultValue = true, + IsPublic = true, }; public static readonly SettingDescriptor CalculationMethod = new SettingDescriptor { Name = "CustomerReviews.Calculation.Method", - GroupName = "Product Reviews|General", + GroupName = "Store|Product Reviews", ValueType = SettingValueType.ShortText, DefaultValue = "Average", }; @@ -99,21 +102,30 @@ public static IEnumerable AllSettings { get { - return new List - { - CustomerReviewsEnabled, - CustomerReviewsEnabledForAnonymous, - CanSubmitReviewWhenHasOrder, - RequestReviewEnableJob, - RequestReviewCronJob, - RequestReviewDaysInState, - RequestReviewOrderInState, - RequestReviewMaxRequests - }; + yield return CustomerReviewsEnabled; + yield return CustomerReviewsEnabledForAnonymous; + yield return CanSubmitReviewWhenHasOrder; + yield return RequestReviewEnableJob; + yield return RequestReviewCronJob; + yield return RequestReviewDaysInState; + yield return RequestReviewOrderInState; + yield return RequestReviewMaxRequests; + yield return CalculationMethod; } } } + public static IEnumerable StoreSettings + { + get + { + yield return General.CustomerReviewsEnabled; + yield return General.CustomerReviewsEnabledForAnonymous; + yield return General.CanSubmitReviewWhenHasOrder; + yield return General.CalculationMethod; + } + } + public static IEnumerable JobSettings { get diff --git a/src/VirtoCommerce.CustomerReviews.Core/VirtoCommerce.CustomerReviews.Core.csproj b/src/VirtoCommerce.CustomerReviews.Core/VirtoCommerce.CustomerReviews.Core.csproj index 42a5e59..996001b 100644 --- a/src/VirtoCommerce.CustomerReviews.Core/VirtoCommerce.CustomerReviews.Core.csproj +++ b/src/VirtoCommerce.CustomerReviews.Core/VirtoCommerce.CustomerReviews.Core.csproj @@ -17,6 +17,6 @@ - + \ No newline at end of file diff --git a/src/VirtoCommerce.CustomerReviews.Web/Localizations/en.customerReviews.json b/src/VirtoCommerce.CustomerReviews.Web/Localizations/en.customerReviews.json index 06ca85f..5532c4e 100644 --- a/src/VirtoCommerce.CustomerReviews.Web/Localizations/en.customerReviews.json +++ b/src/VirtoCommerce.CustomerReviews.Web/Localizations/en.customerReviews.json @@ -1,25 +1,25 @@ { - "customerReviews": { - "blades": { - "review-list": { - "title": "Product Reviews", - "labels": { - "title": "Title", - "rating": "Rating", - "review": "Review", - "modifiedDate": "Last updated", - "no-review": "No Reviews found" - }, + "customerReviews": { + "blades": { + "review-list": { + "title": "Product Reviews", + "labels": { + "title": "Title", + "rating": "Rating", + "review": "Review", + "modifiedDate": "Last updated", + "no-review": "No Reviews found" + }, "placeholders": { "select-review-Status": "Select review status", "select-entity-type": "Select entity type" } - }, - "store": { - "calculate-btn": { - "title": "Calculate product rating" - } - }, + }, + "store": { + "calculate-btn": { + "title": "Calculate product rating" + } + }, "review-detail": { "labels": { "title": "Title", @@ -42,15 +42,15 @@ "product-detail": { "description": "Product detail" } - }, - "widgets": { - "item-detail": { - "title": "Reviews" - }, - "product-rating": { - "title": "Rating" - } - }, + }, + "widgets": { + "item-detail": { + "title": "Reviews" + }, + "product-rating": { + "title": "Rating" + } + }, "dialogs": { "customerReview-save": { "title": "Save changes", @@ -65,59 +65,59 @@ "message": "This action may result in a rating change. Are you sure you want to delete review?" } } - }, - "permissions": { - "customerReviews:read": "Open product reviews", - "customerReviews:update": "Approve, reject and reset review status", - "customerReviews:delete": "Delete customer review related data", - "customerReviews:ratingRead": "Read rating", - "customerReviews:ratingRecalc": "Recalculate rating" - }, - "notificationTypes": { - "CustomerReviewEmailNotification": { - "displayName": "Order request review notification", - "description": "The customer will get an email notification when the order is completed and the customer does not leave any product feedback." - } - }, - "settings": { - "CustomerReviews": { - "CustomerReviewsEnabled": { - "title": "Product reviews enabled", - "description": "" - }, - "CustomerReviewsEnabledForAnonymous": { - "title": "Allow anonymous to submit product reviews", - "description": "" - }, - "CanSubmitReviewWhenHasOrder": { - "title": "Only customer who bought product can create new review", - "description": "" - }, - "Calculation.Method": { - "title": "Rating calculation method", - "description": "" - }, - "CustomerReviewsEnabledRequestReviewJob": { - "title": "Enable job to send e-mails request a reviews to customer when order in state at x days", - "description": "" - }, - "CustomerReviewsRequestReviewCronJob": { - "title": "Cron expression for processing job execution", - "description": "The value is a regular CRON expression.\nTo run task every X minutes please use \"0/x * * * *\".\nTo run it every X hours at 00 minutes use \"0 */X * * *\". You can also specify minutes: \"15 */x * * *\"\nTo run it every X days at midnight use \"0 0 */x * *\"" - }, - "CustomerReviewsRequestReviewDaysInState": { - "title": "Order state at x days", - "description": "" - }, - "CustomerReviewsRequestReviewOrderInState": { - "title": "Order state to send mails", - "description": "" - }, - "CustomerReviewsRequestReviewMaxRequests": { - "title": "Max e-mails sent to customer", - "description": "" - } + }, + "permissions": { + "customerReviews:read": "Open product reviews", + "customerReviews:update": "Approve, reject and reset review status", + "customerReviews:delete": "Delete customer review related data", + "customerReviews:ratingRead": "Read rating", + "customerReviews:ratingRecalc": "Recalculate rating" + }, + "notificationTypes": { + "CustomerReviewEmailNotification": { + "displayName": "Order request review notification", + "description": "The customer will get an email notification when the order is completed and the customer does not leave any product feedback." + } + }, + "settings": { + "CustomerReviews": { + "CustomerReviewsEnabled": { + "title": "Product reviews enabled", + "description": "When enabled, customers can provide feedback and reviews for products." + }, + "CustomerReviewsEnabledForAnonymous": { + "title": "Allow anonymous to submit product reviews", + "description": "Enabling this option allows non-registered users to share their opinions on products." + }, + "CanSubmitReviewWhenHasOrder": { + "title": "Only customer who bought product can create new review", + "description": "This restriction ensures that reviews are authored by genuine buyers." + }, + "Calculation.Method": { + "title": "Rating calculation method", + "description": "Defines the approach or algorithm employed to determine ratings based on specific criteria or parameters. " + }, + "CustomerReviewsEnabledRequestReviewJob": { + "title": "Auto Review Email Enabled", + "description": "Enable job to send emails requesting a review to customer when order is in state after x days" + }, + "CustomerReviewsRequestReviewCronJob": { + "title": "Cron expression for processing job execution", + "description": "The value is a regular CRON expression.\nTo run task every X minutes please use \"0/x * * * *\".\nTo run it every X hours at 00 minutes use \"0 */X * * *\". You can also specify minutes: \"15 */x * * *\"\nTo run it every X days at midnight use \"0 0 */x * *\"" + }, + "CustomerReviewsRequestReviewDaysInState": { + "title": "Order state at x days", + "description": "Specifies the duration in days after which an order transitions to a new state." + }, + "CustomerReviewsRequestReviewOrderInState": { + "title": "Order state to send mails", + "description": "Defines the order state at which emails are automatically sent to customers." + }, + "CustomerReviewsRequestReviewMaxRequests": { + "title": "Max e-mails sent to customer", + "description": "Limits the maximum number of emails that can be sent to a customer within a specified timeframe." + } - } - } - } + } + } +} diff --git a/src/VirtoCommerce.CustomerReviews.Web/Module.cs b/src/VirtoCommerce.CustomerReviews.Web/Module.cs index 45ea90f..018e857 100644 --- a/src/VirtoCommerce.CustomerReviews.Web/Module.cs +++ b/src/VirtoCommerce.CustomerReviews.Web/Module.cs @@ -36,7 +36,6 @@ namespace VirtoCommerce.CustomerReviews.Web public class Module : IModule, IHasConfiguration { private IApplicationBuilder _applicationBuilder; - private const string _storeModuleId = "VirtoCommerce.Store"; public ManifestModuleInfo ModuleInfo { get; set; } public IConfiguration Configuration { get; set; } @@ -92,11 +91,8 @@ public void PostInitialize(IApplicationBuilder appBuilder) var settingsRegistrar = appBuilder.ApplicationServices.GetRequiredService(); settingsRegistrar.RegisterSettings(ReviewSettings.AllSettings, ModuleInfo.Id); - var jobSettings = ReviewSettings.JobSettings.Select(s => s.Name).ToList(); - var storeSettings = settingsRegistrar.AllRegisteredSettings.Where(x => x.ModuleId.EqualsInvariant(ModuleInfo.Id) && !jobSettings.Contains(x.Name)).ToList(); - storeSettings.Add(GetCalculatorStoreSetting()); - settingsRegistrar.RegisterSettingsForType(storeSettings, nameof(Store)); - settingsRegistrar.RegisterSettings(storeSettings, _storeModuleId); + UpdateCalculationMethod(); + settingsRegistrar.RegisterSettingsForType(ReviewSettings.StoreSettings, nameof(Store)); var permissionsRegistrar = appBuilder.ApplicationServices.GetRequiredService(); permissionsRegistrar.RegisterPermissions(ModuleInfo.Id, "CustomerReviews", ModuleConstants.Security.Permissions.AllPermissions); @@ -132,13 +128,11 @@ public void Uninstall() // Nothing to do here } - private SettingDescriptor GetCalculatorStoreSetting() + private void UpdateCalculationMethod() { - var result = ReviewSettings.General.CalculationMethod; - result.AllowedValues = _applicationBuilder.ApplicationServices.GetServices() + ReviewSettings.General.CalculationMethod.AllowedValues = _applicationBuilder.ApplicationServices.GetServices() .Select(x => x.Name) .ToArray(); - return result; } } } diff --git a/src/VirtoCommerce.CustomerReviews.Web/module.manifest b/src/VirtoCommerce.CustomerReviews.Web/module.manifest index 652f12b..bbd744e 100644 --- a/src/VirtoCommerce.CustomerReviews.Web/module.manifest +++ b/src/VirtoCommerce.CustomerReviews.Web/module.manifest @@ -3,7 +3,7 @@ VirtoCommerce.CustomerReviews 3.801.0 - 3.800.0 + 3.813.0