diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e46ba33 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "twain", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "twain", + "version": "1.0.0", + "license": "ISC" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..c9b84c0 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "twain", + "version": "1.0.0", + "description": "", + "main": "index.js", + "directories": { + "doc": "docs" + }, + "scripts": { + "watch": "dotnet watch --project ./src/Twain.Web/Twain.Web.csproj", + "watch-theme": "npm run dev --prefix src/OAP/OAP.Theme.Svelte" + }, + "author": "", + "license": "ISC" +} diff --git a/src/OAP/Oap.Content/Migrations.cs b/src/OAP/Oap.Content/Migrations.cs index a8a8f61..e4aef67 100644 --- a/src/OAP/Oap.Content/Migrations.cs +++ b/src/OAP/Oap.Content/Migrations.cs @@ -1,243 +1,273 @@ -using Oap.OapApplication; -using OrchardCore.Autoroute.Models; -using OrchardCore.ContentFields.Fields; -using OrchardCore.ContentFields.Settings; -using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; -using OrchardCore.Data.Migration; -using OrchardCore.Flows.Models; -using OrchardCore.Forms.Models; -using OrchardCore.Html.Models; -using OrchardCore.Html.Settings; -using OrchardCore.Lists.Models; -using OrchardCore.Mvc.Utilities; -using OrchardCore.Title.Models; - -namespace Oap.Content; - -public class Migrations : DataMigration -{ - public Migrations(IContentDefinitionManager contentDefinitionManager) - { - m_contentDefinitionManager = contentDefinitionManager; - } - - public async Task CreateAsync() - { - await m_contentDefinitionManager - .AlterTypeDefinitionAsync(ContentTypes.OapApplicationFormStep, type => type - .Securable() - .Draftable() - .Versionable() - .WithPart(nameof(TitlePart), part => part - .WithPosition("1")) - .WithPart(nameof(AutoroutePart), part => part - .WithPosition("2") - .WithSettings(new AutoroutePartSettings - { - AllowCustomPath = true, - AllowUpdatePath = true, - })) - .WithPart(nameof(FlowPart), part => part - .WithPosition("3"))); - - await m_contentDefinitionManager - .AlterTypeDefinitionAsync(ContentTypes.OapApplicationForm, type => type - .Creatable() - .Listable() - .Securable() - .Draftable() - .Versionable() - .WithPart(nameof(AutoroutePart), part => part - .WithPosition("2") - .WithSettings(new AutoroutePartSettings - { - AllowCustomPath = true, - AllowUpdatePath = true, - })) - .WithPart(nameof(ListPart), part => part - .WithDisplayName("Form Steps") - .WithPosition("3") - .WithSettings(new ListPartSettings - { - PageSize = 10, - EnableOrdering = true, - ContainedContentTypes = [ContentTypes.OapApplicationFormStep] - }) - )); - - await m_contentDefinitionManager - .AlterPartDefinitionAsync(nameof(OapApplicationPart), builder => builder - .Attachable() - .WithField(nameof(OapApplicationPart.Status), field => field - .OfType(nameof(TextField)) - .WithDisplayName(nameof(OapApplicationPart.Status)) - .WithDescription("The status of the OAP Application.") - .WithEditor("PredefinedList") - .WithSettings(new TextFieldPredefinedListEditorSettings - { - Options = new[] - { - new ListValueOption { Name = OapApplicationStatuses.InProgress, Value = OapApplicationStatuses.InProgress.HtmlClassify() }, - new ListValueOption { Name = OapApplicationStatuses.Submitted, Value = OapApplicationStatuses.Submitted.HtmlClassify() }, - }, - DefaultValue = OapApplicationStatuses.InProgress.HtmlClassify(), - Editor = EditorOption.Radio, - })) - .WithDescription("Makes a content item into an OAP Application.")); - - await m_contentDefinitionManager - .AlterTypeDefinitionAsync(ContentTypes.OapApplication, type => type - .Creatable() - .Listable() - .Securable() - .WithPart(nameof(HtmlBodyPart), part => part - .WithDisplayName("Notes") - .WithSettings(new ContentTypePartSettings { Editor = "Wysiwyg", }) - ) - .WithPart(nameof(OapApplicationPart))); - - return 1; - } - - public async Task UpdateFrom1Async() - { - await m_contentDefinitionManager - .AlterTypeDefinitionAsync(ContentTypes.OapApplicationFormStep, type => type - .WithPart(nameof(HtmlBodyPart), part => part - .WithPosition("2") - .WithEditor("Wysiwyg") - .WithSettings(new HtmlBodyPartSettings - { - SanitizeHtml = true, - }))); - - return 2; - } - - public Task UpdateFrom2Async() - { - return Task.FromResult(3); - } - - public Task UpdateFrom3Async() - { - return Task.FromResult(4); - } - - public Task UpdateFrom4Async() - { - return Task.FromResult(5); - } - - public Task UpdateFrom5Async() - { - return Task.FromResult(6); - } - - public async Task UpdateFrom6Async() - { - await m_contentDefinitionManager - .AlterTypeDefinitionAsync(ContentTypes.OapApplicationForm, type => type - .WithPart(nameof(TitlePart))); - - return 7; - } - - public async Task UpdateFrom7Async() - { - await m_contentDefinitionManager - .AlterTypeDefinitionAsync("Input", type => type - .WithPart("Explanation", "HtmlBodyPart", part => part - .WithPosition("1") - .WithDisplayName("Details to help the user correctly fill out this form field.") - .WithEditor("Wysiwyg") - )); - - await m_contentDefinitionManager - .AlterTypeDefinitionAsync("TextArea", type => type - .WithPart("Explanation", "HtmlBodyPart", part => part - .WithPosition("1") - .WithDisplayName("Details to help the user correctly fill out this form field.") - .WithEditor("Wysiwyg") - )); - - await m_contentDefinitionManager - .AlterTypeDefinitionAsync("Select", type => type - .WithPart("Explanation", "HtmlBodyPart", part => part - .WithPosition("1") - .WithDisplayName("Details to help the user correctly fill out this form field.") - .WithEditor("Wysiwyg") - )); - - return 8; - } - - public async Task UpdateFrom8Async() - { - await m_contentDefinitionManager - .AlterTypeDefinitionAsync("Input", type => type - .WithPart("Explanation", "HtmlBodyPart", part => part - .WithPosition("4") - ) - .WithPart("InputPart", part => part - .WithPosition("5") - ) - .WithPart("FormElementValidationPart", part => part - .WithPosition("6") - )); - - await m_contentDefinitionManager - .AlterTypeDefinitionAsync("TextArea", type => type - .WithPart("Explanation", "HtmlBodyPart", part => part - .WithPosition("4") - ) - .WithPart("TextAreaPart", part => part - .WithPosition("5") - ) - .WithPart("FormElementValidationPart", part => part - .WithPosition("6") - )); - - await m_contentDefinitionManager - .AlterTypeDefinitionAsync("Select", type => type - .WithPart("Explanation", "HtmlBodyPart", part => part - .WithPosition("4") - ) - .WithPart("SelectPart", part => part - .WithPosition("5") - ) - .WithPart("FormElementValidationPart", part => part - .WithPosition("6") - )); - - return 9; - } - public async Task UpdateFrom9Async() - { - await m_contentDefinitionManager - .AlterTypeDefinitionAsync("Input", type => type - .WithPart("Explanation", "HtmlBodyPart", part => part - .WithDisplayName("Explanation") - .WithDescription("Details to help the user correctly fill out this form field.") - )); - - await m_contentDefinitionManager - .AlterTypeDefinitionAsync("TextArea", type => type - .WithPart("Explanation", "HtmlBodyPart", part => part - .WithDisplayName("Explanation") - .WithDescription("Details to help the user correctly fill out this form field.") - )); - - await m_contentDefinitionManager - .AlterTypeDefinitionAsync("Select", type => type - .WithPart("Explanation", "HtmlBodyPart", part => part - .WithDisplayName("Explanation") - .WithDescription("Details to help the user correctly fill out this form field.") - )); - - return 10; - } - - private readonly IContentDefinitionManager m_contentDefinitionManager; -} +using Oap.OapApplication; +using OrchardCore.Autoroute.Models; +using OrchardCore.ContentFields.Fields; +using OrchardCore.ContentFields.Settings; +using OrchardCore.ContentManagement.Metadata; +using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.Data.Migration; +using OrchardCore.Flows.Models; +using OrchardCore.Forms.Models; +using OrchardCore.Html.Models; +using OrchardCore.Html.Settings; +using OrchardCore.Lists.Models; +using OrchardCore.Mvc.Utilities; +using OrchardCore.Title.Models; + +namespace Oap.Content; + +public class Migrations : DataMigration +{ + public Migrations(IContentDefinitionManager contentDefinitionManager) + { + m_contentDefinitionManager = contentDefinitionManager; + } + + public async Task CreateAsync() + { + await m_contentDefinitionManager + .AlterTypeDefinitionAsync(ContentTypes.OapApplicationFormStep, type => type + .Securable() + .Draftable() + .Versionable() + .WithPart(nameof(TitlePart), part => part + .WithPosition("1")) + .WithPart(nameof(AutoroutePart), part => part + .WithPosition("2") + .WithSettings(new AutoroutePartSettings + { + AllowCustomPath = true, + AllowUpdatePath = true, + })) + .WithPart(nameof(FlowPart), part => part + .WithPosition("3"))); + + await m_contentDefinitionManager + .AlterTypeDefinitionAsync(ContentTypes.OapApplicationForm, type => type + .Creatable() + .Listable() + .Securable() + .Draftable() + .Versionable() + .WithPart(nameof(AutoroutePart), part => part + .WithPosition("2") + .WithSettings(new AutoroutePartSettings + { + AllowCustomPath = true, + AllowUpdatePath = true, + })) + .WithPart(nameof(ListPart), part => part + .WithDisplayName("Form Steps") + .WithPosition("3") + .WithSettings(new ListPartSettings + { + PageSize = 10, + EnableOrdering = true, + ContainedContentTypes = [ContentTypes.OapApplicationFormStep] + }) + )); + + await m_contentDefinitionManager + .AlterPartDefinitionAsync(nameof(OapApplicationPart), builder => builder + .Attachable() + .WithField(nameof(OapApplicationPart.Status), field => field + .OfType(nameof(TextField)) + .WithDisplayName(nameof(OapApplicationPart.Status)) + .WithDescription("The status of the OAP Application.") + .WithEditor("PredefinedList") + .WithSettings(new TextFieldPredefinedListEditorSettings + { + Options = new[] + { + new ListValueOption { Name = OapApplicationStatuses.InProgress, Value = OapApplicationStatuses.InProgress.HtmlClassify() }, + new ListValueOption { Name = OapApplicationStatuses.Submitted, Value = OapApplicationStatuses.Submitted.HtmlClassify() }, + }, + DefaultValue = OapApplicationStatuses.InProgress.HtmlClassify(), + Editor = EditorOption.Radio, + })) + .WithDescription("Makes a content item into an OAP Application.")); + + await m_contentDefinitionManager + .AlterTypeDefinitionAsync(ContentTypes.OapApplication, type => type + .Creatable() + .Listable() + .Securable() + .WithPart(nameof(HtmlBodyPart), part => part + .WithDisplayName("Notes") + .WithSettings(new ContentTypePartSettings { Editor = "Wysiwyg", }) + ) + .WithPart(nameof(OapApplicationPart))); + + return 1; + } + + public async Task UpdateFrom1Async() + { + await m_contentDefinitionManager + .AlterTypeDefinitionAsync(ContentTypes.OapApplicationFormStep, type => type + .WithPart(nameof(HtmlBodyPart), part => part + .WithPosition("2") + .WithEditor("Wysiwyg") + .WithSettings(new HtmlBodyPartSettings + { + SanitizeHtml = true, + }))); + + return 2; + } + + public Task UpdateFrom2Async() + { + return Task.FromResult(3); + } + + public Task UpdateFrom3Async() + { + return Task.FromResult(4); + } + + public Task UpdateFrom4Async() + { + return Task.FromResult(5); + } + + public Task UpdateFrom5Async() + { + return Task.FromResult(6); + } + + public async Task UpdateFrom6Async() + { + await m_contentDefinitionManager + .AlterTypeDefinitionAsync(ContentTypes.OapApplicationForm, type => type + .WithPart(nameof(TitlePart))); + + return 7; + } + + public async Task UpdateFrom7Async() + { + await m_contentDefinitionManager + .AlterTypeDefinitionAsync("Input", type => type + .WithPart("Explanation", "HtmlBodyPart", part => part + .WithPosition("1") + .WithDisplayName("Details to help the user correctly fill out this form field.") + .WithEditor("Wysiwyg") + )); + + await m_contentDefinitionManager + .AlterTypeDefinitionAsync("TextArea", type => type + .WithPart("Explanation", "HtmlBodyPart", part => part + .WithPosition("1") + .WithDisplayName("Details to help the user correctly fill out this form field.") + .WithEditor("Wysiwyg") + )); + + await m_contentDefinitionManager + .AlterTypeDefinitionAsync("Select", type => type + .WithPart("Explanation", "HtmlBodyPart", part => part + .WithPosition("1") + .WithDisplayName("Details to help the user correctly fill out this form field.") + .WithEditor("Wysiwyg") + )); + + return 8; + } + + public async Task UpdateFrom8Async() + { + await m_contentDefinitionManager + .AlterTypeDefinitionAsync("Input", type => type + .WithPart("Explanation", "HtmlBodyPart", part => part + .WithPosition("4") + ) + .WithPart("InputPart", part => part + .WithPosition("5") + ) + .WithPart("FormElementValidationPart", part => part + .WithPosition("6") + )); + + await m_contentDefinitionManager + .AlterTypeDefinitionAsync("TextArea", type => type + .WithPart("Explanation", "HtmlBodyPart", part => part + .WithPosition("4") + ) + .WithPart("TextAreaPart", part => part + .WithPosition("5") + ) + .WithPart("FormElementValidationPart", part => part + .WithPosition("6") + )); + + await m_contentDefinitionManager + .AlterTypeDefinitionAsync("Select", type => type + .WithPart("Explanation", "HtmlBodyPart", part => part + .WithPosition("4") + ) + .WithPart("SelectPart", part => part + .WithPosition("5") + ) + .WithPart("FormElementValidationPart", part => part + .WithPosition("6") + )); + + return 9; + } + + public async Task UpdateFrom9Async() + { + await m_contentDefinitionManager + .AlterTypeDefinitionAsync("Input", type => type + .WithPart("Explanation", "HtmlBodyPart", part => part + .WithDisplayName("Explanation") + .WithDescription("Details to help the user correctly fill out this form field.") + )); + + await m_contentDefinitionManager + .AlterTypeDefinitionAsync("TextArea", type => type + .WithPart("Explanation", "HtmlBodyPart", part => part + .WithDisplayName("Explanation") + .WithDescription("Details to help the user correctly fill out this form field.") + )); + + await m_contentDefinitionManager + .AlterTypeDefinitionAsync("Select", type => type + .WithPart("Explanation", "HtmlBodyPart", part => part + .WithDisplayName("Explanation") + .WithDescription("Details to help the user correctly fill out this form field.") + )); + + return 10; + } + + public async Task UpdateFrom10Async() + { + await m_contentDefinitionManager.AlterTypeDefinitionAsync("OapApplicationFormButtons", type => type + .Stereotype("Widget") + .WithPart("OapApplicationFormButtons") + .WithPart("Back", "ButtonPart", part => part + .WithDisplayName("Back Button")) + .WithPart("Submit", "ButtonPart", part => part + .WithDisplayName("Submit Button"))); + + return 11; + } + + public async Task UpdateFrom11Async() + { + await m_contentDefinitionManager.AlterPartDefinitionAsync("OapApplicationFormButtons", part => part + .WithField("ShowBackButton", field => field.WithDisplayName("Show Back Button"))); + + return 12; + } + + public async Task UpdateFrom12Async() + { + await m_contentDefinitionManager.AlterTypeDefinitionAsync("OapApplicationFormButtons", type => type + .WithPart("OapApplicationFormButtons")); + + return 13; + } + + private readonly IContentDefinitionManager m_contentDefinitionManager; +} diff --git a/src/OAP/Oap.Theme.Svelte/src/components/ButtonPart.svelte b/src/OAP/Oap.Theme.Svelte/src/components/ButtonPart.svelte deleted file mode 100644 index 470b3b6..0000000 --- a/src/OAP/Oap.Theme.Svelte/src/components/ButtonPart.svelte +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - diff --git a/src/OAP/Oap.Theme.Svelte/src/components/Fields/Button.svelte b/src/OAP/Oap.Theme.Svelte/src/components/Fields/Button.svelte new file mode 100644 index 0000000..5a699fb --- /dev/null +++ b/src/OAP/Oap.Theme.Svelte/src/components/Fields/Button.svelte @@ -0,0 +1,23 @@ + + + + + diff --git a/src/OAP/Oap.Theme.Svelte/src/components/CommonFieldParts.svelte b/src/OAP/Oap.Theme.Svelte/src/components/Fields/CommonFieldParts.svelte similarity index 71% rename from src/OAP/Oap.Theme.Svelte/src/components/CommonFieldParts.svelte rename to src/OAP/Oap.Theme.Svelte/src/components/Fields/CommonFieldParts.svelte index 85802ec..96927d2 100644 --- a/src/OAP/Oap.Theme.Svelte/src/components/CommonFieldParts.svelte +++ b/src/OAP/Oap.Theme.Svelte/src/components/Fields/CommonFieldParts.svelte @@ -3,8 +3,9 @@ FormElementLabelPart, FormElementPart, RichTextFragment, - } from "../gql/graphql"; - import ExplanationPart from "./ExplanationPart.svelte"; + } from "../../gql/graphql"; + import ExplanationPart from "./Explanation.svelte"; + import Label from "./Label.svelte"; export let formElementLabel: FormElementLabelPart | undefined | null; export let formElement: FormElementPart | undefined | null; @@ -23,9 +24,7 @@ {#if formElementLabel?.label} - +