Skip to content

Commit b9d5150

Browse files
committed
Merge branch 'issue-1832-configurable-contact-form' into develop
# Conflicts: # src/Libraries/Nop.Data/Migrations/UpgradeTo500/DataMigration.cs # src/Libraries/Nop.Data/Migrations/UpgradeTo500/SchemaMigration.cs # src/Presentation/Nop.Web.Framework/Migrations/UpgradeTo500/LocalizationMigration.cs
2 parents 848aba0 + 0ae2059 commit b9d5150

51 files changed

Lines changed: 2064 additions & 69 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Nop.Core.Domain.Attributes;
2+
3+
namespace Nop.Core.Domain.Common;
4+
5+
/// <summary>
6+
/// Represents a contact form attribute
7+
/// </summary>
8+
public partial class ContactFormAttribute : BaseAttribute;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Nop.Core.Domain.Attributes;
2+
3+
namespace Nop.Core.Domain.Common;
4+
5+
/// <summary>
6+
/// Represents a contact form attribute value
7+
/// </summary>
8+
public partial class ContactFormAttributeValue : BaseAttributeValue;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using FluentMigrator.Builders.Create.Table;
2+
using Nop.Core.Domain.Common;
3+
4+
namespace Nop.Data.Mapping.Builders.Common;
5+
6+
/// <summary>
7+
/// Represents a contact form attribute entity builder
8+
/// </summary>
9+
public partial class ContactFormAttributeBuilder : NopEntityBuilder<ContactFormAttribute>
10+
{
11+
#region Methods
12+
13+
/// <summary>
14+
/// Apply entity configuration
15+
/// </summary>
16+
/// <param name="table">Create table expression builder</param>
17+
public override void MapEntity(CreateTableExpressionBuilder table)
18+
{
19+
table.WithColumn(nameof(ContactFormAttribute.Name)).AsString(400).NotNullable();
20+
}
21+
22+
#endregion
23+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using FluentMigrator.Builders.Create.Table;
2+
using Nop.Core.Domain.Common;
3+
using Nop.Data.Extensions;
4+
5+
namespace Nop.Data.Mapping.Builders.Common;
6+
7+
/// <summary>
8+
/// Represents a contact form attribute value entity builder
9+
/// </summary>
10+
public partial class ContactFormAttributeValueBuilder : NopEntityBuilder<ContactFormAttributeValue>
11+
{
12+
#region Methods
13+
14+
/// <summary>
15+
/// Apply entity configuration
16+
/// </summary>
17+
/// <param name="table">Create table expression builder</param>
18+
public override void MapEntity(CreateTableExpressionBuilder table)
19+
{
20+
table
21+
.WithColumn(nameof(ContactFormAttributeValue.Name)).AsString(400).NotNullable()
22+
.WithColumn(nameof(ContactFormAttributeValue.AttributeId)).AsInt32().ForeignKey<ContactFormAttribute>();
23+
}
24+
25+
#endregion
26+
}

src/Libraries/Nop.Data/Migrations/Installation/SchemaMigration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,7 @@ public override void Up()
159159
this.CreateTableIfNotExists<VendorNote>();
160160
this.CreateTableIfNotExists<Menu>();
161161
this.CreateTableIfNotExists<MenuItem>();
162+
this.CreateTableIfNotExists<ContactFormAttribute>();
163+
this.CreateTableIfNotExists<ContactFormAttributeValue>();
162164
}
163165
}

src/Libraries/Nop.Data/Migrations/UpgradeTo500/DataMigration.cs

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using FluentMigrator;
2+
using Nop.Core.Domain.Logging;
23
using Nop.Core.Domain.ScheduleTasks;
34

45
namespace Nop.Data.Migrations.UpgradeTo500;
@@ -32,10 +33,85 @@ public override void Up()
3233
StopOnError = false
3334
});
3435
}
36+
37+
var activityLogTypeTable = _dataProvider.GetTable<ActivityLogType>();
38+
39+
//#1832
40+
if (!activityLogTypeTable.Any(alt => string.Compare(alt.SystemKeyword, "AddNewContactFormAttribute", StringComparison.InvariantCultureIgnoreCase) == 0))
41+
{
42+
_dataProvider.InsertEntity(
43+
new ActivityLogType
44+
{
45+
SystemKeyword = "AddNewContactFormAttribute",
46+
Enabled = true,
47+
Name = "Add a new contact form attribute"
48+
}
49+
);
50+
}
51+
52+
if (!activityLogTypeTable.Any(alt => string.Compare(alt.SystemKeyword, "EditContactFormAttribute", StringComparison.InvariantCultureIgnoreCase) == 0))
53+
{
54+
_dataProvider.InsertEntity(
55+
new ActivityLogType
56+
{
57+
SystemKeyword = "EditContactFormAttribute",
58+
Enabled = true,
59+
Name = "Edit a contact form attribute"
60+
}
61+
);
62+
}
63+
64+
if (!activityLogTypeTable.Any(alt => string.Compare(alt.SystemKeyword, "DeleteContactFormAttribute", StringComparison.InvariantCultureIgnoreCase) == 0))
65+
{
66+
_dataProvider.InsertEntity(
67+
new ActivityLogType
68+
{
69+
SystemKeyword = "DeleteContactFormAttribute",
70+
Enabled = true,
71+
Name = "Delete a contact form attribute"
72+
}
73+
);
74+
}
75+
76+
if (!activityLogTypeTable.Any(alt => string.Compare(alt.SystemKeyword, "AddNewContactFormAttributeValue", StringComparison.InvariantCultureIgnoreCase) == 0))
77+
{
78+
_dataProvider.InsertEntity(
79+
new ActivityLogType
80+
{
81+
SystemKeyword = "AddNewContactFormAttributeValue",
82+
Enabled = true,
83+
Name = "Add a new contact form attribute value"
84+
}
85+
);
86+
}
87+
88+
if (!activityLogTypeTable.Any(alt => string.Compare(alt.SystemKeyword, "EditContactFormAttributeValue", StringComparison.InvariantCultureIgnoreCase) == 0))
89+
{
90+
_dataProvider.InsertEntity(
91+
new ActivityLogType
92+
{
93+
SystemKeyword = "EditContactFormAttributeValue",
94+
Enabled = true,
95+
Name = "Edit a contact form attribute value"
96+
}
97+
);
98+
}
99+
100+
if (!activityLogTypeTable.Any(alt => string.Compare(alt.SystemKeyword, "DeleteContactFormAttributeValue", StringComparison.InvariantCultureIgnoreCase) == 0))
101+
{
102+
_dataProvider.InsertEntity(
103+
new ActivityLogType
104+
{
105+
SystemKeyword = "DeleteContactFormAttributeValue",
106+
Enabled = true,
107+
Name = "Delete a contact form attribute value"
108+
}
109+
);
110+
}
35111
}
36112

