Some clean up in ContentModelMapper.cs
This commit is contained in:
@@ -119,67 +119,63 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
TabsAndPropertiesResolver.AddListView(display, "content", dataTypeService, localizedText);
|
||||
}
|
||||
|
||||
var properties = new List<ContentPropertyDisplay>();
|
||||
|
||||
TabsAndPropertiesResolver.MapGenericProperties(content, display, localizedText, properties.ToArray(),
|
||||
genericProperties =>
|
||||
{
|
||||
//TODO: This would be much nicer with the IUmbracoContextAccessor so we don't use singletons
|
||||
//If this is a web request and there's a user signed in and the
|
||||
// user has access to the settings section, we will
|
||||
if (HttpContext.Current != null && UmbracoContext.Current != null && UmbracoContext.Current.Security.CurrentUser != null
|
||||
&& UmbracoContext.Current.Security.CurrentUser.AllowedSections.Any(x => x.Equals(Constants.Applications.Settings)))
|
||||
{
|
||||
var currentDocumentType = contentTypeService.GetContentType(display.ContentTypeAlias);
|
||||
var currentDocumentTypeName = currentDocumentType == null ? string.Empty : localizedText.UmbracoDictionaryTranslate(currentDocumentType.Name);
|
||||
|
||||
var currentDocumentTypeId = currentDocumentType == null ? string.Empty : currentDocumentType.Id.ToString(CultureInfo.InvariantCulture);
|
||||
//TODO: Hard coding this is not good
|
||||
var docTypeLink = string.Format("#/settings/documenttypes/edit/{0}", currentDocumentTypeId);
|
||||
|
||||
var templateProperty = new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}template",
|
||||
Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = localizedText.Localize("template/template"),
|
||||
Value = display.TemplateAlias,
|
||||
View =
|
||||
"dropdown", //TODO: Hard coding until we make a real dropdown property editor to lookup
|
||||
Config = new Dictionary<string, object>
|
||||
{
|
||||
{"items", templateItemConfig}
|
||||
}
|
||||
};
|
||||
|
||||
//Replace the doc type property
|
||||
var docTypeProperty = new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}doctype",
|
||||
Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = localizedText.Localize("content/documentType"),
|
||||
Value = localizedText.UmbracoDictionaryTranslate(display.ContentTypeName),
|
||||
View = PropertyEditorResolver.Current.GetByAlias(Constants.PropertyEditors.NoEditAlias)
|
||||
.ValueEditor.View
|
||||
};
|
||||
docTypeProperty.Value = new List<object>
|
||||
{
|
||||
new
|
||||
{
|
||||
linkText = currentDocumentTypeName,
|
||||
url = docTypeLink,
|
||||
target = "_self",
|
||||
icon = "icon-item-arrangement"
|
||||
}
|
||||
};
|
||||
//TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor
|
||||
docTypeProperty.View = "urllist";
|
||||
|
||||
//Moving template and docType properties to the root node (issue U4-10311)
|
||||
display.AllowedTemplates = templateProperty.Config;
|
||||
display.DocTypeValue = docTypeProperty.Value;
|
||||
}
|
||||
});
|
||||
//TODO: This would be much nicer with the IUmbracoContextAccessor so we don't use singletons
|
||||
//If this is a web request and there's a user signed in and the
|
||||
// user has access to the settings section, we will
|
||||
if (HttpContext.Current != null && UmbracoContext.Current != null && UmbracoContext.Current.Security.CurrentUser != null
|
||||
&& UmbracoContext.Current.Security.CurrentUser.AllowedSections.Any(x => x.Equals(Constants.Applications.Settings)))
|
||||
{
|
||||
var currentDocumentType = contentTypeService.GetContentType(display.ContentTypeAlias);
|
||||
var currentDocumentTypeName = currentDocumentType == null ? string.Empty : localizedText.UmbracoDictionaryTranslate(currentDocumentType.Name);
|
||||
|
||||
var currentDocumentTypeId = currentDocumentType == null ? string.Empty : currentDocumentType.Id.ToString(CultureInfo.InvariantCulture);
|
||||
//TODO: Hard coding this is not good
|
||||
var docTypeLink = string.Format("#/settings/documenttypes/edit/{0}", currentDocumentTypeId);
|
||||
|
||||
var templateProperty = new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}template",
|
||||
Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = localizedText.Localize("template/template"),
|
||||
Value = display.TemplateAlias,
|
||||
View =
|
||||
"dropdown", //TODO: Hard coding until we make a real dropdown property editor to lookup
|
||||
Config = new Dictionary<string, object>
|
||||
{
|
||||
{"items", templateItemConfig}
|
||||
}
|
||||
};
|
||||
|
||||
//Replace the doc type property
|
||||
var docTypeProperty = new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}doctype",
|
||||
Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = localizedText.Localize("content/documentType"),
|
||||
Value = localizedText.UmbracoDictionaryTranslate(display.ContentTypeName),
|
||||
View = PropertyEditorResolver.Current.GetByAlias(Constants.PropertyEditors.NoEditAlias)
|
||||
.ValueEditor.View
|
||||
};
|
||||
docTypeProperty.Value = new List<object>
|
||||
{
|
||||
new
|
||||
{
|
||||
linkText = currentDocumentTypeName,
|
||||
url = docTypeLink,
|
||||
target = "_self",
|
||||
icon = "icon-item-arrangement"
|
||||
}
|
||||
};
|
||||
//TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor
|
||||
docTypeProperty.View = "urllist";
|
||||
|
||||
//Moving template and docType properties to the root node (issue U4-10311)
|
||||
display.AllowedTemplates = templateProperty.Config;
|
||||
display.DocTypeValue = docTypeProperty.Value;
|
||||
}
|
||||
|
||||
TabsAndPropertiesResolver.MapGenericProperties(content, display, localizedText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user