diff --git a/src/OAP/Oap.Content/ContentTypes.cs b/src/OAP/Oap.Content/ContentTypes.cs index 218c1c5..98aa9eb 100644 --- a/src/OAP/Oap.Content/ContentTypes.cs +++ b/src/OAP/Oap.Content/ContentTypes.cs @@ -4,4 +4,5 @@ public static class ContentTypes public const string OapApplication = nameof(OapApplication); public const string OapApplicationForm = nameof(OapApplicationForm); public const string OapApplicationFormStep = nameof(OapApplicationFormStep); + public const string OapExplanation = nameof(OapExplanation); } diff --git a/src/OAP/Oap.Content/Migrations.cs b/src/OAP/Oap.Content/Migrations.cs index 61807ad..b9a17e8 100644 --- a/src/OAP/Oap.Content/Migrations.cs +++ b/src/OAP/Oap.Content/Migrations.cs @@ -1,4 +1,5 @@ using Oap.OapApplication; +using Oap.OapExplanation; using OrchardCore.Autoroute.Models; using OrchardCore.ContentFields.Fields; using OrchardCore.ContentFields.Settings; @@ -114,5 +115,41 @@ public class Migrations : DataMigration return 2; } + public async Task UpdateFrom2Async() + { + await m_contentDefinitionManager + .AlterPartDefinitionAsync(nameof(OapExplanationPart), part => part + .Attachable()); + + await m_contentDefinitionManager + .AlterTypeDefinitionAsync(ContentTypes.OapExplanation, type => type + .WithPart() + .Stereotype("Widget")); + + return 3; + } + + public async Task UpdateFrom3Async() + { + await m_contentDefinitionManager + .AlterPartDefinitionAsync(nameof(OapExplanationPart), part => part + .WithField(nameof(OapExplanationPart.Text), field => field + .OfType(nameof(HtmlField)) + .WithDisplayName(nameof(OapExplanationPart.Text)) + .WithDescription("A detailed explanation of a field."))); + + return 4; + } + + public async Task UpdateFrom4Async() + { + await m_contentDefinitionManager + .AlterPartDefinitionAsync(nameof(OapExplanationPart), part => part + .WithField(nameof(OapExplanationPart.Text), field => field + .WithSettings(new ContentPartFieldSettings { Editor = "Wysiwyg" }))); + + return 5; + } + private readonly IContentDefinitionManager m_contentDefinitionManager; } diff --git a/src/OAP/Oap.Content/Startup.cs b/src/OAP/Oap.Content/Startup.cs index a163d2e..7cbfcdd 100644 --- a/src/OAP/Oap.Content/Startup.cs +++ b/src/OAP/Oap.Content/Startup.cs @@ -2,6 +2,8 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; using Oap.OapApplication; +using Oap.OapExplanation; +using OrchardCore.ContentManagement; using OrchardCore.Data.Migration; namespace Oap.Content; @@ -10,7 +12,8 @@ public class Startup : OrchardCore.Modules.StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddScoped(); + services.AddContentPart(); + services.AddContentPart(); services.AddDataMigration(); } diff --git a/src/OAP/Oap.Theme/Views/ButtonPart.cshtml b/src/OAP/Oap.Theme/Views/ButtonPart.cshtml new file mode 100644 index 0000000..a5992ed --- /dev/null +++ b/src/OAP/Oap.Theme/Views/ButtonPart.cshtml @@ -0,0 +1,16 @@ +@using OrchardCore.Forms.Models +@model OrchardCore.DisplayManagement.Views.ShapeViewModel +@{ + var formElementPart = Model.Value.ContentItem.As(); + var formInputElementPart = Model.Value.ContentItem.As(); + var elementId = formElementPart.Id; + var elementName = formInputElementPart.Name; + var id = !string.IsNullOrEmpty(elementId) ? elementId : !string.IsNullOrEmpty(elementName) ? Html.GenerateIdFromName(elementName) : default(string); +} + \ No newline at end of file diff --git a/src/OAP/Oap.Theme/Views/Content-OapApplicationFormStep.cshtml b/src/OAP/Oap.Theme/Views/Content-OapApplicationFormStep.cshtml index 75dea36..316dcfe 100644 --- a/src/OAP/Oap.Theme/Views/Content-OapApplicationFormStep.cshtml +++ b/src/OAP/Oap.Theme/Views/Content-OapApplicationFormStep.cshtml @@ -1,10 +1,20 @@

- @Model.Header.TitlePart.Title + Form Title

- + +
+

+ @Model.Header.TitlePart.Title +

