/// <summary> /// initialize collections so they are never null /// </summary> protected AbstractSchemaEditorModel() { NewProperty = new DocumentTypeProperty(); ActiveTabIndex = 0; Properties = new HashSet <DocumentTypeProperty>(); AllowedChildren = Enumerable.Empty <SelectListItem>(); AllowedChildIds = Enumerable.Empty <HiveId>(); InheritFrom = Enumerable.Empty <HierarchicalSelectListItem>(); InheritFromIds = Enumerable.Empty <HiveId>(); AvailableIcons = Enumerable.Empty <SelectListItem>(); AvailableThumbnails = Enumerable.Empty <SelectListItem>(); AvailableDataTypes = Enumerable.Empty <SelectListItem>(); AvailableTabs = Enumerable.Empty <SelectListItem>(); //ensure theres always a general tab DefinedTabs = new HashSet <Tab>(); var generalGroup = FixedGroupDefinitions.GeneralGroup; DefinedTabs.Add(new Tab { Alias = generalGroup.Alias, Name = generalGroup.Name, SortOrder = generalGroup.Ordinal }); InheritedTabs = new HashSet <Tab>(); InheritedProperties = new HashSet <DocumentTypeProperty>(); IsReadOnly = false; IsAbstract = false; Icon = "tree-folder"; Thumbnail = "doc.png"; PopulateUIElements(); }
/// <summary> /// initialize collections so they are never null /// </summary> protected AbstractSchemaEditorModel() { NewProperty = new DocumentTypeProperty(); ActiveTabIndex = 0; Properties = new HashSet<DocumentTypeProperty>(); AllowedChildren = Enumerable.Empty<SelectListItem>(); AllowedChildIds = Enumerable.Empty<HiveId>(); InheritFrom = Enumerable.Empty<HierarchicalSelectListItem>(); InheritFromIds = Enumerable.Empty<HiveId>(); AvailableIcons = Enumerable.Empty<SelectListItem>(); AvailableThumbnails = Enumerable.Empty<SelectListItem>(); AvailableDataTypes = Enumerable.Empty<SelectListItem>(); AvailableTabs = Enumerable.Empty<SelectListItem>(); //ensure theres always a general tab DefinedTabs = new HashSet<Tab>(); var generalGroup = FixedGroupDefinitions.GeneralGroup; DefinedTabs.Add(new Tab { Alias = generalGroup.Alias, Name = generalGroup.Name, SortOrder = generalGroup.Ordinal }); InheritedTabs = new HashSet<Tab>(); InheritedProperties = new HashSet<DocumentTypeProperty>(); IsReadOnly = false; IsAbstract = false; Icon = "tree-folder"; Thumbnail = "doc.png"; PopulateUIElements(); }
/// <summary> /// Constructor for creating a property that has a single bool value /// </summary> /// <param name="id"></param> /// <param name="docTypeProperty"></param> /// <param name="propertyValue">The value of the property</param> /// <remarks> /// This will create a new Dictionary object to put the value in with a key of "Value" /// </remarks> public ContentProperty(HiveId id, DocumentTypeProperty docTypeProperty, bool propertyValue) : this(id, docTypeProperty, new Dictionary <string, object> { { "Value", propertyValue } }) { }
/// <summary> /// constructor for creating a property that has a multi-value /// </summary> /// <param name="id"></param> /// <param name="docTypeProperty">The DocumentTypeProperty associated with this content property</param> /// <param name="propertyValue">The value of the property, used to set the values of the editor model</param> public ContentProperty(HiveId id, DocumentTypeProperty docTypeProperty, IDictionary <string, object> propertyValue) { Mandate.ParameterNotEmpty(id, "id"); Mandate.ParameterNotNull(docTypeProperty, "docTypeProperty"); _propertyValue = propertyValue; Id = id; DocTypeProperty = docTypeProperty; DocTypePropertyId = docTypeProperty.Id; }
/// <summary> /// constructor for creating a property that has a multi-value /// </summary> /// <param name="id"></param> /// <param name="docTypeProperty">The DocumentTypeProperty associated with this content property</param> /// <param name="propertyValue">The value of the property, used to set the values of the editor model</param> public ContentProperty(HiveId id, DocumentTypeProperty docTypeProperty, IDictionary<string, object> propertyValue) { Mandate.ParameterNotEmpty(id, "id"); Mandate.ParameterNotNull(docTypeProperty, "docTypeProperty"); _propertyValue = propertyValue; Id = id; DocTypeProperty = docTypeProperty; DocTypePropertyId = docTypeProperty.Id; }
/// <summary> /// Creates selected template property /// </summary> /// <param name="docType"></param> /// <returns></returns> private DocumentTypeProperty CreateSelectedTemplate(DocumentTypeEditorModel docType) { var selectedTemplateAttributeType = _attributeTypeRegistry.GetAttributeType(SelectedTemplateAttributeType.AliasValue); _selectedTemplateDataType = new DataType( selectedTemplateAttributeType.Id, selectedTemplateAttributeType.Name, selectedTemplateAttributeType.Alias, _propertyEditorFactory.GetPropertyEditor(new Guid(CorePluginConstants.SelectedTemplatePropertyEditorId)).Value, string.Empty); var dtp = new DocumentTypeProperty(new HiveId(Guid.NewGuid()), _selectedTemplateDataType); dtp.Name = "Selected template"; dtp.Alias = SelectedTemplateAttributeDefinition.AliasValue; //dtp.TabId = docType.DefinedTabs.Where(x => x.Alias == _generalGroup.Alias).Single().Id; dtp.TabId = docType.DefinedTabs.Single(x => x.Alias == FixedGroupDefinitions.GeneralGroup.Alias).Id; dtp.SortOrder = 0; return dtp; }
/// <summary> /// Create properties from xml /// </summary> /// <param name="docTypeXml"></param> /// <param name="docType"></param> /// <returns></returns> private new HashSet<DocumentTypeProperty> CreateProperties(XElement docTypeXml, DocumentTypeEditorModel docType) { var properties = new HashSet<DocumentTypeProperty>(); properties.Add(CreateNodeName(docType)); properties.Add(CreateSelectedTemplate(docType)); var propsXml = docTypeXml.Descendants("property"); foreach (var xElement in propsXml) { var name = xElement.Attribute("Name").Value; var alias = xElement.Attribute("Alias").Value; var dataTypeAlias = xElement.Element("DataTypeAlias").Value; var sortOrder = int.Parse(xElement.Attribute("SortOrder").Value); var tabAlias = xElement.Attribute("TabAlias").Value; LogHelper.Error<UmbracoXmlImportHelper>(String.Format("the data type alias was {0}", dataTypeAlias), new Exception()); var dataType = _dataTypes.First(x => x.Alias == dataTypeAlias); // TODO: property is not in tab...possibly need object initializer? var p = new DocumentTypeProperty(new HiveId(Guid.NewGuid()), dataType) { Name = name, Alias = alias, // TabId = docType.DefinedTabs.Single(x => x.Alias == tabAlias).Id, SortOrder = sortOrder }; properties.Add(p); } return properties; }
/// <summary> /// Creates Node Name property /// </summary> /// <param name="docType"></param> /// <returns></returns> private DocumentTypeProperty CreateNodeName(DocumentTypeEditorModel docType) { var nodeNameAttributeType = _attributeTypeRegistry.GetAttributeType(NodeNameAttributeType.AliasValue); _nodeNameDataType = new DataType( nodeNameAttributeType.Id, nodeNameAttributeType.Name, nodeNameAttributeType.Alias, _propertyEditorFactory.GetPropertyEditor(new Guid(CorePluginConstants.NodeNamePropertyEditorId)).Value, string.Empty); var dtp = new DocumentTypeProperty(new HiveId(Guid.NewGuid()), _nodeNameDataType); dtp.Name = "Node Name"; dtp.Alias = NodeNameAttributeDefinition.AliasValue; dtp.TabId = docType.DefinedTabs.Single(x => x.Alias == FixedGroupDefinitions.GeneralGroup.Alias).Id; dtp.SortOrder = 0; return dtp; }
/// <summary> /// Constructor for creating a property that has a single decimal value /// </summary> /// <param name="id"></param> /// <param name="docTypeProperty"></param> /// <param name="propertyValue">The value of the property</param> /// <remarks> /// This will create a new Dictionary object to put the value in with a key of "Value" /// </remarks> public ContentProperty(HiveId id, DocumentTypeProperty docTypeProperty, decimal propertyValue) : this(id, docTypeProperty, new Dictionary<string, object> { { "Value", propertyValue } }) { }