protected override IEnumerable <Tab <ContentPropertyDisplay> > ResolveCore(IContentBase content) { var aggregateTabs = new List <Tab <ContentPropertyDisplay> >(); //now we need to aggregate the tabs and properties since we might have duplicate tabs (based on aliases) because // of how content composition works. foreach (var propertyGroups in content.PropertyGroups.OrderBy(x => x.SortOrder).GroupBy(x => x.Name)) { var aggregateProperties = new List <ContentPropertyDisplay>(); //add the properties from each composite property group foreach (var current in propertyGroups) { var propsForGroup = content.GetPropertiesForGroup(current) .Where(x => IgnoreProperties.Contains(x.Alias) == false); //don't include ignored props aggregateProperties.AddRange( Mapper.Map <IEnumerable <Property>, IEnumerable <ContentPropertyDisplay> >( propsForGroup)); } if (aggregateProperties.Count == 0) { continue; } TranslateProperties(aggregateProperties); //then we'll just use the root group's data to make the composite tab var rootGroup = propertyGroups.First(x => x.ParentId == null); aggregateTabs.Add(new Tab <ContentPropertyDisplay> { Id = rootGroup.Id, Alias = rootGroup.Name, Label = TranslateItem(rootGroup.Name), Properties = aggregateProperties, IsActive = false }); } //now add the generic properties tab for any properties that don't belong to a tab var orphanProperties = content.GetNonGroupedProperties() .Where(x => IgnoreProperties.Contains(x.Alias) == false); //don't include ignored props //now add the generic properties tab var genericproperties = Mapper.Map <IEnumerable <Property>, IEnumerable <ContentPropertyDisplay> >(orphanProperties).ToList(); TranslateProperties(genericproperties); aggregateTabs.Add(new Tab <ContentPropertyDisplay> { Id = 0, Label = ui.Text("general", "properties"), Alias = "Generic properties", Properties = genericproperties }); //set the first tab to active aggregateTabs.First().IsActive = true; return(aggregateTabs); }
protected override IEnumerable <Tab <ContentPropertyDisplay> > ResolveCore(IContentBase content) { var tabs = new List <Tab <ContentPropertyDisplay> >(); // add the tabs, for properties that belong to a tab // need to aggregate the tabs, as content.PropertyGroups contains all the composition tabs, // and there might be duplicates (content does not work like contentType and there is no // content.CompositionPropertyGroups). var groupsGroupsByName = content.PropertyGroups.OrderBy(x => x.SortOrder).GroupBy(x => x.Name); foreach (var groupsByName in groupsGroupsByName) { var properties = new List <Property>(); // merge properties for groups with the same name foreach (var group in groupsByName) { var groupProperties = content.GetPropertiesForGroup(group) .Where(x => IgnoreProperties.Contains(x.Alias) == false); // skip ignored properties.AddRange(groupProperties); } if (properties.Count == 0) { continue; } // Sort properties so items from different compositions appear in correct order (see U4-9298). Map sorted properties. var mappedProperties = Mapper.Map <IEnumerable <Property>, IEnumerable <ContentPropertyDisplay> >(properties.OrderBy(prop => prop.PropertyType.SortOrder)); TranslateProperties(mappedProperties); // add the tab // we need to pick an identifier... there is no "right" way... var g = groupsByName.FirstOrDefault(x => x.Id == content.ContentTypeId) // try local ?? groupsByName.First(); // else pick one randomly var groupId = g.Id; var groupName = groupsByName.Key; tabs.Add(new Tab <ContentPropertyDisplay> { Id = groupId, Alias = groupName, Label = _localizedTextService.UmbracoDictionaryTranslate(groupName), Properties = mappedProperties, IsActive = false }); } // add the generic properties tab, for properties that don't belong to a tab // get the properties, map and translate them, then add the tab var noGroupProperties = content.GetNonGroupedProperties() .Where(x => IgnoreProperties.Contains(x.Alias) == false); // skip ignored var genericproperties = Mapper.Map <IEnumerable <Property>, IEnumerable <ContentPropertyDisplay> >(noGroupProperties).ToList(); TranslateProperties(genericproperties); tabs.Add(new Tab <ContentPropertyDisplay> { Id = 0, Label = _localizedTextService.Localize("general/properties"), Alias = "Generic properties", Properties = genericproperties }); // activate the first tab tabs.First().IsActive = true; return(tabs); }