WIP - editing all variants at once, this is getting things wired up to display a content item, lots of TODOs added, models and mappings refactored, content apps put in c# model, etc...
This commit is contained in:
@@ -35,11 +35,13 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// <param name="entityType">This must be either 'content' or 'media'</param>
|
||||
/// <param name="dataTypeService"></param>
|
||||
/// <param name="localizedTextService"></param>
|
||||
internal static void AddListView<TPersisted>(TabbedContentItem<ContentPropertyDisplay, TPersisted> display, string entityType, IDataTypeService dataTypeService, ILocalizedTextService localizedTextService)
|
||||
where TPersisted : IContentBase
|
||||
internal static void AddListView(
|
||||
ITabbedContentItem<ContentPropertyDisplay> display,
|
||||
string contentTypeAlias, string entityType,
|
||||
IDataTypeService dataTypeService, ILocalizedTextService localizedTextService)
|
||||
{
|
||||
int dtdId;
|
||||
var customDtdName = Constants.Conventions.DataTypes.ListViewPrefix + display.ContentTypeAlias;
|
||||
var customDtdName = Constants.Conventions.DataTypes.ListViewPrefix + contentTypeAlias;
|
||||
switch (entityType)
|
||||
{
|
||||
case "content":
|
||||
@@ -71,39 +73,43 @@ namespace Umbraco.Web.Models.Mapping
|
||||
throw new NullReferenceException("The property editor with alias " + dt.EditorAlias + " does not exist");
|
||||
}
|
||||
|
||||
var listViewTab = new Tab<ContentPropertyDisplay>
|
||||
{
|
||||
Alias = Constants.Conventions.PropertyGroups.ListViewGroupName,
|
||||
Label = localizedTextService.Localize("content/childItems"),
|
||||
Id = display.Tabs.Count() + 1,
|
||||
IsActive = true
|
||||
};
|
||||
//TODO: We need to move this logic elsewhere, we don't want to have to add a list view to a tab that will
|
||||
// get removed later and magically move to the ListView ContentApp. The ListView ContentApp will need to
|
||||
// manage this data somehow so a content app will also need to be able to specify it's own model.
|
||||
|
||||
var listViewConfig = editor.GetConfigurationEditor().ToConfigurationEditor(dt.Configuration);
|
||||
//add the entity type to the config
|
||||
listViewConfig["entityType"] = entityType;
|
||||
//var listViewTab = new Tab<ContentPropertyDisplay>
|
||||
//{
|
||||
// Alias = Constants.Conventions.PropertyGroups.ListViewGroupName,
|
||||
// Label = localizedTextService.Localize("content/childItems"),
|
||||
// Id = display.Tabs.Count() + 1,
|
||||
// IsActive = true
|
||||
//};
|
||||
|
||||
//Override Tab Label if tabName is provided
|
||||
if (listViewConfig.ContainsKey("tabName"))
|
||||
{
|
||||
var configTabName = listViewConfig["tabName"];
|
||||
if (configTabName != null && string.IsNullOrWhiteSpace(configTabName.ToString()) == false)
|
||||
listViewTab.Label = configTabName.ToString();
|
||||
}
|
||||
//var listViewConfig = editor.GetConfigurationEditor().ToConfigurationEditor(dt.Configuration);
|
||||
////add the entity type to the config
|
||||
//listViewConfig["entityType"] = entityType;
|
||||
|
||||
var listViewProperties = new List<ContentPropertyDisplay>();
|
||||
listViewProperties.Add(new ContentPropertyDisplay
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}containerView",
|
||||
Label = "",
|
||||
Value = null,
|
||||
View = editor.GetValueEditor().View,
|
||||
HideLabel = true,
|
||||
Config = listViewConfig
|
||||
});
|
||||
listViewTab.Properties = listViewProperties;
|
||||
////Override Tab Label if tabName is provided
|
||||
//if (listViewConfig.ContainsKey("tabName"))
|
||||
//{
|
||||
// var configTabName = listViewConfig["tabName"];
|
||||
// if (configTabName != null && string.IsNullOrWhiteSpace(configTabName.ToString()) == false)
|
||||
// listViewTab.Label = configTabName.ToString();
|
||||
//}
|
||||
|
||||
SetChildItemsTabPosition(display, listViewConfig, listViewTab);
|
||||
//var listViewProperties = new List<ContentPropertyDisplay>();
|
||||
//listViewProperties.Add(new ContentPropertyDisplay
|
||||
//{
|
||||
// Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}containerView",
|
||||
// Label = "",
|
||||
// Value = null,
|
||||
// View = editor.GetValueEditor().View,
|
||||
// HideLabel = true,
|
||||
// Config = listViewConfig
|
||||
//});
|
||||
//listViewTab.Properties = listViewProperties;
|
||||
|
||||
//SetChildItemsTabPosition(display, listViewConfig, listViewTab);
|
||||
}
|
||||
|
||||
private static int GetTabNumberFromConfig(IDictionary<string, object> listViewConfig)
|
||||
@@ -120,37 +126,36 @@ namespace Umbraco.Web.Models.Mapping
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static void SetChildItemsTabPosition<TPersisted>(TabbedContentItem<ContentPropertyDisplay, TPersisted> display,
|
||||
IDictionary<string, object> listViewConfig,
|
||||
Tab<ContentPropertyDisplay> listViewTab)
|
||||
where TPersisted : IContentBase
|
||||
{
|
||||
// Find position of tab from config
|
||||
var tabIndexForChildItems = GetTabNumberFromConfig(listViewConfig);
|
||||
if (tabIndexForChildItems != -1)
|
||||
{
|
||||
// Tab position is recorded 1-based but we insert into collection 0-based
|
||||
tabIndexForChildItems--;
|
||||
//private static void SetChildItemsTabPosition(ITabbedContentItem<ContentPropertyDisplay> display,
|
||||
// IDictionary<string, object> listViewConfig,
|
||||
// Tab<ContentPropertyDisplay> listViewTab)
|
||||
//{
|
||||
// // Find position of tab from config
|
||||
// var tabIndexForChildItems = GetTabNumberFromConfig(listViewConfig);
|
||||
// if (tabIndexForChildItems != -1)
|
||||
// {
|
||||
// // Tab position is recorded 1-based but we insert into collection 0-based
|
||||
// tabIndexForChildItems--;
|
||||
|
||||
// Ensure within bounds
|
||||
if (tabIndexForChildItems < 0)
|
||||
{
|
||||
tabIndexForChildItems = 0;
|
||||
}
|
||||
// // Ensure within bounds
|
||||
// if (tabIndexForChildItems < 0)
|
||||
// {
|
||||
// tabIndexForChildItems = 0;
|
||||
// }
|
||||
|
||||
if (tabIndexForChildItems > display.Tabs.Count())
|
||||
{
|
||||
tabIndexForChildItems = display.Tabs.Count();
|
||||
}
|
||||
}
|
||||
else tabIndexForChildItems = 0;
|
||||
// if (tabIndexForChildItems > display.Tabs.Count())
|
||||
// {
|
||||
// tabIndexForChildItems = display.Tabs.Count();
|
||||
// }
|
||||
// }
|
||||
// else tabIndexForChildItems = 0;
|
||||
|
||||
// Recreate tab list with child items tab at configured position
|
||||
var tabs = new List<Tab<ContentPropertyDisplay>>();
|
||||
tabs.AddRange(display.Tabs);
|
||||
tabs.Insert(tabIndexForChildItems, listViewTab);
|
||||
display.Tabs = tabs;
|
||||
}
|
||||
// // Recreate tab list with child items tab at configured position
|
||||
// var tabs = new List<Tab<ContentPropertyDisplay>>();
|
||||
// tabs.AddRange(display.Tabs);
|
||||
// tabs.Insert(tabIndexForChildItems, listViewTab);
|
||||
// display.Tabs = tabs;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of custom generic properties that exist on the generic properties tab
|
||||
@@ -234,7 +239,6 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
//we need to map this way to pass the context through, I don't like it but we'll see what AutoMapper says: https://github.com/AutoMapper/AutoMapper/issues/2588
|
||||
var result = context.Mapper.Map<IEnumerable<Property>, IEnumerable<ContentPropertyDisplay>>(
|
||||
// Sort properties so items from different compositions appear in correct order (see U4-9298). Map sorted properties.
|
||||
properties.OrderBy(prop => prop.PropertyType.SortOrder),
|
||||
null,
|
||||
context)
|
||||
|
||||
Reference in New Issue
Block a user