public RegionSceneObjectModel(RegionItemModel itemModel) : base(itemModel) { Parameter.Add(new PositionModel()); Parameter.Add(new TextureModel()); Parameter.Add(new RotationModel()); Parameter.Add(new ScaleModel()); Parameter.Add(new ObjectColorModel()); }
/// <summary> /// Creates a new region for the given content type. /// </summary> /// <param name="type">The content type</param> /// <param name="region">The region id</param> /// <returns>The new region item</returns> private async Task <RegionItemModel> CreateRegionAsync(ContentTypeBase type, string region) { var regionType = type.Regions.First(r => r.Id == region); var regionModel = await _factory.CreateDynamicRegionAsync(type, region, true); var regionItem = new RegionItemModel { Title = regionType.ListTitlePlaceholder ?? "...", IsNew = true }; foreach (var fieldType in regionType.Fields) { var appFieldType = App.Fields.GetByType(fieldType.Type); var field = new FieldModel { Meta = new FieldMeta { Id = fieldType.Id, Name = fieldType.Title, Component = appFieldType.Component, Placeholder = fieldType.Placeholder, IsHalfWidth = fieldType.Options.HasFlag(FieldOption.HalfWidth), Description = fieldType.Description } }; PopulateFieldOptions(appFieldType, field); if (regionType.Fields.Count > 1) { field.Model = (IField)((IDictionary <string, object>)regionModel)[fieldType.Id]; field.Meta.NotifyChange = regionType.ListTitleField == fieldType.Id; } else { field.Model = (IField)regionModel; field.Meta.NotifyChange = true; } regionItem.Fields.Add(field); } return(regionItem); }
public RegionItemModel CreatePageRegion(string type, string region) { var pageType = App.PageTypes.GetById(type); if (pageType != null) { var regionType = pageType.Regions.First(r => r.Id == region); var regionModel = _factory.CreateDynamicRegion(pageType, region); var regionItem = new RegionItemModel(); foreach (var fieldType in regionType.Fields) { var appFieldType = App.Fields.GetByType(fieldType.Type); var field = new FieldModel { Meta = new FieldMeta { Id = fieldType.Id, Name = fieldType.Title, Component = appFieldType.Component, Placeholder = fieldType.Placeholder, IsHalfWidth = fieldType.Options.HasFlag(FieldOption.HalfWidth), Description = fieldType.Description } }; if (regionType.Fields.Count > 1) { field.Model = (Extend.IField)((IDictionary <string, object>)regionModel)[fieldType.Id]; field.Meta.NotifyChange = regionType.ListTitleField == fieldType.Id; } else { field.Model = (Extend.IField)regionModel; field.Meta.NotifyChange = true; } regionItem.Fields.Add(field); } return(regionItem); } return(null); }
private void ImportRegions() { //Add hardcoded region items GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane); RegionItemModel planeModel = new RegionItemModel(); planeModel.DisplayName = "Plane"; planeModel.Mesh = plane.GetComponent <MeshFilter>().mesh; planeModel.Materials = plane.GetComponent <MeshRenderer>().materials; GlobalSettingsModel.EditorModel.AllRegionItemsModel.Add(planeModel); //Add imported region items string importPath = Application.dataPath + "/Import/" + "Regions"; foreach (string file in Directory.GetFiles(importPath)) { if (file.EndsWith(".obj")) { OBJLoader objLoader = new OBJLoader(); GameObject tmpObject = objLoader.Load(file).gameObject; try { RegionItemModel model = new RegionItemModel(); model.DisplayName = tmpObject.name; model.Mesh = tmpObject.GetComponentInChildren <MeshFilter>().mesh; model.Materials = tmpObject.GetComponentInChildren <MeshRenderer>().materials; GlobalSettingsModel.EditorModel.AllRegionItemsModel.Add(model); } catch (Exception e) { Debug.Log("An error has occured during import of " + tmpObject.name + "\n" + e.Message + "\n" + e.StackTrace); } finally { Destroy(tmpObject); } } } }
private PostEditModel Transform(DynamicPost post, bool isDraft) { var config = new Config(_api); var type = App.PostTypes.GetById(post.TypeId); var route = type.Routes.FirstOrDefault(r => r.Route == post.Route) ?? type.Routes.FirstOrDefault(); var model = new PostEditModel { Id = post.Id, BlogId = post.BlogId, TypeId = post.TypeId, PrimaryImage = post.PrimaryImage, Title = post.Title, Slug = post.Slug, MetaTitle = post.MetaTitle, MetaKeywords = post.MetaKeywords, MetaDescription = post.MetaDescription, OgTitle = post.OgTitle, OgDescription = post.OgDescription, OgImage = post.OgImage, Excerpt = post.Excerpt, Published = post.Published?.ToString("yyyy-MM-dd HH:mm"), RedirectUrl = post.RedirectUrl, RedirectType = post.RedirectType.ToString(), EnableComments = post.EnableComments, CloseCommentsAfterDays = post.CloseCommentsAfterDays, CommentCount = post.CommentCount, State = post.GetState(isDraft), UseBlocks = type.UseBlocks, UsePrimaryImage = type.UsePrimaryImage, UseExcerpt = type.UseExcerpt, UseHtmlExcerpt = config.HtmlExcerpt, SelectedRoute = route == null ? null : new RouteModel { Title = route.Title, Route = route.Route }, Permissions = App.Permissions .GetPublicPermissions() .Select(p => new KeyValuePair <string, string>(p.Name, p.Title)) .ToList(), SelectedPermissions = post.Permissions }; foreach (var r in type.Routes) { model.Routes.Add(new RouteModel { Title = r.Title, Route = r.Route }); } foreach (var regionType in type.Regions) { var region = new RegionModel { Meta = new RegionMeta { Id = regionType.Id, Name = regionType.Title, Description = regionType.Description, Placeholder = regionType.ListTitlePlaceholder, IsCollection = regionType.Collection, Expanded = regionType.ListExpand, Icon = regionType.Icon, Display = regionType.Display.ToString().ToLower() } }; var regionListModel = ((IDictionary <string, object>)post.Regions)[regionType.Id]; if (!regionType.Collection) { var regionModel = (IRegionList)Activator.CreateInstance(typeof(RegionList <>).MakeGenericType(regionListModel.GetType())); regionModel.Add(regionListModel); regionListModel = regionModel; } foreach (var regionModel in (IEnumerable)regionListModel) { var regionItem = new RegionItemModel(); foreach (var fieldType in regionType.Fields) { var appFieldType = App.Fields.GetByType(fieldType.Type); var field = new FieldModel { Meta = new FieldMeta { Id = fieldType.Id, Name = fieldType.Title, Component = appFieldType.Component, Placeholder = fieldType.Placeholder, IsHalfWidth = fieldType.Options.HasFlag(FieldOption.HalfWidth), Description = fieldType.Description } }; if (typeof(SelectFieldBase).IsAssignableFrom(appFieldType.Type)) { foreach (var item in ((SelectFieldBase)Activator.CreateInstance(appFieldType.Type)).Items) { field.Meta.Options.Add(Convert.ToInt32(item.Value), item.Title); } } if (regionType.Fields.Count > 1) { field.Model = (IField)((IDictionary <string, object>)regionModel)[fieldType.Id]; if (regionType.ListTitleField == fieldType.Id) { regionItem.Title = field.Model.GetTitle(); field.Meta.NotifyChange = true; } } else { field.Model = (IField)regionModel; field.Meta.NotifyChange = true; regionItem.Title = field.Model.GetTitle(); } regionItem.Fields.Add(field); } if (string.IsNullOrWhiteSpace(regionItem.Title)) { regionItem.Title = "..."; } region.Items.Add(regionItem); } model.Regions.Add(region); } foreach (var block in post.Blocks) { var blockType = App.Blocks.GetByType(block.Type); if (block is BlockGroup blockGroup) { var group = new BlockGroupModel { Id = block.Id, Type = block.Type, Meta = new BlockMeta { Name = blockType.Name, Icon = blockType.Icon, Component = "block-group", IsGroup = true, isCollapsed = config.ManagerDefaultCollapsedBlocks, ShowHeader = !config.ManagerDefaultCollapsedBlockGroupHeaders } }; if (blockType.Display != BlockDisplayMode.MasterDetail) { group.Meta.Component = blockType.Display == BlockDisplayMode.Horizontal ? "block-group-horizontal" : "block-group-vertical"; } group.Fields = ContentUtils.GetBlockFields(block); bool firstChild = true; foreach (var child in blockGroup.Items) { blockType = App.Blocks.GetByType(child.Type); if (!blockType.IsGeneric) { group.Items.Add(new BlockItemModel { IsActive = firstChild, Model = child, Meta = new BlockMeta { Name = blockType.Name, Title = child.GetTitle(), Icon = blockType.Icon, Component = blockType.Component } }); } else { // Generic block item model group.Items.Add(new BlockGenericModel { IsActive = firstChild, Model = ContentUtils.GetBlockFields(child), Type = child.Type, Meta = new BlockMeta { Name = blockType.Name, Title = child.GetTitle(), Icon = blockType.Icon, Component = blockType.Component, } }); } firstChild = false; } model.Blocks.Add(group); } else { if (!blockType.IsGeneric) { // Regular block item model model.Blocks.Add(new BlockItemModel { Model = block, Meta = new BlockMeta { Name = blockType.Name, Title = block.GetTitle(), Icon = blockType.Icon, Component = blockType.Component, isCollapsed = config.ManagerDefaultCollapsedBlocks } }); } else { // Generic block item model model.Blocks.Add(new BlockGenericModel { Model = ContentUtils.GetBlockFields(block), Type = block.Type, Meta = new BlockMeta { Name = blockType.Name, Title = block.GetTitle(), Icon = blockType.Icon, Component = blockType.Component, isCollapsed = config.ManagerDefaultCollapsedBlocks } }); } } } // Custom editors foreach (var editor in type.CustomEditors) { model.Editors.Add(new EditorModel { Component = editor.Component, Icon = editor.Icon, Name = editor.Title }); } return(model); }
private PostEditModel Transform(DynamicPost post, bool isDraft) { var type = App.PostTypes.GetById(post.TypeId); var model = new PostEditModel { Id = post.Id, BlogId = post.BlogId, TypeId = post.TypeId, Title = post.Title, Slug = post.Slug, MetaKeywords = post.MetaKeywords, MetaDescription = post.MetaDescription, Published = post.Published.HasValue ? post.Published.Value.ToString("yyyy-MM-dd HH:mm") : null, RedirectUrl = post.RedirectUrl, RedirectType = post.RedirectType.ToString(), State = GetState(post, isDraft), UseBlocks = type.UseBlocks }; foreach (var regionType in type.Regions) { var region = new RegionModel { Meta = new RegionMeta { Id = regionType.Id, Name = regionType.Title, Description = regionType.Description, Placeholder = regionType.ListTitlePlaceholder, IsCollection = regionType.Collection, Icon = regionType.Icon, Display = regionType.Display.ToString().ToLower() } }; var regionListModel = ((IDictionary <string, object>)post.Regions)[regionType.Id]; if (!regionType.Collection) { var regionModel = (IRegionList)Activator.CreateInstance(typeof(RegionList <>).MakeGenericType(regionListModel.GetType())); regionModel.Add(regionListModel); regionListModel = regionModel; } foreach (var regionModel in (IEnumerable)regionListModel) { var regionItem = new RegionItemModel(); foreach (var fieldType in regionType.Fields) { var appFieldType = App.Fields.GetByType(fieldType.Type); var field = new FieldModel { Meta = new FieldMeta { Id = fieldType.Id, Name = fieldType.Title, Component = appFieldType.Component, Placeholder = fieldType.Placeholder, IsHalfWidth = fieldType.Options.HasFlag(FieldOption.HalfWidth), Description = fieldType.Description } }; if (typeof(Extend.Fields.SelectFieldBase).IsAssignableFrom(appFieldType.Type)) { foreach (var item in ((Extend.Fields.SelectFieldBase)Activator.CreateInstance(appFieldType.Type)).Items) { field.Meta.Options.Add(Convert.ToInt32(item.Value), item.Title); } } if (regionType.Fields.Count > 1) { field.Model = (Extend.IField)((IDictionary <string, object>)regionModel)[fieldType.Id]; if (regionType.ListTitleField == fieldType.Id) { regionItem.Title = field.Model.GetTitle(); field.Meta.NotifyChange = true; } } else { field.Model = (Extend.IField)regionModel; field.Meta.NotifyChange = true; regionItem.Title = field.Model.GetTitle(); } regionItem.Fields.Add(field); } if (string.IsNullOrWhiteSpace(regionItem.Title)) { regionItem.Title = "..."; } region.Items.Add(regionItem); } model.Regions.Add(region); } foreach (var block in post.Blocks) { var blockType = App.Blocks.GetByType(block.Type); if (block is Extend.BlockGroup) { var group = new BlockGroupModel { Id = block.Id, Type = block.Type, Meta = new BlockMeta { Name = blockType.Name, Icon = blockType.Icon, Component = "block-group", IsGroup = true } }; if (blockType.Display != BlockDisplayMode.MasterDetail) { group.Meta.Component = blockType.Display == BlockDisplayMode.Horizontal ? "block-group-horizontal" : "block-group-vertical"; } foreach (var prop in block.GetType().GetProperties(App.PropertyBindings)) { if (typeof(Extend.IField).IsAssignableFrom(prop.PropertyType)) { var fieldType = App.Fields.GetByType(prop.PropertyType); group.Fields.Add(new FieldModel { Model = (Extend.IField)prop.GetValue(block), Meta = new FieldMeta { Id = prop.Name, Name = prop.Name, Component = fieldType.Component, } }); } } bool firstChild = true; foreach (var child in ((Extend.BlockGroup)block).Items) { blockType = App.Blocks.GetByType(child.Type); group.Items.Add(new BlockItemModel { IsActive = firstChild, Model = child, Meta = new BlockMeta { Name = blockType.Name, Title = child.GetTitle(), Icon = blockType.Icon, Component = blockType.Component } }); firstChild = false; } model.Blocks.Add(group); } else { model.Blocks.Add(new BlockItemModel { Model = block, Meta = new BlockMeta { Name = blockType.Name, Title = block.GetTitle(), Icon = blockType.Icon, Component = blockType.Component } }); } } // Custom editors foreach (var editor in type.CustomEditors) { model.Editors.Add(new EditorModel { Component = editor.Component, Icon = editor.Icon, Name = editor.Title }); } return(model); }
private SiteContentEditModel Transform(DynamicSiteContent site) { var type = App.SiteTypes.GetById(site.TypeId); var model = new SiteContentEditModel { Id = site.Id, TypeId = site.TypeId, Title = site.Title, UseBlocks = false }; foreach (var regionType in type.Regions) { var region = new RegionModel { Meta = new RegionMeta { Id = regionType.Id, Name = regionType.Title, Description = regionType.Description, Placeholder = regionType.ListTitlePlaceholder, IsCollection = regionType.Collection, Expanded = regionType.ListExpand, Icon = regionType.Icon, Display = regionType.Display.ToString().ToLower() } }; var regionListModel = ((IDictionary <string, object>)site.Regions)[regionType.Id]; if (!regionType.Collection) { var regionModel = (IRegionList)Activator.CreateInstance(typeof(RegionList <>).MakeGenericType(regionListModel.GetType())); regionModel.Add(regionListModel); regionListModel = regionModel; } foreach (var regionModel in (IEnumerable)regionListModel) { var regionItem = new RegionItemModel(); foreach (var fieldType in regionType.Fields) { var appFieldType = App.Fields.GetByType(fieldType.Type); var field = new FieldModel { Meta = new FieldMeta { Id = fieldType.Id, Name = fieldType.Title, Component = appFieldType.Component, Placeholder = fieldType.Placeholder, IsHalfWidth = fieldType.Options.HasFlag(FieldOption.HalfWidth), Description = fieldType.Description } }; if (typeof(SelectFieldBase).IsAssignableFrom(appFieldType.Type)) { foreach (var item in ((SelectFieldBase)Activator.CreateInstance(appFieldType.Type)).Items) { field.Meta.Options.Add(Convert.ToInt32(item.Value), item.Title); } } if (regionType.Fields.Count > 1) { field.Model = (IField)((IDictionary <string, object>)regionModel)[fieldType.Id]; if (regionType.ListTitleField == fieldType.Id) { regionItem.Title = field.Model.GetTitle(); field.Meta.NotifyChange = true; } } else { field.Model = (IField)regionModel; field.Meta.NotifyChange = true; regionItem.Title = field.Model.GetTitle(); } regionItem.Fields.Add(field); } if (string.IsNullOrWhiteSpace(regionItem.Title)) { regionItem.Title = "..."; } region.Items.Add(regionItem); } model.Regions.Add(region); } return(model); }
private PageEditModel Transform(DynamicPage page, bool isDraft) { var config = new Config(_api); var type = App.PageTypes.GetById(page.TypeId); var route = type.Routes.FirstOrDefault(r => r.Route == page.Route) ?? type.Routes.FirstOrDefault(); var model = new PageEditModel { Id = page.Id, SiteId = page.SiteId, ParentId = page.ParentId, OriginalId = page.OriginalPageId, SortOrder = page.SortOrder, TypeId = page.TypeId, Title = page.Title, NavigationTitle = page.NavigationTitle, Slug = page.Slug, MetaKeywords = page.MetaKeywords, MetaDescription = page.MetaDescription, IsHidden = page.IsHidden, Published = page.Published.HasValue ? page.Published.Value.ToString("yyyy-MM-dd HH:mm") : null, RedirectUrl = page.RedirectUrl, RedirectType = page.RedirectType.ToString(), State = GetState(page, isDraft), UseBlocks = type.UseBlocks, SelectedRoute = route == null ? null : new RouteModel { Title = route.Title, Route = route.Route } }; foreach (var r in type.Routes) { model.Routes.Add(new RouteModel { Title = r.Title, Route = r.Route }); } foreach (var regionType in type.Regions) { var region = new RegionModel { Meta = new RegionMeta { Id = regionType.Id, Name = regionType.Title, Description = regionType.Description, Placeholder = regionType.ListTitlePlaceholder, IsCollection = regionType.Collection, Icon = regionType.Icon, Display = regionType.Display.ToString().ToLower() } }; var regionListModel = ((IDictionary <string, object>)page.Regions)[regionType.Id]; if (!regionType.Collection) { var regionModel = (IRegionList)Activator.CreateInstance(typeof(RegionList <>).MakeGenericType(regionListModel.GetType())); regionModel.Add(regionListModel); regionListModel = regionModel; } foreach (var regionModel in (IEnumerable)regionListModel) { var regionItem = new RegionItemModel(); foreach (var fieldType in regionType.Fields) { var appFieldType = App.Fields.GetByType(fieldType.Type); var field = new FieldModel { Meta = new FieldMeta { Id = fieldType.Id, Name = fieldType.Title, Component = appFieldType.Component, Placeholder = fieldType.Placeholder, IsHalfWidth = fieldType.Options.HasFlag(FieldOption.HalfWidth), Description = fieldType.Description } }; if (typeof(Extend.Fields.SelectFieldBase).IsAssignableFrom(appFieldType.Type)) { foreach (var item in ((Extend.Fields.SelectFieldBase)Activator.CreateInstance(appFieldType.Type)).Items) { field.Meta.Options.Add(Convert.ToInt32(item.Value), item.Title); } } if (regionType.Fields.Count > 1) { field.Model = (Extend.IField)((IDictionary <string, object>)regionModel)[fieldType.Id]; if (regionType.ListTitleField == fieldType.Id) { regionItem.Title = field.Model.GetTitle(); field.Meta.NotifyChange = true; } } else { field.Model = (Extend.IField)regionModel; field.Meta.NotifyChange = true; regionItem.Title = field.Model.GetTitle(); } regionItem.Fields.Add(field); } if (string.IsNullOrWhiteSpace(regionItem.Title)) { regionItem.Title = "..."; } region.Items.Add(regionItem); } model.Regions.Add(region); } foreach (var block in page.Blocks) { var blockType = App.Blocks.GetByType(block.Type); if (block is Extend.BlockGroup) { var group = new BlockGroupModel { Id = block.Id, Type = block.Type, Meta = new BlockMeta { Name = blockType.Name, Icon = blockType.Icon, Component = "block-group", IsGroup = true, IsReadonly = page.OriginalPageId.HasValue, isCollapsed = config.ManagerDefaultCollapsedBlocks, ShowHeader = !config.ManagerDefaultCollapsedBlockGroupHeaders } }; if (blockType.Display != BlockDisplayMode.MasterDetail) { group.Meta.Component = blockType.Display == BlockDisplayMode.Horizontal ? "block-group-horizontal" : "block-group-vertical"; } foreach (var prop in block.GetType().GetProperties(App.PropertyBindings)) { if (typeof(Extend.IField).IsAssignableFrom(prop.PropertyType)) { var fieldType = App.Fields.GetByType(prop.PropertyType); var field = new FieldModel { Model = (Extend.IField)prop.GetValue(block), Meta = new FieldMeta { Id = prop.Name, Name = prop.Name, Component = fieldType.Component, } }; // Check if this is a select field if (typeof(Extend.Fields.SelectFieldBase).IsAssignableFrom(fieldType.Type)) { foreach (var item in ((Extend.Fields.SelectFieldBase)Activator.CreateInstance(fieldType.Type)).Items) { field.Meta.Options.Add(Convert.ToInt32(item.Value), item.Title); } } // Check if we have field meta-data available var attr = prop.GetCustomAttribute <Extend.FieldAttribute>(); if (attr != null) { field.Meta.Name = !string.IsNullOrWhiteSpace(attr.Title) ? attr.Title : field.Meta.Name; field.Meta.Placeholder = attr.Placeholder; field.Meta.IsHalfWidth = attr.Options.HasFlag(FieldOption.HalfWidth); } // Check if we have field description meta-data available var descAttr = prop.GetCustomAttribute <Extend.FieldDescriptionAttribute>(); if (descAttr != null) { field.Meta.Description = descAttr.Text; } group.Fields.Add(field); } } bool firstChild = true; foreach (var child in ((Extend.BlockGroup)block).Items) { blockType = App.Blocks.GetByType(child.Type); group.Items.Add(new BlockItemModel { IsActive = firstChild, Model = child, Meta = new BlockMeta { Name = blockType.Name, Title = child.GetTitle(), Icon = blockType.Icon, Component = blockType.Component } }); firstChild = false; } model.Blocks.Add(group); } else { model.Blocks.Add(new BlockItemModel { Model = block, Meta = new BlockMeta { Name = blockType.Name, Title = block.GetTitle(), Icon = blockType.Icon, Component = blockType.Component, IsReadonly = page.OriginalPageId.HasValue, isCollapsed = config.ManagerDefaultCollapsedBlocks } }); } } // Custom editors foreach (var editor in type.CustomEditors) { model.Editors.Add(new EditorModel { Component = editor.Component, Icon = editor.Icon, Name = editor.Title }); } return(model); }
public async Task <PageEditModel> GetById(Guid id) { var page = await _api.Pages.GetByIdAsync(id); if (page != null) { var type = App.PageTypes.GetById(page.TypeId); var model = new PageEditModel { Id = page.Id, SiteId = page.SiteId, ParentId = page.ParentId, SortOrder = page.SortOrder, TypeId = page.TypeId, Title = page.Title, NavigationTitle = page.NavigationTitle, Slug = page.Slug, MetaKeywords = page.MetaKeywords, MetaDescription = page.MetaDescription, Published = page.Published.HasValue ? page.Published.Value.ToString("yyyy-MM-dd HH:mm") : null }; foreach (var regionType in type.Regions) { var region = new RegionModel { Meta = new RegionMeta { Id = regionType.Id, Name = regionType.Title, Description = regionType.Description, Placeholder = regionType.ListTitlePlaceholder, IsCollection = regionType.Collection, Icon = regionType.Icon, Display = regionType.Display.ToString().ToLower() } }; var regionListModel = ((IDictionary <string, object>)page.Regions)[regionType.Id]; if (!regionType.Collection) { var regionModel = (IRegionList)Activator.CreateInstance(typeof(RegionList <>).MakeGenericType(regionListModel.GetType())); regionModel.Add(regionListModel); regionListModel = regionModel; } foreach (var regionModel in (IEnumerable)regionListModel) { var regionItem = new RegionItemModel(); foreach (var fieldType in regionType.Fields) { var appFieldType = App.Fields.GetByType(fieldType.Type); var field = new FieldModel { Meta = new FieldMeta { Id = fieldType.Id, Name = fieldType.Title, Component = appFieldType.Component, Placeholder = fieldType.Placeholder, IsHalfWidth = fieldType.Options.HasFlag(FieldOption.HalfWidth) } }; if (regionType.Fields.Count > 1) { field.Model = (Extend.IField)((IDictionary <string, object>)regionModel)[fieldType.Id]; if (regionType.ListTitleField == fieldType.Id) { regionItem.Title = field.Model.GetTitle(); field.Meta.NotifyChange = true; } } else { field.Model = (Extend.IField)regionModel; field.Meta.NotifyChange = true; regionItem.Title = field.Model.GetTitle(); } regionItem.Fields.Add(field); } if (string.IsNullOrWhiteSpace(regionItem.Title)) { regionItem.Title = "..."; } region.Items.Add(regionItem); } model.Regions.Add(region); } foreach (var block in page.Blocks) { var blockType = App.Blocks.GetByType(block.Type); if (block is Extend.BlockGroup) { var group = new BlockGroupModel { Id = block.Id, Type = block.Type, Meta = new BlockMeta { Name = blockType.Name, Icon = blockType.Icon, Component = "block-group", IsGroup = true } }; if (blockType.Display != BlockDisplayMode.MasterDetail) { group.Meta.Component = blockType.Display == BlockDisplayMode.Horizontal ? "block-group-horizontal" : "block-group-vertical"; } foreach (var prop in block.GetType().GetProperties(App.PropertyBindings)) { if (typeof(Extend.IField).IsAssignableFrom(prop.PropertyType)) { var fieldType = App.Fields.GetByType(prop.PropertyType); group.Fields.Add(new FieldModel { Model = (Extend.IField)prop.GetValue(block), Meta = new FieldMeta { Id = prop.Name, Name = prop.Name, Component = fieldType.Component, } }); } } bool firstChild = true; foreach (var child in ((Extend.BlockGroup)block).Items) { blockType = App.Blocks.GetByType(child.Type); group.Items.Add(new BlockItemModel { IsActive = firstChild, Model = child, Meta = new BlockMeta { Name = blockType.Name, Title = child.GetTitle(), Icon = blockType.Icon, Component = blockType.Component } }); firstChild = false; } model.Blocks.Add(group); } else { model.Blocks.Add(new BlockItemModel { Model = block, Meta = new BlockMeta { Name = blockType.Name, Title = block.GetTitle(), Icon = blockType.Icon, Component = blockType.Component } }); } } return(model); } return(null); }