37113
public override void Down()
38114
{
39115
//add the downgrade logic if necessary
40116
}
41-
}
117+
}

src/Libraries/Nop.Data/Migrations/UpgradeTo500/SchemaMigration.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using FluentMigrator;
22
using Nop.Core.Domain.Catalog;
33
using Nop.Core.Domain.Customers;
4+
using Nop.Core.Domain.Common;
45
using Nop.Core.Domain.Orders;
56
using Nop.Data.Extensions;
67

78
namespace Nop.Data.Migrations.UpgradeTo500;
89

9-
[NopSchemaMigration("2026-01-13 00:00:02", "SchemaMigration for 5.00.0")]
10+
[NopSchemaMigration("2026-01-13 00:00:03", "SchemaMigration for 5.00.0")]
1011
public class SchemaMigration : ForwardOnlyMigration
1112
{
1213
/// <summary>
@@ -88,5 +89,9 @@ public override void Up()
8889
this.AddOrAlterColumnFor<Order>(t => t.LastPendingOrderFollowUpDateUtc)
8990
.AsDateTime2()
9091
.Nullable();
92+
93+
//#1832
94+
this.CreateTableIfNotExists<ContactFormAttribute>();
95+
this.CreateTableIfNotExists<ContactFormAttributeValue>();
9196
}
9297
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Nop.Core.Domain.Common;
2+
using Nop.Services.Attributes;
3+
using Nop.Services.Caching;
4+
5+
namespace Nop.Services.Common.Caching;
6+
7+
/// <summary>
8+
/// Represents a contact form attribute cache event consumer
9+
/// </summary>
10+
public partial class ContactFormAttributeCacheEventConsumer : CacheEventConsumer<ContactFormAttribute>
11+
{
12+
/// <summary>
13+
/// Clear cache data
14+
/// </summary>
15+
/// <param name="entity">Entity</param>
16+
/// <returns>A task that represents the asynchronous operation</returns>
17+
protected override async Task ClearCacheAsync(ContactFormAttribute entity)
18+
{
19+
await RemoveAsync(NopAttributeDefaults.AttributeValuesByAttributeCacheKey, nameof(ContactFormAttribute), entity);
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Nop.Core.Domain.Common;
2+
using Nop.Services.Attributes;
3+
using Nop.Services.Caching;
4+
5+
namespace Nop.Services.Common.Caching;
6+
7+
/// <summary>
8+
/// Represents a contact form attribute value cache event consumer
9+
/// </summary>
10+
public partial class ContactFormAttributeValueCacheEventConsumer : CacheEventConsumer<ContactFormAttributeValue>
11+
{
12+
/// <summary>
13+
/// Clear cache data
14+
/// </summary>
15+
/// <param name="entity">Entity</param>
16+
/// <returns>A task that represents the asynchronous operation</returns>
17+
protected override async Task ClearCacheAsync(ContactFormAttributeValue entity)
18+
{
19+
await RemoveAsync(NopAttributeDefaults.AttributeValuesByAttributeCacheKey, nameof(ContactFormAttribute), entity.AttributeId);
20+
}
21+
}

src/Libraries/Nop.Services/Common/NopCommonDefaults.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ public static partial class NopCommonDefaults
2424

2525
#endregion
2626

27+
#region Contact form attributes
28+
29+
/// <summary>
30+
/// Gets a name of the contact form attribute control
31+
/// </summary>
32+
/// <remarks>
33+
/// {0} : contact form attribute id
34+
/// </remarks>
35+
public static string ContactFormAttributeControlName => "contact_form_attribute_{0}";
36+
37+
#endregion
38+
2739
#region Maintenance
2840

2941
/// <summary>

0 commit comments

Comments
 (0)