public CmsContentListDefinition GenerateDefaultContentListDefinition(Type clrType) { var configuratorSettingProperties = ToolboxMetadataReader.ReadProperties(clrType, ToolboxPropertyFilter.SupportsDesigner); var definition = new CmsContentListDefinition(); foreach (var property in configuratorSettingProperties) { var ignore = property.PropertyInfo.PropertyType == typeof(Guid?) || property.PropertyInfo.PropertyType == typeof(Guid) || property.PropertyInfo.GetCustomAttribute <SerializedComplexObjectAttribute>() != null; if (!ignore) { definition.Fields.Add(new CmsListField { Id = Guid.NewGuid(), Label = property.DisplayName, PropertyName = property.PropertyInfo.Name }); } } return(definition); }
public EditingSession EditingSession(CmsForm form, Type entityType, IDictionary <string, string> initialValues) { var session = new EditingSession { InitialValues = initialValues }; var widgetsGroupedByProperty = GetClientSideWidgetLookup(form); var editingScope = BuildObjectEditingScope(form); var properties = ToolboxMetadataReader.ReadProperties(entityType, x => editingScope.Contains(x.Name)) .ToDictionary(x => x.PropertyInfo.Name); foreach (var widgetGroup in widgetsGroupedByProperty) { var propertyName = widgetGroup.Key; var widgetsNeedingDataSource = widgetGroup.ToList(); foreach (var widget in widgetsNeedingDataSource) { var dataSource = new RequiresDataSource(); dataSource.SetPropertyValues(widget.Parameters, x => true); var isLinkedToRepository = dataSource.DataSourceType == DataSourceTypes.Repository && dataSource.RepositoryApiId != default(Guid); if (isLinkedToRepository) { var entities = GetDataRelationshipEntities(dataSource, properties[propertyName]); var asDataSourceItems = entities.Select(x => new DataSourceItem { Name = x.Title, Value = x.ContentId.ToString() }).ToList(); var ds = new LocalDataSource { Items = asDataSourceItems }; session.LocalDataSources.Add(propertyName, ds); continue; } var isLinkedToFixedSet = dataSource.DataSourceType == DataSourceTypes.FixedItems; if (isLinkedToFixedSet) { var ds = new LocalDataSource { Items = dataSource.Items.Items }; session.LocalDataSources.Add(propertyName, ds); continue; } } } return(session); }
public CmsPageContent BuildCmsPageContentFromToolboxItemTemplate(object activated) { var toolboxMetadata = ToolboxMetadataReader.ReadMetadata(activated.GetType()); var toolboxItem = new ToolboxManager().GetToolboxItemByCode(toolboxMetadata.WidgetUid); IDictionary <string, string> settings = activated.GetPropertyValues(ToolboxPropertyFilter.SupportsDesigner); return(new CmsPageContent { Id = Guid.NewGuid(), WidgetTypeCode = toolboxItem.WidgetUid, Parameters = settings.ToDictionary(x => x.Key, x => x.Value) }); }
public CmsForm GenerateDefaultForm(Type clrType, FormStyle formStyle) { if (formStyle == FormStyle.Undefined) { throw new ArgumentException(nameof(formStyle)); } var builder = new ConfiguratorCmsPageContentBuilder(); var cmsForm = new CmsForm(); var row = builder.CreateRow(1); cmsForm.ChildNodes.Add(row); var configuratorSettingProperties = ToolboxMetadataReader.ReadProperties(clrType, ToolboxPropertyFilter.SupportsDesigner); foreach (var property in configuratorSettingProperties) { string widgetTypeCode = null; if (formStyle == FormStyle.Edit) { if (property.WidgetTypeCode != null) { widgetTypeCode = property.WidgetTypeCode; } else { var editor = GetEditorForSettingProperty(property); widgetTypeCode = AutoSelectWidgetForEditorCode(editor); } } if (formStyle == FormStyle.Readonly) { widgetTypeCode = AutoSelectWidgetForEditorCode(Editor.Static); } var content = builder.CreateCmsPageContent(property, widgetTypeCode, formStyle); content.PlacementContentPlaceHolderId = 0.ToString(); content.Id = Guid.NewGuid(); row.AllContent.Add(content); } return(cmsForm); }
public IEnumerable <ListOption> GetOptions(ConfiguratorBuildArguments buildArguments, IDictionary <string, string> model) { var propertiesFilered = new List <PropertyInfo>();// ConfiguratorEditingContextHelper.PropertiesFilered(buildArguments); if (_propertyTypes != null) { propertiesFilered = propertiesFilered.Where(x => _propertyTypes.Contains(x.PropertyType)).ToList(); } foreach (var prop in propertiesFilered) { var metadata = ToolboxMetadataReader.GetPropertyMetadata(prop); var label = PropertyDataSourceHelper.CreateListOptionLabel(metadata); yield return(new ListOption { Text = label, Value = prop.Name }); } }