+ + @await DisplayAsync(Model.Content.HtmlBodyPart) + + @await DisplayAsync(Model.Content.FlowPart) +
+
\ No newline at end of file diff --git a/src/OAP/Oap.Theme/Views/Form-FlowPart.cshtml b/src/OAP/Oap.Theme/Views/Form-FlowPart.cshtml new file mode 100644 index 0000000..d920e7d --- /dev/null +++ b/src/OAP/Oap.Theme/Views/Form-FlowPart.cshtml @@ -0,0 +1,13 @@ +@model OrchardCore.Flows.ViewModels.FlowPartViewModel +@inject OrchardCore.ContentManagement.Display.IContentItemDisplayManager ContentItemDisplayManager + +@foreach (var widget in Model.FlowPart.Widgets) +{ + var widgetContent = await ContentItemDisplayManager.BuildDisplayAsync( + widget, + Model.BuildPartDisplayContext.Updater, + Model.BuildPartDisplayContext.DisplayType, + Model.BuildPartDisplayContext.GroupId); + + @await DisplayAsync(widgetContent) +} \ No newline at end of file diff --git a/src/OAP/Oap.Theme/Views/LabelPart.cshtml b/src/OAP/Oap.Theme/Views/LabelPart.cshtml new file mode 100644 index 0000000..7b14174 --- /dev/null +++ b/src/OAP/Oap.Theme/Views/LabelPart.cshtml @@ -0,0 +1,8 @@ +@using OrchardCore.Forms.Models +@model OrchardCore.DisplayManagement.Views.ShapeViewModel + +@{ + var contentItem = Model.Value.ContentItem; + var formElementPart = contentItem.As(); +} + diff --git a/src/OAP/Oap.Theme/Views/OapExplanationPart.cshtml b/src/OAP/Oap.Theme/Views/OapExplanationPart.cshtml new file mode 100644 index 0000000..2d9a0a6 --- /dev/null +++ b/src/OAP/Oap.Theme/Views/OapExplanationPart.cshtml @@ -0,0 +1,3 @@ +

+ @Html.Raw(Model.Html) +

