Ensures internal generic properties are all wired up in c# and fixes up the boolean editor, adds templatepicker html file so that something is rendered and there are no js errors.
This commit is contained in:
@@ -7,7 +7,12 @@
|
||||
/// </summary>
|
||||
public static class PropertyEditors
|
||||
{
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Used to prefix generic properties that are internal content properties
|
||||
/// </summary>
|
||||
public const string InternalGenericPropertiesPrefix = "_umb_";
|
||||
|
||||
/// <summary>
|
||||
/// Guid for the Checkbox list datatype.
|
||||
/// </summary>
|
||||
public const string CheckBoxList = "B4471851-82B6-4C75-AFA4-39FA9C6A75E9";
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
label: "Grid",
|
||||
id: 4,
|
||||
properties: [
|
||||
{ alias: "grid", label: "Grid", view: "grid", controller: "umbraco.grid", value: "test", hideLabel: true }
|
||||
{ alias: "grid", label: "Grid", view: "grid", value: "test", hideLabel: true }
|
||||
]
|
||||
}, {
|
||||
label: "Generic Properties",
|
||||
@@ -62,7 +62,7 @@
|
||||
{
|
||||
label: 'Created by',
|
||||
description: 'Original author',
|
||||
value: 1,
|
||||
value: "Administrator",
|
||||
view: "readonlyvalue",
|
||||
alias: "_umb_createdby"
|
||||
},
|
||||
@@ -71,9 +71,6 @@
|
||||
description: 'Time this document was created',
|
||||
value: new Date().toIsoDateTimeString(),
|
||||
view: "readonlyvalue",
|
||||
//NOTE: No need for filters because the date is a formatted string already because
|
||||
// that is how it comes from the server as a pre-formatted json string
|
||||
//config: {filter: 'date', format: 'medium'},
|
||||
alias: "_umb_createdate"
|
||||
},
|
||||
{
|
||||
@@ -99,10 +96,10 @@
|
||||
label: 'Template',
|
||||
value: "1234",
|
||||
view: "templatepicker",
|
||||
alias: "_umb_template"
|
||||
alias: "_umb_template"
|
||||
},
|
||||
{
|
||||
alias: "test", label: "Stuff", view: "test", controller: "umbraco.embeddedcontent", value: "",
|
||||
alias: "test", label: "Stuff", view: "test", value: "",
|
||||
config: {
|
||||
fields: [
|
||||
{ alias: "embedded", label: "Embbeded", view: "textstring", value: "" },
|
||||
|
||||
@@ -56,14 +56,14 @@ angular.module('umbraco.mocks').
|
||||
alias: "tab03",
|
||||
id: 3,
|
||||
properties: [
|
||||
{ alias: "grid", label: "Grid", view: "grid", controller: "umbraco.grid", value: "test", hideLabel: true }
|
||||
{ alias: "grid", label: "Grid", view: "grid", value: "test", hideLabel: true }
|
||||
]
|
||||
},{
|
||||
label: "WIP",
|
||||
alias: "tab04",
|
||||
id: 4,
|
||||
properties: [
|
||||
{ alias: "tes", label: "Stuff", view: "test", controller: "umbraco.embeddedcontent", value: "",
|
||||
{ alias: "tes", label: "Stuff", view: "test", value: "",
|
||||
|
||||
config: {
|
||||
fields: [
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
function booleanEditorController($scope, $rootScope, assetsService) {
|
||||
|
||||
$scope.renderModel = {
|
||||
value: false
|
||||
};
|
||||
if ($scope.model && $scope.model.value && ($scope.model.value.toString() === "1" || angular.lowercase($scope.model.value) === "true")) {
|
||||
$scope.renderModel.value = true;
|
||||
}
|
||||
|
||||
$scope.$watch("renderModel.value", function (newVal) {
|
||||
$scope.model.value = newVal === true ? "1" : "0";
|
||||
});
|
||||
|
||||
}
|
||||
angular.module("umbraco").controller("Umbraco.Editors.BooleanController", booleanEditorController);
|
||||
@@ -1 +1,3 @@
|
||||
<input type="checkbox" ng-model="model.value" ng-checked="{model.value == 1}" id="{{model.alias}} />
|
||||
<div ng-controller="Umbraco.Editors.BooleanController">
|
||||
<input type="checkbox" ng-model="renderModel.value" id="{{model.alias}" />
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<div class="span7">
|
||||
<h5>TODO: Implement this picker</h5>
|
||||
<div ng-model="model.value"></div>
|
||||
</div>
|
||||
@@ -17,6 +17,9 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
|
||||
[DataMember(Name = "publishDate")]
|
||||
public DateTime? PublishDate { get; set; }
|
||||
|
||||
[DataMember(Name = "template")]
|
||||
public string Template { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,12 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
Notifications = new List<Notification>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the content type
|
||||
/// </summary>
|
||||
[DataMember(Name = "contentTypeName")]
|
||||
public string ContentTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This is used to add custom localized messages/strings to the response for the app to use for localized UI purposes.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Mapping;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using umbraco;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Declares how model mappings for content
|
||||
/// </summary>
|
||||
@@ -15,6 +19,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
public override void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext)
|
||||
{
|
||||
|
||||
//FROM IContent TO ContentItemDisplay
|
||||
config.CreateMap<IContent, ContentItemDisplay>()
|
||||
.ForMember(
|
||||
@@ -29,11 +34,24 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(
|
||||
dto => dto.ContentTypeAlias,
|
||||
expression => expression.MapFrom(content => content.ContentType.Alias))
|
||||
.ForMember(
|
||||
dto => dto.ContentTypeName,
|
||||
expression => expression.MapFrom(content => content.ContentType.Name))
|
||||
.ForMember(
|
||||
dto => dto.PublishDate,
|
||||
expression => expression.MapFrom(content => GetPublishedDate(content, applicationContext)))
|
||||
.ForMember(
|
||||
dto => dto.Template,
|
||||
expression => expression.MapFrom(content => content.Template.Name))
|
||||
.ForMember(display => display.Properties, expression => expression.Ignore())
|
||||
.ForMember(display => display.Tabs, expression => expression.ResolveUsing<TabsAndPropertiesResolver>());
|
||||
.ForMember(display => display.Tabs, expression => expression.ResolveUsing<TabsAndPropertiesResolver>())
|
||||
.AfterMap((content, display) => TabsAndPropertiesResolver.MapGenericProperties(content, display, new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}doctype", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = "Template", //TODO: localize this?
|
||||
Value = display.Template,
|
||||
View = "templatepicker" //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor
|
||||
}));
|
||||
|
||||
//FROM IContent TO ContentItemBasic<ContentPropertyBasic, IContent>
|
||||
config.CreateMap<IContent, ContentItemBasic<ContentPropertyBasic, IContent>>()
|
||||
|
||||
@@ -29,9 +29,13 @@ namespace Umbraco.Web.Models.Mapping
|
||||
expression => expression.MapFrom(content => content.ContentType.Icon))
|
||||
.ForMember(
|
||||
dto => dto.ContentTypeAlias,
|
||||
expression => expression.MapFrom(content => content.ContentType.Alias))
|
||||
expression => expression.MapFrom(content => content.ContentType.Alias))
|
||||
.ForMember(
|
||||
dto => dto.ContentTypeName,
|
||||
expression => expression.MapFrom(content => content.ContentType.Name))
|
||||
.ForMember(display => display.Properties, expression => expression.Ignore())
|
||||
.ForMember(display => display.Tabs, expression => expression.ResolveUsing<TabsAndPropertiesResolver>());
|
||||
.ForMember(display => display.Tabs, expression => expression.ResolveUsing<TabsAndPropertiesResolver>())
|
||||
.AfterMap((media, display) => TabsAndPropertiesResolver.MapGenericProperties(media, display));
|
||||
|
||||
//FROM IMedia TO ContentItemBasic<ContentPropertyBasic, IMedia>
|
||||
config.CreateMap<IMedia, ContentItemBasic<ContentPropertyBasic, IMedia>>()
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using umbraco;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
@@ -11,6 +15,83 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// </summary>
|
||||
internal class TabsAndPropertiesResolver : ValueResolver<IContentBase, IEnumerable<Tab<ContentPropertyDisplay>>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Maps properties on to the generic properties tab
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="display"></param>
|
||||
/// <param name="customProperties">
|
||||
/// Any additional custom properties to assign to the generic properties tab.
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// The generic properties tab is mapped during AfterMap and is responsible for
|
||||
/// setting up the properties such as Created date, udpated date, template selected, etc...
|
||||
/// </remarks>
|
||||
public static void MapGenericProperties<TPersisted>(
|
||||
TPersisted content,
|
||||
ContentItemDisplayBase<ContentPropertyDisplay, TPersisted> display,
|
||||
params ContentPropertyDisplay[] customProperties)
|
||||
where TPersisted : IContentBase
|
||||
{
|
||||
var genericProps = display.Tabs.Single(x => x.Id == 0);
|
||||
|
||||
//store the current props to append to the newly inserted ones
|
||||
var currProps = genericProps.Properties.ToArray();
|
||||
|
||||
var labelEditor = PropertyEditorResolver.Current.GetById(new Guid(Constants.PropertyEditors.NoEdit)).ValueEditor.View;
|
||||
|
||||
var contentProps = new List<ContentPropertyDisplay>
|
||||
{
|
||||
new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}creator", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = ui.Text("content", "createBy"),
|
||||
Description = "Original author", //TODO: Localize this
|
||||
Value = display.Owner.Name,
|
||||
View = labelEditor
|
||||
},
|
||||
new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}createdate", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = ui.Text("content", "createDate"),
|
||||
Description = "Time this document was created", //TODO: Localize this
|
||||
Value = display.CreateDate.ToIsoString(),
|
||||
View = labelEditor
|
||||
},
|
||||
new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}updatedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = ui.Text("content", "updateDate"),
|
||||
Description = "Time this document was last updated", //TODO: Localize this
|
||||
Value = display.UpdateDate.ToIsoString(),
|
||||
View = labelEditor
|
||||
},
|
||||
new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}id", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = "Id",
|
||||
Value = display.Id.ToInvariantString(),
|
||||
View = labelEditor
|
||||
},
|
||||
new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}doctype", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = ui.Text("content", "documentType"),
|
||||
Value = display.ContentTypeName,
|
||||
View = labelEditor
|
||||
}
|
||||
};
|
||||
|
||||
//add the custom ones
|
||||
contentProps.AddRange(customProperties);
|
||||
|
||||
//now add the user props
|
||||
contentProps.AddRange(currProps);
|
||||
|
||||
//re-assign
|
||||
genericProps.Properties = contentProps;
|
||||
}
|
||||
|
||||
protected override IEnumerable<Tab<ContentPropertyDisplay>> ResolveCore(IContentBase content)
|
||||
{
|
||||
var aggregateTabs = new List<Tab<ContentPropertyDisplay>>();
|
||||
|
||||
10
src/Umbraco.Web/PropertyEditors/LabelPropertyEditor.cs
Normal file
10
src/Umbraco.Web/PropertyEditors/LabelPropertyEditor.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
[PropertyEditor(Constants.PropertyEditors.NoEdit, "Label", "readonlyvalue")]
|
||||
public class LabelPropertyEditor : PropertyEditor
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
|
||||
[PropertyEditor(Constants.PropertyEditors.Textbox, "Textstring", "textstring")]
|
||||
public class TextStringPropertyEditor : PropertyEditor
|
||||
{
|
||||
|
||||
@@ -300,6 +300,7 @@
|
||||
<Compile Include="Editors\ContentController.cs" />
|
||||
<Compile Include="Editors\EntityController.cs" />
|
||||
<Compile Include="Models\PagedResult.cs" />
|
||||
<Compile Include="PropertyEditors\LabelPropertyEditor.cs" />
|
||||
<Compile Include="WebApi\ControllerContextExtensions.cs" />
|
||||
<Compile Include="WebApi\CustomDateTimeConvertor.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentSortOrder.cs" />
|
||||
|
||||
Reference in New Issue
Block a user