Merge branch 'dev-v7-contenttypeeditor' of https://github.com/umbraco/Umbraco-CMS into dev-v7-contenttypeeditor
This commit is contained in:
@@ -26,7 +26,7 @@ namespace Umbraco.Core.Models
|
||||
private string _alias;
|
||||
private string _description;
|
||||
private int _sortOrder;
|
||||
private string _icon = "folder.png";
|
||||
private string _icon = "icon-folder";
|
||||
private string _thumbnail = "folder.png";
|
||||
private int _creatorId;
|
||||
private bool _allowedAsRoot;
|
||||
|
||||
@@ -11,57 +11,34 @@ function MemberTypeEditController($scope, $rootScope, $routeParams, $log, member
|
||||
$scope.page = {actions: [], menu: [], subViews: [] };
|
||||
$scope.sortingMode = false;
|
||||
|
||||
$scope.page.subViews = [
|
||||
{
|
||||
"name": "Design",
|
||||
"icon": "merge",
|
||||
"view": "views/documentType/views/design/design.html",
|
||||
"tools": [
|
||||
{
|
||||
"name": "Reorder",
|
||||
"icon": "navigation",
|
||||
"action": function() {
|
||||
$scope.toggleSortingMode();
|
||||
$scope.page.navigation = [
|
||||
{
|
||||
"name": "Design",
|
||||
"icon": "merge",
|
||||
"view": "views/documentType/views/design/design.html",
|
||||
"active": true,
|
||||
"tools": [
|
||||
{
|
||||
"name": "Reorder",
|
||||
"icon": "navigation",
|
||||
"action": function() {
|
||||
$scope.toggleSortingMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
if ($routeParams.create) {
|
||||
//we are creating so get an empty data type item
|
||||
memberTypeResource.getScaffold()
|
||||
.then(function(dt) {
|
||||
$scope.contentType = dt;
|
||||
|
||||
//set a shared state
|
||||
editorState.set($scope.contentType);
|
||||
|
||||
// add init tab
|
||||
addInitTab();
|
||||
init(dt);
|
||||
});
|
||||
}
|
||||
else {
|
||||
memberTypeResource.getById($routeParams.id).then(function(dt){
|
||||
$scope.contentType = dt;
|
||||
|
||||
// set all tab to inactive
|
||||
if( $scope.contentType.groups.length !== 0 ) {
|
||||
angular.forEach($scope.contentType.groups, function(group){
|
||||
// set state
|
||||
group.tabState = "inActive";
|
||||
|
||||
// push init/placeholder property
|
||||
addInitProperty(group);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
//set a shared state
|
||||
editorState.set($scope.contentType);
|
||||
|
||||
// add init tab
|
||||
addInitTab();
|
||||
init(dt);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,26 +49,8 @@ function MemberTypeEditController($scope, $rootScope, $routeParams, $log, member
|
||||
//perform any pre-save logic here
|
||||
|
||||
memberTypeResource.save($scope.contentType).then(function(dt){
|
||||
|
||||
//post save logic here -the saved doctype returns as a new object
|
||||
|
||||
// set all tab to inactive
|
||||
if( $scope.contentType.groups.length !== 0 ) {
|
||||
angular.forEach($scope.contentType.groups, function(group){
|
||||
// set state
|
||||
group.tabState = "inActive";
|
||||
|
||||
// push init/placeholder property
|
||||
addInitProperty(group);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
//set a shared state
|
||||
editorState.set($scope.contentType);
|
||||
|
||||
// add init tab
|
||||
addInitTab();
|
||||
init(dt);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -137,6 +96,29 @@ function MemberTypeEditController($scope, $rootScope, $routeParams, $log, member
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function init(contentType){
|
||||
|
||||
$scope.contentType = contentType;
|
||||
|
||||
// set all tab to inactive
|
||||
if( $scope.contentType.groups.length !== 0 ) {
|
||||
angular.forEach($scope.contentType.groups, function(group){
|
||||
// set state
|
||||
group.tabState = "inActive";
|
||||
|
||||
// push init/placeholder property
|
||||
addInitProperty(group);
|
||||
});
|
||||
}
|
||||
|
||||
//set a shared state
|
||||
editorState.set($scope.contentType);
|
||||
|
||||
// add init tab
|
||||
addInitTab();
|
||||
}
|
||||
|
||||
function addInitTab() {
|
||||
|
||||
// check i init tab already exists
|
||||
|
||||
@@ -9,23 +9,16 @@
|
||||
name="contentType.name"
|
||||
alias="contentType.alias"
|
||||
description="contentType.description"
|
||||
menu="page.menu"
|
||||
actions="page.menu">
|
||||
navigation="page.navigation"
|
||||
icon="contentType.icon">
|
||||
</umb-editor-header>
|
||||
|
||||
<umb-editor-container class="editors-document-type-container">
|
||||
|
||||
<div class="editors-document-type-canvas" ng-class="{'is-in-sorting-mode': sortingMode}">
|
||||
|
||||
<umb-sub-views></umb-sub-views>
|
||||
|
||||
<pre>{{ contentType | json }}</pre>
|
||||
|
||||
<umb-editor-sub-views></umb-editor-sub-views>
|
||||
</div>
|
||||
|
||||
</umb-editor-container>
|
||||
|
||||
|
||||
<umb-editor-footer>
|
||||
<button type="submit" data-hotkey="ctrl+s" class="btn btn-success">
|
||||
<localize key="buttons_save">Save</localize>
|
||||
@@ -33,9 +26,6 @@
|
||||
</umb-editor-footer>
|
||||
|
||||
</umb-editor-view>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<!-- overlay for change property editor -->
|
||||
|
||||
@@ -114,6 +114,13 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
///TODO: Validate the submitted model
|
||||
|
||||
//filter out empty properties
|
||||
contentType.Groups = contentType.Groups.Where(x => x.Name.IsNullOrWhiteSpace() == false).ToList();
|
||||
foreach (var group in contentType.Groups)
|
||||
{
|
||||
group.Properties = group.Properties.Where(x => x.Alias.IsNullOrWhiteSpace() == false).ToList();
|
||||
}
|
||||
|
||||
var ctId = Convert.ToInt32(contentType.Id);
|
||||
|
||||
if (ctId > 0)
|
||||
|
||||
@@ -36,7 +36,6 @@ namespace Umbraco.Web.Models.Mapping
|
||||
config.CreateMap<IMediaType, ContentTypeBasic>();
|
||||
config.CreateMap<IContentType, ContentTypeBasic>();
|
||||
|
||||
|
||||
config.CreateMap<ContentTypeDisplay, IContentType>()
|
||||
.ConstructUsing((ContentTypeDisplay source) => new ContentType(source.ParentId))
|
||||
|
||||
@@ -56,7 +55,8 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(dto => dto.PropertyGroups, expression => expression.Ignore())
|
||||
.AfterMap((source, dest) =>
|
||||
{
|
||||
foreach (var groupDisplay in source.Groups.Where(x => x.Name.IsNullOrWhiteSpace() == false ) )
|
||||
//get all properties from groups that are not generic properties (-666 id)
|
||||
foreach (var groupDisplay in source.Groups.Where(x => x.Id != -666))
|
||||
{
|
||||
//use underlying logic to add the property group which should wire most things up for us
|
||||
dest.AddPropertyGroup(groupDisplay.Name);
|
||||
@@ -70,6 +70,15 @@ namespace Umbraco.Web.Models.Mapping
|
||||
//dest.PropertyGroups.Add(Mapper.Map<PropertyGroup>(groupDisplay));
|
||||
}
|
||||
|
||||
//add generic properties
|
||||
var genericProperties = source.Groups.FirstOrDefault(x => x.Id == -666);
|
||||
if(genericProperties != null){
|
||||
foreach (var propertyTypeDisplay in genericProperties.Properties)
|
||||
{
|
||||
dest.AddPropertyType(Mapper.Map<PropertyType>(propertyTypeDisplay));
|
||||
}
|
||||
}
|
||||
|
||||
//Sync allowed child types
|
||||
var allowedTypes = source.AllowedContentTypes.Select((t, i) => new ContentTypeSort(t, i));
|
||||
|
||||
|
||||
@@ -39,6 +39,50 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(
|
||||
dto => dto.Groups,
|
||||
expression => expression.ResolveUsing(new PropertyTypeGroupResolver(applicationContext, _propertyEditorResolver)));
|
||||
|
||||
config.CreateMap<MemberTypeDisplay, IMemberType>()
|
||||
.ConstructUsing((MemberTypeDisplay source) => new MemberType(source.ParentId))
|
||||
|
||||
//only map id if set to something higher then zero
|
||||
.ForMember(dto => dto.Id, expression => expression.Condition(display => (Convert.ToInt32(display.Id) > 0)))
|
||||
.ForMember(dto => dto.Id, expression => expression.MapFrom(display => Convert.ToInt32(display.Id)))
|
||||
.ForMember(dto => dto.CreatorId, expression => expression.Ignore())
|
||||
.ForMember(dto => dto.Level, expression => expression.Ignore())
|
||||
.ForMember(dto => dto.SortOrder, expression => expression.Ignore())
|
||||
|
||||
//mapped in aftermap
|
||||
.ForMember(dto => dto.AllowedContentTypes, expression => expression.Ignore())
|
||||
|
||||
//ignore, we'll do this in after map
|
||||
.ForMember(dto => dto.PropertyGroups, expression => expression.Ignore())
|
||||
.AfterMap((source, dest) =>
|
||||
{
|
||||
//get all properties from groups that are not generic properties (-666 id)
|
||||
foreach (var groupDisplay in source.Groups.Where(x => x.Id != -666))
|
||||
{
|
||||
//use underlying logic to add the property group which should wire most things up for us
|
||||
dest.AddPropertyGroup(groupDisplay.Name);
|
||||
//now update that group with the values from the display object
|
||||
Mapper.Map(groupDisplay, dest.PropertyGroups[groupDisplay.Name]);
|
||||
|
||||
foreach (var propertyTypeDisplay in groupDisplay.Properties)
|
||||
{
|
||||
dest.AddPropertyType(Mapper.Map<PropertyType>(propertyTypeDisplay), groupDisplay.Name);
|
||||
}
|
||||
//dest.PropertyGroups.Add(Mapper.Map<PropertyGroup>(groupDisplay));
|
||||
}
|
||||
|
||||
//add generic properties
|
||||
var genericProperties = source.Groups.FirstOrDefault(x => x.Id == -666);
|
||||
if (genericProperties != null)
|
||||
{
|
||||
foreach (var propertyTypeDisplay in genericProperties.Properties)
|
||||
{
|
||||
dest.AddPropertyType(Mapper.Map<PropertyType>(propertyTypeDisplay));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,12 +90,13 @@ namespace Umbraco.Web.Models.Mapping
|
||||
|
||||
|
||||
//get all generic properties not already mapped to the generic props collection
|
||||
var ownGenericProperties = source.CompositionPropertyTypes.Where(x => x.PropertyGroupId == null && genericProperties.Any(y => y.Id == x.Id));
|
||||
var ownGenericProperties = source.CompositionPropertyTypes.Where(x => x.PropertyGroupId == null && !genericProperties.Any(y => y.Id == x.Id));
|
||||
genericProperties.AddRange(MapProperties(ownGenericProperties, source, 0, false));
|
||||
|
||||
if (genericProperties.Any())
|
||||
{
|
||||
var genericTab = new PropertyGroupDisplay() { Id = 0, Name = "Generic properties", ParentGroupId = 0, ContentTypeId = source.Id, SortOrder = 999, Inherited = false };
|
||||
var genericTab = new PropertyGroupDisplay() { Id = -666, Name = "Generic properties", ParentGroupId = 0, ContentTypeId = source.Id, SortOrder = 999, Inherited = false };
|
||||
genericTab.Properties = genericProperties;
|
||||
groups.Add(0, genericTab);
|
||||
}
|
||||
|
||||
@@ -145,7 +146,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
private IEnumerable<PropertyTypeDisplay> MapProperties(IEnumerable<PropertyType> properties, IContentTypeBase contentType, int groupId, bool inherited)
|
||||
{
|
||||
var mappedProperties = new List<PropertyTypeDisplay>();
|
||||
foreach (var p in properties)
|
||||
foreach (var p in properties.Where(x => x.DataTypeDefinitionId != 0) )
|
||||
{
|
||||
var editor = _propertyEditorResolver.Value.GetByAlias(p.PropertyEditorAlias);
|
||||
var preVals = _applicationContext.Services.DataTypeService.GetPreValuesCollectionByDataTypeId(p.DataTypeDefinitionId);
|
||||
|
||||
Reference in New Issue
Block a user