\ No newline at end of file diff --git a/src/OAP/Oap.Theme/Views/Widget-Button.cshtml b/src/OAP/Oap.Theme/Views/Widget-Button.cshtml new file mode 100644 index 0000000..0c0a646 --- /dev/null +++ b/src/OAP/Oap.Theme/Views/Widget-Button.cshtml @@ -0,0 +1,3 @@ +
+ @await DisplayAsync(Model.Content) +
\ No newline at end of file diff --git a/src/OAP/Oap.Theme/Views/Widget-Form.cshtml b/src/OAP/Oap.Theme/Views/Widget-Form.cshtml new file mode 100644 index 0000000..34db75f --- /dev/null +++ b/src/OAP/Oap.Theme/Views/Widget-Form.cshtml @@ -0,0 +1,3 @@ +
+ @await DisplayAsync(Model.Content) +
\ No newline at end of file diff --git a/src/OAP/Oap.Theme/Views/Widget-Input.cshtml b/src/OAP/Oap.Theme/Views/Widget-Input.cshtml new file mode 100644 index 0000000..9f13a96 --- /dev/null +++ b/src/OAP/Oap.Theme/Views/Widget-Input.cshtml @@ -0,0 +1,3 @@ +
+ @await DisplayAsync(Model.Content) +
\ No newline at end of file diff --git a/src/OAP/Oap.Theme/Views/Widget-OapExplanation.cshtml b/src/OAP/Oap.Theme/Views/Widget-OapExplanation.cshtml new file mode 100644 index 0000000..8e8f40c --- /dev/null +++ b/src/OAP/Oap.Theme/Views/Widget-OapExplanation.cshtml @@ -0,0 +1,3 @@ +
+ @await DisplayAsync(Model.Content) +
\ No newline at end of file diff --git a/src/OAP/Oap.Theme/Views/Widget-Select.cshtml b/src/OAP/Oap.Theme/Views/Widget-Select.cshtml new file mode 100644 index 0000000..da2b36a --- /dev/null +++ b/src/OAP/Oap.Theme/Views/Widget-Select.cshtml @@ -0,0 +1,3 @@ +
+ @await DisplayAsync(Model.Content) +
\ No newline at end of file diff --git a/src/OAP/Oap.Theme/wwwroot/site.css b/src/OAP/Oap.Theme/wwwroot/site.css index bc52d27..c5db977 100644 --- a/src/OAP/Oap.Theme/wwwroot/site.css +++ b/src/OAP/Oap.Theme/wwwroot/site.css @@ -564,15 +564,25 @@ span.field-validation-error { margin-top: 0.25rem; margin-bottom: 0.25rem; } +.my-2 { + margin-top: 0.5rem; + margin-bottom: 0.5rem; +} .mb-6 { margin-bottom: 1.5rem; } +.block { + display: block; +} .flex { display: flex; } .table { display: table; } +.grid { + display: grid; +} .hidden { display: none; } @@ -585,18 +595,39 @@ span.field-validation-error { .max-w-screen-md { max-width: 768px; } +.cursor-pointer { + cursor: pointer; +} +.grid-cols-2 { + grid-template-columns: repeat(2, minmax(0, 1fr)); +} +.grid-rows-2 { + grid-template-rows: repeat(2, minmax(0, 1fr)); +} .flex-row { flex-direction: row; } .flex-col { flex-direction: column; } +.justify-end { + justify-content: flex-end; +} +.gap-2 { + gap: 0.5rem; +} +.gap-4 { + gap: 1rem; +} .gap-x-4 { column-gap: 1rem; } .whitespace-nowrap { white-space: nowrap; } +.rounded-md { + border-radius: 0.375rem; +} .border-\[1px\] { border-width: 1px; } @@ -618,6 +649,10 @@ span.field-validation-error { --tw-border-opacity: 1; border-right-color: rgb(255 255 255 / var(--tw-border-opacity)); } +.bg-amber-300 { + --tw-bg-opacity: 1; + background-color: rgb(252 211 77 / var(--tw-bg-opacity)); +} .p-6 { padding: 1.5rem; } @@ -629,6 +664,14 @@ span.field-validation-error { padding-left: 0.5rem; padding-right: 0.5rem; } +.px-4 { + padding-left: 1rem; + padding-right: 1rem; +} +.py-2 { + padding-top: 0.5rem; + padding-bottom: 0.5rem; +} .pb-1 { padding-bottom: 0.25rem; } @@ -638,6 +681,9 @@ span.field-validation-error { .pt-1 { padding-top: 0.25rem; } +.pl-4 { + padding-left: 1rem; +} .text-center { text-align: center; } @@ -652,6 +698,10 @@ span.field-validation-error { font-size: 0.875rem; line-height: 1.25rem; } +.text-lg { + font-size: 1.125rem; + line-height: 1.75rem; +} .font-bold { font-weight: 700; } @@ -663,9 +713,28 @@ span.field-validation-error { --tw-text-opacity: 1; color: rgb(107 114 128 / var(--tw-text-opacity)); } +.text-gray-800 { + --tw-text-opacity: 1; + color: rgb(31 41 55 / var(--tw-text-opacity)); +} +.hover\:bg-amber-500:hover { + --tw-bg-opacity: 1; + background-color: rgb(245 158 11 / var(--tw-bg-opacity)); +} .hover\:text-black:hover { --tw-text-opacity: 1; color: rgb(0 0 0 / var(--tw-text-opacity)); } +.disabled\:cursor-not-allowed:disabled { + cursor: not-allowed; +} +.disabled\:bg-gray-400:disabled { + --tw-bg-opacity: 1; + background-color: rgb(156 163 175 / var(--tw-bg-opacity)); +} +.disabled\:text-gray-600:disabled { + --tw-text-opacity: 1; + color: rgb(75 85 99 / var(--tw-text-opacity)); +} diff --git a/src/OAP/Oap/OapExplanation/OapExplanationPart.cs b/src/OAP/Oap/OapExplanation/OapExplanationPart.cs new file mode 100644 index 0000000..791acf2 --- /dev/null +++ b/src/OAP/Oap/OapExplanation/OapExplanationPart.cs @@ -0,0 +1,8 @@ +using OrchardCore.ContentFields.Fields; +using OrchardCore.ContentManagement; + +namespace Oap.OapExplanation; +public class OapExplanationPart : ContentPart +{ + public HtmlField Text { get; set; } = new(); +} diff --git a/src/Twain.Web/Program.cs b/src/Twain.Web/Program.cs index 913f0d2..2fe99a2 100644 --- a/src/Twain.Web/Program.cs +++ b/src/Twain.Web/Program.cs @@ -8,12 +8,11 @@ builder.Services .AddOrchardCms() .EnableFeature("OrchardCore.Tenants") .AddSetupFeatures("OrchardCore.AutoSetup") - // // Orchard Specific Pipeline - // .ConfigureServices( services => { - // }) - // .Configure( (app, routes, services) => { - // }) -; + .ConfigureServices(tenantServices => + tenantServices.ConfigureHtmlSanitizer((sanitizer) => + { + sanitizer.AllowedSchemes.Add("mailto"); + })); var app = builder.Build();