-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from seangwright/feat/remove-wrapping-element-p…
…roperty Feature: Dancing Goat example project, Outline tag helper RemoveElement property
- Loading branch information
Showing
301 changed files
with
30,309 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"kentico.xperience.dbmanager": { | ||
"version": "29.6.0", | ||
"commands": [ | ||
"kentico-xperience-dbmanager" | ||
] | ||
} | ||
} | ||
} | ||
|
||
|
171 changes: 171 additions & 0 deletions
171
...es/DancingGoat/AdminComponents/Apps/SampleDataGenerator/SampleDataGeneratorApplication.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
using CMS.Base; | ||
using CMS.ContactManagement; | ||
using CMS.Core; | ||
using CMS.DataEngine; | ||
using CMS.DataProtection; | ||
using CMS.Membership; | ||
using CMS.OnlineForms; | ||
using CMS.Websites; | ||
|
||
using DancingGoat.AdminComponents; | ||
using DancingGoat.Helpers.Generator; | ||
|
||
using Kentico.Forms.Web.Mvc.Internal; | ||
using Kentico.Xperience.Admin.Base; | ||
using Kentico.Xperience.Admin.Base.UIPages; | ||
|
||
[assembly: UIApplication(SampleDataGeneratorApplication.IDENTIFIER, typeof(SampleDataGeneratorApplication), "sample-data-generator", "Sample data generator", BaseApplicationCategories.CONFIGURATION, Icons.CogwheelSquare, TemplateNames.OVERVIEW)] | ||
|
||
namespace DancingGoat.AdminComponents | ||
{ | ||
/// <summary> | ||
/// Represents an application for sample data generation. | ||
/// </summary> | ||
[UIPermission(SystemPermissions.VIEW)] | ||
public class SampleDataGeneratorApplication : OverviewPageBase | ||
{ | ||
/// <summary> | ||
/// Unique identifier of application. | ||
/// </summary> | ||
public const string IDENTIFIER = "Kentico.Xperience.Application.SampleDataGenerator"; | ||
|
||
private const int DANCING_GOAT_WEBSITE_CHANNEL_ID = 1; | ||
private const string FORM_NAME = "DancingGoatCoffeeSampleList"; | ||
private const string FORM_FIELD_NAME = "Consent"; | ||
private const string DATA_PROTECTION_SETTINGS_KEY = "DataProtectionSamplesEnabled"; | ||
|
||
private readonly IFormBuilderConfigurationSerializer formBuilderConfigurationSerializer; | ||
private readonly IEventLogService eventLogService; | ||
private readonly IInfoProvider<ConsentInfo> consentInfoProvider; | ||
private readonly IInfoProvider<BizFormInfo> bizFormInfoProvider; | ||
private readonly IInfoProvider<ContactGroupInfo> contactGroupInfoProvider; | ||
private readonly IInfoProvider<SettingsKeyInfo> settingsKeyInfoProvider; | ||
private readonly IInfoProvider<WebsiteChannelInfo> websiteChannelInfoProvider; | ||
|
||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SampleDataGeneratorApplication"/> class. | ||
/// </summary> | ||
/// <param name="formBuilderConfigurationSerializer">Form builder configuration serializer.</param> | ||
/// <param name="eventLogService">Event log service.</param> | ||
/// <param name="consentInfoProvider">Consent info provider.</param> | ||
/// <param name="bizFormInfoProvider">BizForm info provider.</param> | ||
/// <param name="contactGroupInfoProvider">Contact group info provider.</param> | ||
/// <param name="settingsKeyInfoProvider">Settings key info provider.</param> | ||
/// <param name="websiteChannelInfoProvider">Website channel info provider.</param> | ||
public SampleDataGeneratorApplication( | ||
IFormBuilderConfigurationSerializer formBuilderConfigurationSerializer, | ||
IEventLogService eventLogService, | ||
IInfoProvider<ConsentInfo> consentInfoProvider, | ||
IInfoProvider<BizFormInfo> bizFormInfoProvider, | ||
IInfoProvider<ContactGroupInfo> contactGroupInfoProvider, | ||
IInfoProvider<SettingsKeyInfo> settingsKeyInfoProvider, | ||
IInfoProvider<WebsiteChannelInfo> websiteChannelInfoProvider) | ||
{ | ||
this.formBuilderConfigurationSerializer = formBuilderConfigurationSerializer; | ||
this.eventLogService = eventLogService; | ||
this.consentInfoProvider = consentInfoProvider; | ||
this.bizFormInfoProvider = bizFormInfoProvider; | ||
this.contactGroupInfoProvider = contactGroupInfoProvider; | ||
this.settingsKeyInfoProvider = settingsKeyInfoProvider; | ||
this.websiteChannelInfoProvider = websiteChannelInfoProvider; | ||
} | ||
|
||
|
||
public override Task ConfigurePage() | ||
{ | ||
PageConfiguration.CardGroups.AddCardGroup().AddCard(GetGdprCard()); | ||
|
||
PageConfiguration.Caption = "Sample data generator"; | ||
|
||
return base.ConfigurePage(); | ||
} | ||
|
||
|
||
[PageCommand(Permission = SystemPermissions.VIEW)] | ||
public async Task<ICommandResponse> GenerateGdprSampleData() | ||
{ | ||
try | ||
{ | ||
new TrackingConsentGenerator(consentInfoProvider).Generate(); | ||
new FormConsentGenerator(formBuilderConfigurationSerializer, consentInfoProvider, bizFormInfoProvider).Generate(FORM_NAME, FORM_FIELD_NAME); | ||
new FormContactGroupGenerator(contactGroupInfoProvider).Generate(); | ||
|
||
EnableDataProtectionSamples(); | ||
|
||
await SetChannelDefaultCookieLevelToEssential(DANCING_GOAT_WEBSITE_CHANNEL_ID); | ||
} | ||
catch (Exception ex) | ||
{ | ||
eventLogService.LogException("SampleDataGenerator", "GDPR", ex); | ||
|
||
return Response().AddErrorMessage("GDPR sample data generator failed. See event log for more details."); | ||
} | ||
|
||
return Response().AddSuccessMessage("Generating data finished successfully."); | ||
} | ||
|
||
|
||
private void EnableDataProtectionSamples() | ||
{ | ||
var dataProtectionSamplesEnabledSettingsKey = settingsKeyInfoProvider.Get(DATA_PROTECTION_SETTINGS_KEY); | ||
if (dataProtectionSamplesEnabledSettingsKey?.KeyValue.ToBoolean(false) ?? false) | ||
{ | ||
return; | ||
} | ||
|
||
var keyInfo = new SettingsKeyInfo | ||
{ | ||
KeyName = DATA_PROTECTION_SETTINGS_KEY, | ||
KeyDisplayName = DATA_PROTECTION_SETTINGS_KEY, | ||
KeyType = "boolean", | ||
KeyValue = "True", | ||
KeyIsHidden = true, | ||
}; | ||
|
||
settingsKeyInfoProvider.Set(keyInfo); | ||
} | ||
|
||
|
||
private OverviewCard GetGdprCard() | ||
{ | ||
return new OverviewCard | ||
{ | ||
Headline = "Set up data protection (GDPR) demo", | ||
Actions = new[] | ||
{ | ||
new Kentico.Xperience.Admin.Base.Action(ActionType.Command) | ||
{ | ||
Label = "Generate", | ||
Parameter = nameof(GenerateGdprSampleData), | ||
ButtonColor = ButtonColor.Secondary | ||
} | ||
}, | ||
Components = new List<IOverviewCardComponent>() | ||
{ | ||
new StringContentCardComponent | ||
{ | ||
Content = @"Generates data and enables demonstration of giving consents, personal data portability, right to access, and right to be forgotten features. | ||
Once enabled, the demo functionality cannot be disabled. Use on demo instances only." | ||
} | ||
} | ||
}; | ||
} | ||
|
||
|
||
private async Task SetChannelDefaultCookieLevelToEssential(int websiteChannelId) | ||
{ | ||
var websiteChannel = await websiteChannelInfoProvider.GetAsync(websiteChannelId); | ||
|
||
if (websiteChannel is not null) | ||
{ | ||
websiteChannel.WebsiteChannelDefaultCookieLevel = Kentico.Web.Mvc.CookieLevel.Essential.Level; | ||
websiteChannel.Generalized.SetObject(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace DancingGoat | ||
{ | ||
/// <summary> | ||
/// Encapsulated identifiers of components. | ||
/// </summary> | ||
public static class ComponentIdentifiers | ||
{ | ||
// Widgets | ||
public const string CTA_BUTTON_WIDGET = "DancingGoat.General.CTAButtonWidget"; | ||
public const string TESTIMONIAL_WIDGET = "DancingGoat.LandingPage.TestimonialWidget"; | ||
|
||
// Sections | ||
public const string SINGLE_COLUMN_SECTION = "DancingGoat.SingleColumnSection"; | ||
public const string TWO_COLUMN_SECTION = "DancingGoat.TwoColumnSection"; | ||
public const string THREE_COLUMN_SECTION = "DancingGoat.ThreeColumnSection"; | ||
public const string SECTION_75_25 = "DancingGoat.Section_75_25"; | ||
public const string SECTION_25_75 = "DancingGoat.Section_25_75"; | ||
|
||
// Page templates | ||
public const string LANDING_PAGE_SINGLE_COLUMN_TEMPLATE = "DancingGoat.LandingPageSingleColumn"; | ||
public const string ARTICLE_TEMPLATE = "DancingGoat.Article"; | ||
public const string ARTICLE_WITH_SIDEBAR_TEMPLATE = "DancingGoat.ArticleWithSidebar"; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
examples/DancingGoat/Components/FormBuilderComponentRegister.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using DancingGoat.Components.FormSections.TitledSection; | ||
|
||
using Kentico.Forms.Web.Mvc; | ||
|
||
[assembly: RegisterFormSection("DancingGoat.TitledSection", "Section with title", "~/Components/FormSections/TitledSection/_TitledSection.cshtml", Description = "Single-column section with one zone and an editable title", IconClass = "icon-rectangle-a", PropertiesType = typeof(TitledSectionProperties))] |
12 changes: 12 additions & 0 deletions
12
examples/DancingGoat/Components/FormSections/TitledSection/TitledSectionProperties.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Kentico.Forms.Web.Mvc; | ||
|
||
using Kentico.Xperience.Admin.Base.FormAnnotations; | ||
|
||
namespace DancingGoat.Components.FormSections.TitledSection | ||
{ | ||
public class TitledSectionProperties : IFormSectionProperties | ||
{ | ||
[RichTextEditorComponent(Label = "Title")] | ||
public string Title { get; set; } | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
examples/DancingGoat/Components/FormSections/TitledSection/_TitledSection.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@using Kentico.Forms.Web.Mvc | ||
@using DancingGoat.Components.FormSections.TitledSection | ||
@using Kentico.Web.Mvc; | ||
@using Kentico.PageBuilder.Web.Mvc | ||
|
||
|
||
@model FormSectionViewModel<TitledSectionProperties> | ||
|
||
@if (!string.IsNullOrEmpty(Model?.Properties?.Title)) | ||
{ | ||
<div class="ktc-section-title"> | ||
@Html.Raw(Html.Kentico().ResolveRichText(Model.Properties.Title)) | ||
</div> | ||
} | ||
|
||
<div class="row"> | ||
<div class="col-md-12"> | ||
@await Html.Kentico().FormZoneAsync() | ||
</div> | ||
</div> |
13 changes: 13 additions & 0 deletions
13
...ples/DancingGoat/Components/InlineEditors/ColorPickerEditor/ColorPickerEditorViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace DancingGoat.InlineEditors | ||
{ | ||
/// <summary> | ||
/// View model for Color picker editor. | ||
/// </summary> | ||
public sealed class ColorPickerEditorViewModel : InlineEditorViewModel | ||
{ | ||
/// <summary> | ||
/// Color CSS class. | ||
/// </summary> | ||
public string ColorCssClass { get; set; } | ||
} | ||
} |
Oops, something went wrong.