From 3d68bf514182a6888068938104a8786dd76971d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E5=86=A0=E9=AD=81?= Date: Sat, 17 Feb 2024 21:56:19 +0900 Subject: [PATCH] Code Review --- common.props | 2 +- .../Abp/Data/HasCustomFieldsExtensions.cs | 12 ++- .../Dignite/Cms/Entries/EntryConsts.cs | 4 + .../Sections/ISectionPublicAppService.cs | 6 +- .../Sections/SectionPublicAppService.cs | 59 +++++++---- .../SectionPublicClientProxy.Generated.cs | 6 +- .../Sections/SectionPublicController.cs | 12 +-- .../CmsApplicationBuilderExtensions.cs | 10 +- .../Controllers/CmsController.cs | 97 +++++++++---------- .../Routing/RouteConsts.cs | 20 ++++ .../TagHelpers/LinkToEntryTagHelper.cs | 2 +- ...er.cs => LinkToEntryWithPathlTagHelper.cs} | 16 +-- .../Cms/Fields/Matrix/content-section.cshtml | 21 ---- .../Shared/Cms/Fields/Matrix/gallery.cshtml | 80 --------------- .../Cms/Fields/Matrix/introduction.cshtml | 86 ---------------- 15 files changed, 148 insertions(+), 285 deletions(-) create mode 100644 src/Dignite.Cms.Public.Web/Routing/RouteConsts.cs rename src/Dignite.Cms.Public.Web/TagHelpers/{LinkToEntryByUrlTagHelper.cs => LinkToEntryWithPathlTagHelper.cs} (74%) delete mode 100644 src/Dignite.Cms.Public.Web/Views/Shared/Cms/Fields/Matrix/content-section.cshtml delete mode 100644 src/Dignite.Cms.Public.Web/Views/Shared/Cms/Fields/Matrix/gallery.cshtml delete mode 100644 src/Dignite.Cms.Public.Web/Views/Shared/Cms/Fields/Matrix/introduction.cshtml diff --git a/common.props b/common.props index e3f66f3..7ef04fb 100644 --- a/common.props +++ b/common.props @@ -1,7 +1,7 @@ latest - 1.0.2 + 1.0.4-beta2 $(NoWarn);CS1591;CS0436 https://dignite.com/assets/dignite_nupkg.png https://dignite.com/dignite-cms diff --git a/src/Dignite.Cms.Domain.Shared/Dignite/Abp/Data/HasCustomFieldsExtensions.cs b/src/Dignite.Cms.Domain.Shared/Dignite/Abp/Data/HasCustomFieldsExtensions.cs index 955656a..a0f9e03 100644 --- a/src/Dignite.Cms.Domain.Shared/Dignite/Abp/Data/HasCustomFieldsExtensions.cs +++ b/src/Dignite.Cms.Domain.Shared/Dignite/Abp/Data/HasCustomFieldsExtensions.cs @@ -1,7 +1,9 @@ -using System.Text.Json; +using System; +using System.Text.Json; using JetBrains.Annotations; using Volo.Abp; using Volo.Abp.Data; +using Volo.Abp.Reflection; namespace Dignite.Abp.Data; @@ -29,14 +31,18 @@ public static TField GetField([NotNull] this IHasCustomFields source, [N { return source.GetProperty(name, defaultValue); } - catch (AbpException) + catch (Exception exc) { var value = source.GetProperty(name); if (value == null) { return defaultValue; } - return JsonSerializer.Deserialize(value.ToString(), new JsonSerializerOptions(JsonSerializerDefaults.Web)); + + if (TypeHelper.IsPrimitiveExtended(typeof(TField))) + return ((JsonElement)value).Deserialize(JsonSerializerOptions.Default); + else + return JsonSerializer.Deserialize(value.ToString(), new JsonSerializerOptions(JsonSerializerDefaults.Web)); } } diff --git a/src/Dignite.Cms.Domain.Shared/Dignite/Cms/Entries/EntryConsts.cs b/src/Dignite.Cms.Domain.Shared/Dignite/Cms/Entries/EntryConsts.cs index 67c46ce..62ae429 100644 --- a/src/Dignite.Cms.Domain.Shared/Dignite/Cms/Entries/EntryConsts.cs +++ b/src/Dignite.Cms.Domain.Shared/Dignite/Cms/Entries/EntryConsts.cs @@ -27,5 +27,9 @@ public static class EntryConsts /// public static int MaxRevisionNotesLength { get; set; } = 512; + /// + /// Default value: index + /// + public static string DefaultSlug { get; set; } = "index"; } } diff --git a/src/Dignite.Cms.Public.Application.Contracts/Dignite/Cms/Public/Sections/ISectionPublicAppService.cs b/src/Dignite.Cms.Public.Application.Contracts/Dignite/Cms/Public/Sections/ISectionPublicAppService.cs index d953717..37d5519 100644 --- a/src/Dignite.Cms.Public.Application.Contracts/Dignite/Cms/Public/Sections/ISectionPublicAppService.cs +++ b/src/Dignite.Cms.Public.Application.Contracts/Dignite/Cms/Public/Sections/ISectionPublicAppService.cs @@ -13,11 +13,11 @@ public interface ISectionPublicAppService : IApplicationService /// /// /// - /// - /// + /// + /// The entry path does not contain culture. /// /// - Task FindByUrlAsync(Guid siteId, string url); + Task FindByEntryPathAsync(Guid siteId, string entryPath); Task GetDefaultAsync(Guid siteId); } diff --git a/src/Dignite.Cms.Public.Application/Dignite/Cms/Public/Sections/SectionPublicAppService.cs b/src/Dignite.Cms.Public.Application/Dignite/Cms/Public/Sections/SectionPublicAppService.cs index 1686b89..4946488 100644 --- a/src/Dignite.Cms.Public.Application/Dignite/Cms/Public/Sections/SectionPublicAppService.cs +++ b/src/Dignite.Cms.Public.Application/Dignite/Cms/Public/Sections/SectionPublicAppService.cs @@ -1,4 +1,5 @@ -using Dignite.Cms.Fields; +using Dignite.Cms.Entries; +using Dignite.Cms.Fields; using Dignite.Cms.Sections; using System; using System.Collections.Generic; @@ -35,32 +36,34 @@ public async Task FindByNameAsync(Guid siteId, string name) await _sectionRepository.FindByNameAsync(siteId, name) ); - await FillSectionFields( dto ); + await FillSectionFields(dto); return dto; } - - public async Task FindByUrlAsync(Guid siteId, string url) + /// + /// + /// + /// + /// + /// The entry path does not contain culture. + /// + /// + public async Task FindByEntryPathAsync(Guid siteId, string entryPath) { - url = url.RemovePreFix("/").RemovePostFix("/"); var allSections = await _sectionRepository.GetListAsync(siteId, null, true, true); - allSections.ForEach((s) => s.Route.RemovePreFix("/").RemovePostFix("/")); + var section = await MatchingSectionWithEntryPath(allSections, entryPath); - foreach ( var section in allSections.OrderByDescending(s => s.Route)) + /** + * When no matching Section is found, add /index/ to the url to try again. + * The reason is that when the Section type is SectionType.Single, the url may not contain a slug, so the default slug (i.e. index) is used to match again. + * **/ + if (section == null) { - var route = section.Route.RemovePreFix("/").RemovePostFix("/"); - var extractResult = FormattedStringValueExtracter.Extract(url, route, ignoreCase: true); - if (extractResult.IsMatch) - { - var dto = ObjectMapper.Map( - section - ); - await FillSectionFields(dto); - return dto; - } + entryPath = entryPath.EnsureEndsWith('/') + EntryConsts.DefaultSlug; + section= await MatchingSectionWithEntryPath(allSections,entryPath); } - return null; + return section; } public async Task GetDefaultAsync(Guid siteId) @@ -81,6 +84,26 @@ public async Task GetDefaultAsync(Guid siteId) } } + protected async Task MatchingSectionWithEntryPath(List
sections, string entryPath) + { + entryPath = entryPath.RemovePreFix("/").RemovePostFix("/"); + foreach (var section in sections.OrderByDescending(s => s.Route)) + { + var route = section.Route.RemovePreFix("/").RemovePostFix("/"); + var extractResult = FormattedStringValueExtracter.Extract(entryPath, route, ignoreCase: true); + if (extractResult.IsMatch) + { + var dto = ObjectMapper.Map( + section + ); + await FillSectionFields(dto); + return dto; + } + } + + return null; + } + protected async Task FillSectionFields(SectionDto dto) { var allFields = await _fieldRepository.GetListAsync(false); diff --git a/src/Dignite.Cms.Public.HttpApi.Client/ClientProxies/Dignite/Cms/Public/Sections/SectionPublicClientProxy.Generated.cs b/src/Dignite.Cms.Public.HttpApi.Client/ClientProxies/Dignite/Cms/Public/Sections/SectionPublicClientProxy.Generated.cs index 700b91e..3005451 100644 --- a/src/Dignite.Cms.Public.HttpApi.Client/ClientProxies/Dignite/Cms/Public/Sections/SectionPublicClientProxy.Generated.cs +++ b/src/Dignite.Cms.Public.HttpApi.Client/ClientProxies/Dignite/Cms/Public/Sections/SectionPublicClientProxy.Generated.cs @@ -26,12 +26,12 @@ public virtual async Task FindByNameAsync(Guid siteId, string name) }); } - public virtual async Task FindByUrlAsync(Guid siteId, string url) + public virtual async Task FindByEntryPathAsync(Guid siteId, string entryPath) { - return await RequestAsync(nameof(FindByUrlAsync), new ClientProxyRequestTypeValue + return await RequestAsync(nameof(FindByEntryPathAsync), new ClientProxyRequestTypeValue { { typeof(Guid), siteId }, - { typeof(string), url } + { typeof(string), entryPath } }); } diff --git a/src/Dignite.Cms.Public.HttpApi/Dignite/Cms/Public/Sections/SectionPublicController.cs b/src/Dignite.Cms.Public.HttpApi/Dignite/Cms/Public/Sections/SectionPublicController.cs index 7d3fca1..9e3f024 100644 --- a/src/Dignite.Cms.Public.HttpApi/Dignite/Cms/Public/Sections/SectionPublicController.cs +++ b/src/Dignite.Cms.Public.HttpApi/Dignite/Cms/Public/Sections/SectionPublicController.cs @@ -30,15 +30,15 @@ public async Task FindByNameAsync(Guid siteId, string name) /// /// /// - /// - /// + /// + /// The entry path does not contain culture. /// /// [HttpGet] - [Route("find-by-url")] - public async Task FindByUrlAsync(Guid siteId, string url) + [Route("find-by-entry-path")] + public async Task FindByEntryPathAsync(Guid siteId, string entryPath) { - return await _sectionAppService.FindByUrlAsync(siteId, url); + return await _sectionAppService.FindByEntryPathAsync(siteId, entryPath); } [HttpGet] @@ -49,7 +49,7 @@ public async Task GetAsync(Guid sectionId) } [HttpGet] - [Route("get-default")] + [Route("get-default-by-siteId/{siteId:guid}")] public async Task GetDefaultAsync(Guid siteId) { return await _sectionAppService.GetDefaultAsync(siteId); diff --git a/src/Dignite.Cms.Public.Web/Builder/CmsApplicationBuilderExtensions.cs b/src/Dignite.Cms.Public.Web/Builder/CmsApplicationBuilderExtensions.cs index daa8e3c..8446860 100644 --- a/src/Dignite.Cms.Public.Web/Builder/CmsApplicationBuilderExtensions.cs +++ b/src/Dignite.Cms.Public.Web/Builder/CmsApplicationBuilderExtensions.cs @@ -16,16 +16,16 @@ public static IApplicationBuilder UseCmsRoute(this IApplicationBuilder app) app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( - name: "cms-home", + name: RouteConsts.HomeRouteName, pattern: "/", defaults: new { controller = CmsController.ControllerName, action = "Index" }); endpoints.MapControllerRoute( - name: "cms-entry-by-culture", - pattern: "{"+ CultureRouteSegmentConstraint.RouteSegmentName + ":"+ CultureRouteSegmentConstraint.RouteConstraintName + "}/{*url}", + name: RouteConsts.EntryWithCultureRouteName, + pattern: "{"+ CultureRouteSegmentConstraint.RouteSegmentName + ":"+ CultureRouteSegmentConstraint.RouteConstraintName + "}/{*path}", defaults: new { controller = CmsController.ControllerName, action = "EntryByCulture" }); endpoints.MapControllerRoute( - name: "cms-entry", - pattern: "{*url:regex(^(?!swagger/).*)}", //TODO: Use an options to configure the regular expression for the url + name: RouteConsts.EntryRouteName, + pattern: "{*path:regex(^(?!swagger/).*)}", //TODO: Use an options to configure the regular expression for the path defaults: new { controller = CmsController.ControllerName, action = "Entry" }); }); diff --git a/src/Dignite.Cms.Public.Web/Controllers/CmsController.cs b/src/Dignite.Cms.Public.Web/Controllers/CmsController.cs index c1dad06..2fe28c0 100644 --- a/src/Dignite.Cms.Public.Web/Controllers/CmsController.cs +++ b/src/Dignite.Cms.Public.Web/Controllers/CmsController.cs @@ -1,4 +1,5 @@ -using Dignite.Cms.Localization; +using Dignite.Cms.Entries; +using Dignite.Cms.Localization; using Dignite.Cms.Public.Entries; using Dignite.Cms.Public.Sections; using Dignite.Cms.Public.Sites; @@ -41,7 +42,7 @@ public CmsController(ISitePublicAppService sitePublicAppService, ISectionPublicA public async Task Index() { - return await EntryViewResult("/", null); + return await EntryViewResult(); } @@ -49,37 +50,37 @@ public async Task Index() /// /// /// - /// + /// /// There are several formats: /// 1.{culture} - /// 2.{culture}/{url} + /// 2.{culture}/{path} /// /// - public async Task EntryByCulture(string culture, string url="/") + public async Task EntryWithCulture(string culture, string path = "/") { - return await EntryViewResult(url, culture); + return await EntryViewResult(culture, path); } /// /// /// - /// + /// /// - public async Task Entry(string url="/") + public async Task Entry(string path = "/") { - return await EntryViewResult(url, null); + return await EntryViewResult(null, path); } /// /// /// - /// /// + /// /// - protected async Task EntryViewResult(string url, string culture = null) + protected async Task EntryViewResult(string culture = null, string path = "/") { - var section = await GetSection(url); + var section = await GetSection(path); if (section == null) { return NotFound(); @@ -93,8 +94,8 @@ protected async Task EntryViewResult(string url, string culture = } else { - /* Remove the default culture prefix and redirect to the new Url. - * Example: the default culture is en, the current request path is /en/about, will jump to /about Url + /* Remove the default culture prefix and redirect to the new path. + * Example: the default culture is en, the current request path is /en/about, will jump to /about path */ if (culture.Equals(defaultCulture, StringComparison.OrdinalIgnoreCase) && Request.Path.Value.EnsureEndsWith('/').StartsWith($"/{culture}/")) @@ -119,7 +120,7 @@ protected async Task EntryViewResult(string url, string culture = ); // - var entry = await GetEntry(section, url, culture); + var entry = await GetEntry(culture, section, path); if (entry != null) { var viewModel = new EntryViewModel(entry, section); @@ -129,7 +130,7 @@ protected async Task EntryViewResult(string url, string culture = { if (!culture.Equals(defaultCulture, StringComparison.OrdinalIgnoreCase)) { - return Redirect(url.EnsureStartsWith('/')); + return Redirect(path.EnsureStartsWith('/')); } else { @@ -138,7 +139,7 @@ protected async Task EntryViewResult(string url, string culture = } } - protected async Task GetSection(string url = null) + protected async Task GetSection(string path) { var host = $"{Request.Scheme}://{Request.Host.Value}"; var site = await _sitePublicAppService.FindByHostAsync(host); @@ -146,52 +147,35 @@ protected async Task GetSection(string url = null) if (site == null) return null; - if (url.IsNullOrEmpty() || url == "/") + if (path.IsNullOrEmpty() || path == "/") { return await _sectionPublicAppService.GetDefaultAsync(site.Id); } else { - return await _sectionPublicAppService.FindByUrlAsync(site.Id,url); + return await _sectionPublicAppService.FindByEntryPathAsync(site.Id, path); } } - protected async Task GetEntry(SectionDto section, string url, string culture) + protected async Task GetEntry(string culture, SectionDto section, string path) { - EntryDto entry = null; - // If the section type is single, then the slug value of the entry is the name of the section - if (section.Type == Cms.Sections.SectionType.Single) + var slug = ExtractSlug(section.Route, path); + if (slug.IsNullOrEmpty()) { - var result = await _entryPublicAppService.GetListAsync(new GetEntriesInput { - SectionId = section.Id, - SkipCount=0, - MaxResultCount=1, - Culture = culture - }); - entry = result.Items.Any() ? result.Items[0] : null; - } - else - { - string slug = null; - //Extract Slug value from URL - var extractResult = FormattedStringValueExtracter.Extract(url.RemovePreFix("/").RemovePostFix("/"), section.Route.RemovePreFix("/").RemovePostFix("/"), ignoreCase: true); - if (extractResult.IsMatch) - { - slug = extractResult.Matches.First(m => m.Name.Equals(nameof(EntryDto.Slug), StringComparison.OrdinalIgnoreCase)).Value; - // - entry = await _entryPublicAppService.FindBySlugAsync(new FindBySlugInput - { - Culture = culture, - SectionId = section.Id, - Slug = slug - }); - } + if (section.Type == Cms.Sections.SectionType.Single) + slug = EntryConsts.DefaultSlug; else - { throw new Volo.Abp.AbpException($"The structure type section and channel type section route of the entry must contain {{slug}}"); - } } + EntryDto entry = await _entryPublicAppService.FindBySlugAsync( + new FindBySlugInput + { + Culture = culture, + SectionId = section.Id, + Slug = slug + }); + if (entry != null) { @@ -202,7 +186,7 @@ protected async Task GetEntry(SectionDto section, string url, string c } - protected void SetEntryUrl(EntryDto entry) + protected virtual void SetEntryUrl(EntryDto entry) { var host = HttpContext.Request.Scheme + "://" + HttpContext.Request.Host; if (entry.Url.StartsWith(host, StringComparison.OrdinalIgnoreCase)) @@ -210,5 +194,18 @@ protected void SetEntryUrl(EntryDto entry) entry.Url = entry.Url.RemovePreFix(StringComparison.OrdinalIgnoreCase, host); } } + + protected virtual string ExtractSlug(string route, string path) + { + string slug = null; + //Extract Slug value from path + var extractResult = FormattedStringValueExtracter.Extract(path.RemovePreFix("/").RemovePostFix("/"), route.RemovePreFix("/").RemovePostFix("/"), ignoreCase: true); + if (extractResult.IsMatch) + { + slug = extractResult.Matches.FirstOrDefault(m => m.Name.Equals(nameof(EntryDto.Slug), StringComparison.InvariantCultureIgnoreCase))?.Value; + } + + return slug; + } } } diff --git a/src/Dignite.Cms.Public.Web/Routing/RouteConsts.cs b/src/Dignite.Cms.Public.Web/Routing/RouteConsts.cs new file mode 100644 index 0000000..15fdd80 --- /dev/null +++ b/src/Dignite.Cms.Public.Web/Routing/RouteConsts.cs @@ -0,0 +1,20 @@ +namespace Dignite.Cms.Public.Web.Routing +{ + public static class RouteConsts + { + /// + /// Default value: cms-home + /// + public const string HomeRouteName = "cms-home"; + + /// + /// Default value: cms-entry-with-culture + /// + public const string EntryWithCultureRouteName = "cms-entry-with-culture"; + + /// + /// Default value: cms-entry + /// + public const string EntryRouteName = "cms-entry"; + } +} diff --git a/src/Dignite.Cms.Public.Web/TagHelpers/LinkToEntryTagHelper.cs b/src/Dignite.Cms.Public.Web/TagHelpers/LinkToEntryTagHelper.cs index ef14309..ba98c2c 100644 --- a/src/Dignite.Cms.Public.Web/TagHelpers/LinkToEntryTagHelper.cs +++ b/src/Dignite.Cms.Public.Web/TagHelpers/LinkToEntryTagHelper.cs @@ -79,7 +79,7 @@ private string GetEntryUrl(EntryDto entry, SectionDto section) } else { - url = urlHelper.ActionLink(nameof(CmsController.EntryByCulture), CmsController.ControllerName, new { culture = entry.Culture, url }); + url = urlHelper.ActionLink(nameof(CmsController.EntryWithCulture), CmsController.ControllerName, new { culture = entry.Culture, url }); } //Since the URL is encoded in the ActionLink method, it is decoded here diff --git a/src/Dignite.Cms.Public.Web/TagHelpers/LinkToEntryByUrlTagHelper.cs b/src/Dignite.Cms.Public.Web/TagHelpers/LinkToEntryWithPathlTagHelper.cs similarity index 74% rename from src/Dignite.Cms.Public.Web/TagHelpers/LinkToEntryByUrlTagHelper.cs rename to src/Dignite.Cms.Public.Web/TagHelpers/LinkToEntryWithPathlTagHelper.cs index f88fe0f..be8dee7 100644 --- a/src/Dignite.Cms.Public.Web/TagHelpers/LinkToEntryByUrlTagHelper.cs +++ b/src/Dignite.Cms.Public.Web/TagHelpers/LinkToEntryWithPathlTagHelper.cs @@ -10,13 +10,13 @@ namespace Dignite.Cms.Public.Web.TagHelpers /// /// Link to entry /// - [HtmlTargetElement("a", Attributes = "[entry-url]")] - public class LinkToEntryByUrlTagHelper : TagHelper + [HtmlTargetElement("a", Attributes = "[entry-path]")] + public class LinkToEntryWithPathlTagHelper : TagHelper { /// - /// Specify the url of the link to the entry + /// Specify the path of the link to the entry /// - public string EntryUrl { get; set; } + public string EntryPath { get; set; } /// /// Specify Culture; @@ -37,22 +37,22 @@ public override void Process(TagHelperContext context, TagHelperOutput output) { var urlHelper = ViewContext.GetUrlHelper(); - if (urlHelper.IsLocalUrl(EntryUrl)) + if (urlHelper.IsLocalUrl(EntryPath)) { if (Culture.IsNullOrEmpty()) { Culture = ViewContext.HttpContext.GetRouteValue(CultureRouteSegmentConstraint.RouteSegmentName)?.ToString(); } - EntryUrl = ("~/" + Culture).EnsureEndsWith('/') + EntryUrl.RemovePreFix("~").RemovePreFix("/"); + EntryPath = ("~/" + Culture).EnsureEndsWith('/') + EntryPath.RemovePreFix("~").RemovePreFix("/"); if (!Host.IsNullOrEmpty()) { - EntryUrl = Host + urlHelper.Content(EntryUrl); + EntryPath = Host + urlHelper.Content(EntryPath); } } - output.Attributes.SetAttribute("href", urlHelper.Content(EntryUrl)); + output.Attributes.SetAttribute("href", urlHelper.Content(EntryPath)); } } } diff --git a/src/Dignite.Cms.Public.Web/Views/Shared/Cms/Fields/Matrix/content-section.cshtml b/src/Dignite.Cms.Public.Web/Views/Shared/Cms/Fields/Matrix/content-section.cshtml deleted file mode 100644 index 5db82b3..0000000 --- a/src/Dignite.Cms.Public.Web/Views/Shared/Cms/Fields/Matrix/content-section.cshtml +++ /dev/null @@ -1,21 +0,0 @@ -@using Dignite.Abp.DynamicForms.Select; -@using Dignite.Cms.Public.Web.Models; -@using Dignite.Abp.DynamicForms; -@using Dignite.Abp.Data; -@using Dignite.FileExplorer.Files; -@using Dignite.Cms.Public.Web.TagHelpers -@model MatrixBlockViewModel -@{ - var contentField = Model.Type.Fields.First(fd => fd.Name == "rich-text"); - var subject = Model.Block.GetField("subject",null); - contentField.Value = Model.Block.GetField("rich-text", null); -} -@if (!subject.IsNullOrEmpty()) -{ -

- @subject -

-} -
- -
\ No newline at end of file diff --git a/src/Dignite.Cms.Public.Web/Views/Shared/Cms/Fields/Matrix/gallery.cshtml b/src/Dignite.Cms.Public.Web/Views/Shared/Cms/Fields/Matrix/gallery.cshtml deleted file mode 100644 index 103a1ca..0000000 --- a/src/Dignite.Cms.Public.Web/Views/Shared/Cms/Fields/Matrix/gallery.cshtml +++ /dev/null @@ -1,80 +0,0 @@ -@using Dignite.Abp.DynamicForms.Select; -@using Dignite.Cms.Public.Web.Models; -@using Dignite.Abp.DynamicForms; -@using Dignite.Abp.Data; -@using Dignite.FileExplorer.Files; -@model MatrixBlockViewModel -@{ - var layoutField = Model.Type.Fields.First(fd => fd.Name == "layout"); - var layoutConfiguration = new SelectConfiguration(layoutField.FormConfiguration); - var layouts = Model.Block.GetField>("layout"); - var photos = Model.Block.GetField>("photos"); -} - -@if (layouts != null && layouts.Any() && photos!=null) -{ - var layout = layouts.First(); - switch (layout) - { - case "tile": - foreach (var photo in photos) - { -
- @photo.Name -
- } - break; - case "two-columns-per-row": -
- @foreach(var photo in photos) - { -
- @photo.Name -
- } -
- break; - case "three-columns-per-row": -
- @foreach (var photo in photos) - { -
- @photo.Name -
- } -
- break; - case "four-columns-per-row": -
- @foreach (var photo in photos) - { -
- @photo.Name -
- } -
- break; - case "scroll": - var carouseId = Guid.NewGuid().ToString(); - - break; - } -} \ No newline at end of file diff --git a/src/Dignite.Cms.Public.Web/Views/Shared/Cms/Fields/Matrix/introduction.cshtml b/src/Dignite.Cms.Public.Web/Views/Shared/Cms/Fields/Matrix/introduction.cshtml deleted file mode 100644 index f184b6c..0000000 --- a/src/Dignite.Cms.Public.Web/Views/Shared/Cms/Fields/Matrix/introduction.cshtml +++ /dev/null @@ -1,86 +0,0 @@ -@using Dignite.Abp.DynamicForms.Select; -@using Dignite.Cms.Public.Web.Models; -@using Dignite.Abp.DynamicForms; -@using Dignite.Abp.Data; -@using Dignite.FileExplorer.Files; -@using Dignite.Cms.Public.Web.TagHelpers -@model MatrixBlockViewModel -@{ - var titleField = Model.Type.Fields.First(fd => fd.Name == "title"); - var descriptionField = Model.Type.Fields.First(fd => fd.Name == "description"); - var layouts = Model.Block.GetField>("layout"); - var files = Model.Block.GetField>("illustration"); - var linkText = Model.Block.GetField("link-text", null); - var linkUrl = Model.Block.GetField("link-url", null); - titleField.Value = @Model.Block.GetField("title"); - descriptionField.Value = @Model.Block.GetField("description"); - FileDescriptorDto illustration = (files != null && files.Any()) ? files[0] : null; -} - -@if (layouts != null && layouts.Any()) -{ - var layout = layouts.First(); - switch (layout) - { - case "top-and-bottom": -
-
-

- -

-
-
-
- - @if (!linkUrl.IsNullOrWhiteSpace()) - { - @linkText - } -
-
-
- @if (illustration != null) - { - @Model.Block.GetField( - } - break; - case "left-and-right": -
-
-

- -

-
- - @if (!linkUrl.IsNullOrWhiteSpace()) - { - @linkText - } -
-
-
- @Model.Block.GetField( -
-
- break; - case "right-and-left": -
-
- @Model.Block.GetField( -
-
-

- -

-
- - @if (!linkUrl.IsNullOrWhiteSpace()) - { - @linkText - } -
-
-
- break; - } -} \ No newline at end of file