diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/_utils.js b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/_utils.js index 57d3692df2..f8ecb582ea 100644 --- a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/_utils.js +++ b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/_utils.js @@ -59,6 +59,12 @@ label: "Generic Properties", id: 0, properties: [ + { + label: 'Id', + value: 1234, + view: "readonlyvalue", + alias: "_umb_id" + }, { label: 'Created by', description: 'Original author', @@ -68,36 +74,50 @@ }, { label: 'Created', - description: 'Time this document was created', + description: 'Date/time this document was created', value: new Date().toIsoDateTimeString(), view: "readonlyvalue", alias: "_umb_createdate" }, { label: 'Updated', - description: 'Time this document was last updated', + description: 'Date/time this document was created', value: new Date().toIsoDateTimeString(), view: "readonlyvalue", alias: "_umb_updatedate" - }, - { - label: 'Id', - value: 1234, - view: "readonlyvalue", - alias: "_umb_id" - }, + }, { label: 'Document Type', value: "Home page", view: "readonlyvalue", - alias: "_umb_doctype" + alias: "_umb_doctype" }, { - label: 'Template', - value: "1234", + label: 'Publish at', + description: 'Date/time to publish this document', + value: new Date().toIsoDateTimeString(), + view: "datepicker", + alias: "_umb_releasedate" + }, + { + label: 'Unpublish at', + description: 'Date/time to un-publish this document', + value: new Date().toIsoDateTimeString(), + view: "datepicker", + alias: "_umb_removedate" + }, + { + label: 'Template', + value: "1234", view: "templatepicker", alias: "_umb_template" }, + { + label: 'Link to document', + value: ["/testing" + id, "http://localhost/testing" + id, "http://mydomain.com/testing" + id].join(), + view: "urllist", + alias: "_umb_template" + }, { alias: "test", label: "Stuff", view: "test", value: "", config: { diff --git a/src/Umbraco.Web.UI.Client/src/views/content/edit.html b/src/Umbraco.Web.UI.Client/src/views/content/edit.html index 6097f57d6e..cb014917e2 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/edit.html @@ -1,4 +1,4 @@ - +
@@ -48,4 +48,4 @@ - +
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/readonlyvalue/readonlyvalue.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/readonlyvalue/readonlyvalue.controller.js index b5bfffe668..de258e25fb 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/readonlyvalue/readonlyvalue.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/readonlyvalue/readonlyvalue.controller.js @@ -1,8 +1,15 @@ angular.module('umbraco').controller("Umbraco.Editors.ReadOnlyValueController", function($rootScope, $scope, $filter){ - if ($scope.model.config && $scope.model.config.filter && $scope.model.config.format) { - $scope.displayvalue = $filter($scope.model.config.filter)($scope.model.value, $scope.model.config.filter); - }else{ + + if ($scope.model.config && $scope.model.config.filter) { + if ($scope.model.config.format) { + $scope.displayvalue = $filter($scope.model.config.filter)($scope.model.value, $scope.model.config.format); + } + else { + $scope.displayvalue = $filter($scope.model.config.filter)($scope.model.value); + } + } + else { $scope.displayvalue = $scope.model.value; } }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.controller.js new file mode 100644 index 0000000000..9abc45d2f3 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.controller.js @@ -0,0 +1,11 @@ +angular.module('umbraco').controller("Umbraco.Editors.UrlListController", + function($rootScope, $scope, $filter) { + + $scope.renderModel = _.map($scope.model.value.split(","), function(item) { + return { + url: item, + urlTarget : ($scope.config && $scope.config.target) ? $scope.config.target : "_blank" + }; + }); + + }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.html new file mode 100644 index 0000000000..7255b5832f --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.html @@ -0,0 +1,7 @@ +
+ +
\ No newline at end of file diff --git a/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplay.cs b/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplay.cs index ad961c4b50..5ca8ed6f6a 100644 --- a/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplay.cs +++ b/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplay.cs @@ -18,8 +18,17 @@ namespace Umbraco.Web.Models.ContentEditing [DataMember(Name = "publishDate")] public DateTime? PublishDate { get; set; } + [DataMember(Name = "releaseDate")] + public DateTime? ReleaseDate { get; set; } + + [DataMember(Name = "removeDate")] + public DateTime? RemoveDate { get; set; } + [DataMember(Name = "template")] public string Template { get; set; } + + [DataMember(Name = "urls")] + public string[] Urls { get; set; } } } \ No newline at end of file diff --git a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs index 3063d9b522..0c2ed6830b 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using AutoMapper; @@ -8,6 +9,7 @@ using Umbraco.Core.Models.Mapping; using Umbraco.Core.PropertyEditors; using Umbraco.Web.Models.ContentEditing; using umbraco; +using Umbraco.Web.Routing; namespace Umbraco.Web.Models.Mapping { @@ -40,18 +42,53 @@ namespace Umbraco.Web.Models.Mapping .ForMember( dto => dto.PublishDate, expression => expression.MapFrom(content => GetPublishedDate(content, applicationContext))) - .ForMember( + .ForMember( dto => dto.Template, expression => expression.MapFrom(content => content.Template.Name)) + .ForMember( + dto => dto.ReleaseDate, + expression => expression.MapFrom(content => content.ReleaseDate)) + .ForMember( + dto => dto.RemoveDate, + expression => expression.MapFrom(content => content.ExpireDate)) + .ForMember( + dto => dto.Urls, + expression => expression.MapFrom(content => + UmbracoContext.Current == null + ? new[] {"Cannot generate urls without a current Umbraco Context"} + : content.GetContentUrls())) .ForMember(display => display.Properties, expression => expression.Ignore()) .ForMember(display => display.Tabs, expression => expression.ResolveUsing()) - .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 - })); + .AfterMap((content, display) => TabsAndPropertiesResolver.MapGenericProperties( + content, display, + new ContentPropertyDisplay + { + Alias = string.Format("{0}releasedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = ui.Text("content", "releaseDate"), + Value = display.ReleaseDate.HasValue ? display.ReleaseDate.Value.ToIsoString() : null, + View = "datepicker" //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor + }, + new ContentPropertyDisplay + { + Alias = string.Format("{0}removedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = ui.Text("content", "removeDate"), + Value = display.RemoveDate.HasValue ? display.RemoveDate.Value.ToIsoString() : null, + View = "datepicker" //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor + }, + 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 + }, + new ContentPropertyDisplay + { + Alias = string.Format("{0}urls", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = ui.Text("content", "urls"), + Value = string.Join(",", display.Urls), + View = "urllist" //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor + })); //FROM IContent TO ContentItemBasic config.CreateMap>() diff --git a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs index 3f284f8a7b..26fc6f63cf 100644 --- a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs @@ -42,6 +42,13 @@ namespace Umbraco.Web.Models.Mapping var contentProps = new List { + new ContentPropertyDisplay + { + Alias = string.Format("{0}id", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = "Id", + Value = display.Id.ToInvariantString(), + View = labelEditor + }, new ContentPropertyDisplay { Alias = string.Format("{0}creator", Constants.PropertyEditors.InternalGenericPropertiesPrefix), @@ -54,7 +61,7 @@ namespace Umbraco.Web.Models.Mapping { Alias = string.Format("{0}createdate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), Label = ui.Text("content", "createDate"), - Description = "Time this document was created", //TODO: Localize this + Description = "Date/time this document was created", //TODO: Localize this Value = display.CreateDate.ToIsoString(), View = labelEditor }, @@ -62,17 +69,10 @@ namespace Umbraco.Web.Models.Mapping { Alias = string.Format("{0}updatedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), Label = ui.Text("content", "updateDate"), - Description = "Time this document was last updated", //TODO: Localize this + Description = "Date/time this document was created", //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), diff --git a/src/Umbraco.Web/Routing/UrlProvider.cs b/src/Umbraco.Web/Routing/UrlProvider.cs index 62d4142ec6..b8020ff04f 100644 --- a/src/Umbraco.Web/Routing/UrlProvider.cs +++ b/src/Umbraco.Web/Routing/UrlProvider.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; -using Umbraco.Core.Configuration; using Umbraco.Web.PublishedCache; +using UmbracoSettings = Umbraco.Core.Configuration.UmbracoSettings; namespace Umbraco.Web.Routing { diff --git a/src/Umbraco.Web/Routing/UrlProviderExtensions.cs b/src/Umbraco.Web/Routing/UrlProviderExtensions.cs new file mode 100644 index 0000000000..4bd1ac3c8c --- /dev/null +++ b/src/Umbraco.Web/Routing/UrlProviderExtensions.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using Umbraco.Core.Models; +using umbraco; + +namespace Umbraco.Web.Routing +{ + internal static class UrlProviderExtensions + { + /// + /// Gets the URLs for the content item + /// + /// + /// + /// + /// Use this when displaying URLs, if there are errors genertaing the urls the urls themselves will + /// contain the errors. + /// + public static IEnumerable GetContentUrls(this IContent content) + { + var urlProvider = UmbracoContext.Current.RoutingContext.UrlProvider; + var url = urlProvider.GetUrl(content.Id); + var urls = new List(); + if (url == "#") + { + // document as a published version yet it's url is "#" => a parent must be + // unpublished, walk up the tree until we find it, and report. + var parent = content; + do + { + parent = parent.ParentId > 0 ? content.Parent() : null; + } + while (parent != null && parent.Published); + + if (parent == null) // oops - internal error + urls.Add(ui.Text("content", "parentNotPublishedAnomaly", UmbracoContext.Current.Security.CurrentUser)); + else + urls.Add(ui.Text("content", "parentNotPublished", parent.Name, UmbracoContext.Current.Security.CurrentUser)); + } + else + { + urls.Add(url); + urls.AddRange(urlProvider.GetOtherUrls(content.Id)); + } + return urls; + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 52d20f9661..c75d8fe75f 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -301,6 +301,7 @@ +