diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/insertmacro.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/insertmacro.controller.js index 6b46dcd6d8..c132d3af2e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/insertmacro.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/insertmacro.controller.js @@ -136,7 +136,16 @@ function InsertMacroController($scope, entityResource, macroResource, umbPropEdi entityResource.getAll("Macro", ($scope.dialogData && $scope.dialogData.richTextEditor && $scope.dialogData.richTextEditor === true) ? "UseInEditor=true" : null) .then(function (data) { - $scope.macros = data; + //if 'allowedMacros' is specified, we need to filter + if (angular.isArray($scope.dialogData.allowedMacros) && $scope.dialogData.allowedMacros.length > 0) { + $scope.macros = _.filter(data, function(d) { + return _.contains($scope.dialogData.allowedMacros, d.alias); + }); + } + else { + $scope.macros = data; + } + //check if there's a pre-selected macro and if it exists if ($scope.dialogData && $scope.dialogData.macroData && $scope.dialogData.macroData.macroAlias) { diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/insertmacro.html b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/insertmacro.html index 16c6d6fcc3..c71b70faf8 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/insertmacro.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/insertmacro.html @@ -15,7 +15,11 @@
- diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.controller.js index c18b3c5610..6dc3e41cd4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.controller.js @@ -2,7 +2,7 @@ angular.module('umbraco') .controller("Umbraco.PropertyEditors.MacroContainerController", - function($scope, dialogService, entityResource, macroService, macroResource){ + function($scope, dialogService, entityResource, macroService){ $scope.renderModel = []; if($scope.model.value){ @@ -35,11 +35,13 @@ angular.module('umbraco') } function openDialog(index){ - var dialogData = {}; + var dialogData = { + allowedMacros: $scope.model.config.allowed + }; if(index !== null && $scope.renderModel[index]) { var macro = $scope.renderModel[index]; - dialogData = {macroData: macro}; + dialogData[macroData] = macro; } dialogService.macroPicker({ diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrolist.prevalues.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrolist.prevalues.controller.js new file mode 100644 index 0000000000..ffede2abd4 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrolist.prevalues.controller.js @@ -0,0 +1,15 @@ +function MacroListController($scope, entityResource) { + + $scope.items = []; + + entityResource.getAll("Macro").then(function(items) { + _.each(items, function(i) { + $scope.items.push({ name: i.name, alias: i.alias }); + }); + + }); + + +} + +angular.module("umbraco").controller("Umbraco.PrevalueEditors.MacroList", MacroListController); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrolist.prevalues.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrolist.prevalues.html new file mode 100644 index 0000000000..d0081e7bc2 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrolist.prevalues.html @@ -0,0 +1,7 @@ +
+ + + +
\ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs index 686d248b4b..6d24c9960d 100644 --- a/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs @@ -12,6 +12,15 @@ namespace Umbraco.Web.PropertyEditors [PropertyEditor(Constants.PropertyEditors.MacroContainerAlias, "Macro container", "macrocontainer")] public class MacroContainerPropertyEditor : PropertyEditor { + /// + /// Creates a pre value editor instance + /// + /// + protected override PreValueEditor CreatePreValueEditor() + { + return new MacroContainerPreValueEditor(); + } + protected override PropertyValueEditor CreateValueEditor() { //TODO: Need to add some validation to the ValueEditor to ensure that any media chosen actually exists! @@ -19,5 +28,14 @@ namespace Umbraco.Web.PropertyEditors return base.CreateValueEditor(); } + internal class MacroContainerPreValueEditor : PreValueEditor + { + [PreValueField("max", "Max items", "number", Description = "The maximum number of macros that are allowed in the container")] + public int MaxItems { get; set; } + + [PreValueField("allowed", "Allowed items", "views/propertyeditors/macrocontainer/macrolist.prevalues.html", Description = "The macro types allowed, if none are selected all macros will be allowed")] + public object AllowedItems { get; set; } + } + } } diff --git a/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs b/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs index b8d6d0bc91..1a4cafbc42 100644 --- a/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs +++ b/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs @@ -59,8 +59,7 @@ namespace Umbraco.Web.Scheduling wc.Headers.Set("Authorization", AdminTokenAuthorizeAttribute.GetAuthHeaderTokenVal(_appContext)); var result = wc.UploadString(url, ""); - } - } + } } } catch (Exception ee) diff --git a/src/Umbraco.Web/Trees/ApplicationTreeRegistrar.cs b/src/Umbraco.Web/Trees/ApplicationTreeRegistrar.cs index 1b125bce63..60ea0aabd8 100644 --- a/src/Umbraco.Web/Trees/ApplicationTreeRegistrar.cs +++ b/src/Umbraco.Web/Trees/ApplicationTreeRegistrar.cs @@ -53,16 +53,14 @@ namespace Umbraco.Web.Trees //convert them to ApplicationTree instances var legacyItems = legacyTreeTypes .Select(x => - new Tuple( - new Tuple( - x, - x.GetCustomAttributes(false).SingleOrDefault(), - x.GetCustomAttributes(false).SingleOrDefault())) - x.GetCustomAttributes(false).SingleOrDefault())) - //ensure that the legacy tree attribute exists + new Tuple( + x, + x.GetCustomAttributes(false).SingleOrDefault(), + x.GetCustomAttributes(false).SingleOrDefault())) + //ensure that the legacy tree attribute exists .Where(x => x.Item2 != null) - //ensure that it's not obsoleted, any obsoleted tree will not be auto added to the config - .Where(x => x.Item3 == null) + //ensure that it's not obsoleted, any obsoleted tree will not be auto added to the config + .Where(x => x.Item3 == null) //make sure the legacy tree isn't added on top of the controller tree! .Where(x => added.InvariantContains(x.Item2.Alias) == false) .Select(x => new ApplicationTree(x.Item2.Initialize, x.Item2.SortOrder, x.Item2.ApplicationAlias, x.Item2.Alias, x.Item2.Title, x.Item2.IconClosed, x.Item2.IconOpen, x.Item1.GetFullNameWithAssembly())); diff --git a/src/UmbracoExamine/UmbracoMemberIndexer.cs b/src/UmbracoExamine/UmbracoMemberIndexer.cs index 6ab7e6d9fd..d23ff26751 100644 --- a/src/UmbracoExamine/UmbracoMemberIndexer.cs +++ b/src/UmbracoExamine/UmbracoMemberIndexer.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Specialized; using System.Linq; using System.Xml.Linq; using Examine.LuceneEngine.Config; @@ -13,7 +12,6 @@ using Examine; using System.IO; using UmbracoExamine.DataServices; using Lucene.Net.Analysis; -using Member = umbraco.cms.businesslogic.member.Member; namespace UmbracoExamine {