From b2004057a50382e4ab45e3dcc2e851256d4fcf4d Mon Sep 17 00:00:00 2001 From: Claus Date: Fri, 9 Feb 2018 11:55:34 +0100 Subject: [PATCH 1/3] U4-10957 If RequiredSection is not defined in a tour - backoffice will throw errors --- src/Umbraco.Web/Editors/TourController.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web/Editors/TourController.cs b/src/Umbraco.Web/Editors/TourController.cs index da16659cfe..98a01f2c6e 100644 --- a/src/Umbraco.Web/Editors/TourController.cs +++ b/src/Umbraco.Web/Editors/TourController.cs @@ -70,14 +70,20 @@ namespace Umbraco.Web.Editors //Checking to see if the user has access to the required tour sections, else we remove the tour foreach (var backOfficeTourFile in result) { - foreach (var tour in backOfficeTourFile.Tours) + if (backOfficeTourFile.Tours != null) { - foreach (var toursRequiredSection in tour.RequiredSections) + foreach (var tour in backOfficeTourFile.Tours) { - if (allowedSections.Contains(toursRequiredSection) == false) + if (tour.RequiredSections != null) { - toursToBeRemoved.Add(backOfficeTourFile); - break; + foreach (var toursRequiredSection in tour.RequiredSections) + { + if (allowedSections.Contains(toursRequiredSection) == false) + { + toursToBeRemoved.Add(backOfficeTourFile); + break; + } + } } } } From 7019c9433be9d9fc3fe662e3a6cc967df36c5485 Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 23 Feb 2018 16:40:29 +1000 Subject: [PATCH 2/3] U4-10991 TourController Object reference not set to an instance of an object - when loading an invalid tour --- src/Umbraco.Web/Models/BackOfficeTour.cs | 5 +++++ src/Umbraco.Web/Models/BackOfficeTourFile.cs | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Models/BackOfficeTour.cs b/src/Umbraco.Web/Models/BackOfficeTour.cs index 78a4cd1897..268d5667f4 100644 --- a/src/Umbraco.Web/Models/BackOfficeTour.cs +++ b/src/Umbraco.Web/Models/BackOfficeTour.cs @@ -9,6 +9,11 @@ namespace Umbraco.Web.Models [DataContract(Name = "tour", Namespace = "")] public class BackOfficeTour { + public BackOfficeTour() + { + RequiredSections = new List(); + } + [DataMember(Name = "name")] public string Name { get; set; } [DataMember(Name = "alias")] diff --git a/src/Umbraco.Web/Models/BackOfficeTourFile.cs b/src/Umbraco.Web/Models/BackOfficeTourFile.cs index 7291a89ff4..6840171f48 100644 --- a/src/Umbraco.Web/Models/BackOfficeTourFile.cs +++ b/src/Umbraco.Web/Models/BackOfficeTourFile.cs @@ -9,6 +9,11 @@ namespace Umbraco.Web.Models [DataContract(Name = "tourFile", Namespace = "")] public class BackOfficeTourFile { + public BackOfficeTourFile() + { + Tours = new List(); + } + /// /// The file name for the tour /// @@ -27,4 +32,4 @@ namespace Umbraco.Web.Models [DataMember(Name = "tours")] public IEnumerable Tours { get; set; } } -} \ No newline at end of file +} From 1a590664e7a5dafd7627cd5d35243a865c518305 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 21 Mar 2018 12:32:27 +1100 Subject: [PATCH 3/3] Revert "Merge pull request #2502 from umbraco/temp-U4-11032" This reverts commit 2aa0dfb2c5a682d74eca8858f26bcfe563515a3f, reversing changes made to 2c6e7e46c219253040b38b246648d006cae10d54. --- src/Umbraco.Core/Constants-PropertyEditors.cs | 7 +- .../src/views/prevalueeditors/boolean.html | 2 +- .../dropdownFlexible.controller.js | 81 ------------------ .../dropdownFlexible/dropdownFlexible.html | 19 ----- .../DropDownMultiplePropertyEditor.cs | 4 +- .../DropDownMultipleWithKeysPropertyEditor.cs | 4 +- .../PropertyEditors/DropDownPropertyEditor.cs | 4 +- .../DropDownWithKeysPropertyEditor.cs | 4 +- .../DropdownFlexiblePropertyEditor.cs | 84 ------------------- src/Umbraco.Web/Umbraco.Web.csproj | 1 - 10 files changed, 10 insertions(+), 200 deletions(-) delete mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/dropdownFlexible/dropdownFlexible.controller.js delete mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/dropdownFlexible/dropdownFlexible.html delete mode 100644 src/Umbraco.Web/PropertyEditors/DropdownFlexiblePropertyEditor.cs diff --git a/src/Umbraco.Core/Constants-PropertyEditors.cs b/src/Umbraco.Core/Constants-PropertyEditors.cs index 43779ea44a..1f3986eeaf 100644 --- a/src/Umbraco.Core/Constants-PropertyEditors.cs +++ b/src/Umbraco.Core/Constants-PropertyEditors.cs @@ -122,11 +122,6 @@ namespace Umbraco.Core /// Alias for the Dropdown list, publishing keys datatype. /// public const string DropdownlistPublishingKeysAlias = "Umbraco.DropdownlistPublishingKeys"; - - /// - /// Alias for the "new" Dropdown list, that replaces the old four deprecated ones and works as other list based property editors - /// - public const string DropDownListFlexibleAlias = "Umbraco.DropDown.Flexible"; /// /// Guid for the Folder browser datatype. @@ -457,4 +452,4 @@ namespace Umbraco.Core } } } -} +} \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/boolean.html b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/boolean.html index 3e6be09650..8af17a18ea 100644 --- a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/boolean.html +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/boolean.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/dropdownFlexible/dropdownFlexible.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/dropdownFlexible/dropdownFlexible.controller.js deleted file mode 100644 index c7a472d80e..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/dropdownFlexible/dropdownFlexible.controller.js +++ /dev/null @@ -1,81 +0,0 @@ -angular.module("umbraco").controller("Umbraco.PropertyEditors.DropdownFlexibleController", - function($scope) { - - //setup the default config - var config = { - items: [], - multiple: false - }; - - //map the user config - angular.extend(config, $scope.model.config); - - //map back to the model - $scope.model.config = config; - - function convertArrayToDictionaryArray(model){ - //now we need to format the items in the dictionary because we always want to have an array - var newItems = []; - for (var i = 0; i < model.length; i++) { - newItems.push({ id: model[i], sortOrder: 0, value: model[i] }); - } - - return newItems; - } - - - function convertObjectToDictionaryArray(model){ - //now we need to format the items in the dictionary because we always want to have an array - var newItems = []; - var vals = _.values($scope.model.config.items); - var keys = _.keys($scope.model.config.items); - - for (var i = 0; i < vals.length; i++) { - var label = vals[i].value ? vals[i].value : vals[i]; - newItems.push({ id: keys[i], sortOrder: vals[i].sortOrder, value: label }); - } - - return newItems; - } - - $scope.updateSingleDropdownValue = function() { - $scope.model.value = [$scope.model.singleDropdownValue]; - } - - if (angular.isArray($scope.model.config.items)) { - //PP: I dont think this will happen, but we have tests that expect it to happen.. - //if array is simple values, convert to array of objects - if(!angular.isObject($scope.model.config.items[0])){ - $scope.model.config.items = convertArrayToDictionaryArray($scope.model.config.items); - } - } - else if (angular.isObject($scope.model.config.items)) { - $scope.model.config.items = convertObjectToDictionaryArray($scope.model.config.items); - } - else { - throw "The items property must be either an array or a dictionary"; - } - - - //sort the values - $scope.model.config.items.sort(function (a, b) { return (a.sortOrder > b.sortOrder) ? 1 : ((b.sortOrder > a.sortOrder) ? -1 : 0); }); - - //now we need to check if the value is null/undefined, if it is we need to set it to "" so that any value that is set - // to "" gets selected by default - if ($scope.model.value === null || $scope.model.value === undefined) { - if ($scope.model.config.multiple) { - $scope.model.value = []; - } - else { - $scope.model.value = ""; - } - } - - // if we run in single mode we'll store the value in a local variable - // so we can pass an array as the model as our PropertyValueEditor expects that - $scope.model.singleDropdownValue = ""; - if ($scope.model.config.multiple === "0") { - $scope.model.singleDropdownValue = Array.isArray($scope.model.value) ? $scope.model.value[0] : $scope.model.value; - } - - }); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/dropdownFlexible/dropdownFlexible.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/dropdownFlexible/dropdownFlexible.html deleted file mode 100644 index a68a614ad1..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/dropdownFlexible/dropdownFlexible.html +++ /dev/null @@ -1,19 +0,0 @@ -
- - - - - -
diff --git a/src/Umbraco.Web/PropertyEditors/DropDownMultiplePropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DropDownMultiplePropertyEditor.cs index 5cfd745d62..a4dfd6c2ad 100644 --- a/src/Umbraco.Web/PropertyEditors/DropDownMultiplePropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DropDownMultiplePropertyEditor.cs @@ -15,7 +15,7 @@ namespace Umbraco.Web.PropertyEditors [ParameterEditor("propertyTypePickerMultiple", "Name", "textbox")] [ParameterEditor("contentTypeMultiple", "Name", "textbox")] [ParameterEditor("tabPickerMultiple", "Name", "textbox")] - [PropertyEditor(Constants.PropertyEditors.DropDownListMultipleAlias, "Dropdown list multiple", "dropdown", Group = "lists", Icon="icon-bulleted-list", IsDeprecated = true)] + [PropertyEditor(Constants.PropertyEditors.DropDownListMultipleAlias, "Dropdown list multiple", "dropdown", Group = "lists", Icon="icon-bulleted-list")] public class DropDownMultiplePropertyEditor : DropDownMultipleWithKeysPropertyEditor { protected override PropertyValueEditor CreateValueEditor() @@ -28,4 +28,4 @@ namespace Umbraco.Web.PropertyEditors -} +} \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/DropDownMultipleWithKeysPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DropDownMultipleWithKeysPropertyEditor.cs index ac28379f0d..05ba3e2644 100644 --- a/src/Umbraco.Web/PropertyEditors/DropDownMultipleWithKeysPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DropDownMultipleWithKeysPropertyEditor.cs @@ -12,7 +12,7 @@ namespace Umbraco.Web.PropertyEditors /// Due to maintaining backwards compatibility this data type stores the value as a string which is a comma separated value of the /// ids of the individual items so we have logic in here to deal with that. /// - [PropertyEditor(Constants.PropertyEditors.DropdownlistMultiplePublishKeysAlias, "Dropdown list multiple, publish keys", "dropdown", Group = "lists", Icon = "icon-bulleted-list", IsDeprecated = true)] + [PropertyEditor(Constants.PropertyEditors.DropdownlistMultiplePublishKeysAlias, "Dropdown list multiple, publish keys", "dropdown", Group = "lists", Icon = "icon-bulleted-list")] public class DropDownMultipleWithKeysPropertyEditor : DropDownPropertyEditor { protected override PropertyValueEditor CreateValueEditor() @@ -62,4 +62,4 @@ namespace Umbraco.Web.PropertyEditors } } -} +} \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/DropDownPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DropDownPropertyEditor.cs index 4c9b0ae99a..115b99dea4 100644 --- a/src/Umbraco.Web/PropertyEditors/DropDownPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DropDownPropertyEditor.cs @@ -16,7 +16,7 @@ namespace Umbraco.Web.PropertyEditors /// as INT and we have logic in here to ensure it is formatted correctly including ensuring that the string value is published /// in cache and not the int ID. /// - [PropertyEditor(Constants.PropertyEditors.DropDownListAlias, "Dropdown list", "dropdown", ValueType = PropertyEditorValueTypes.String, Group = "lists", Icon = "icon-indent", IsDeprecated = true)] + [PropertyEditor(Constants.PropertyEditors.DropDownListAlias, "Dropdown list", "dropdown", ValueType = PropertyEditorValueTypes.String, Group = "lists", Icon = "icon-indent")] public class DropDownPropertyEditor : DropDownWithKeysPropertyEditor { /// @@ -29,4 +29,4 @@ namespace Umbraco.Web.PropertyEditors } } -} +} \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/DropDownWithKeysPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DropDownWithKeysPropertyEditor.cs index 4e8efd93a5..a33115003c 100644 --- a/src/Umbraco.Web/PropertyEditors/DropDownWithKeysPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DropDownWithKeysPropertyEditor.cs @@ -11,7 +11,7 @@ namespace Umbraco.Web.PropertyEditors /// as INT and we have logic in here to ensure it is formatted correctly including ensuring that the INT ID value is published /// in cache and not the string value. /// - [PropertyEditor(Constants.PropertyEditors.DropdownlistPublishingKeysAlias, "Dropdown list, publishing keys", "dropdown", ValueType = PropertyEditorValueTypes.Integer, Group = "lists", Icon = "icon-indent", IsDeprecated = true)] + [PropertyEditor(Constants.PropertyEditors.DropdownlistPublishingKeysAlias, "Dropdown list, publishing keys", "dropdown", ValueType = PropertyEditorValueTypes.Integer, Group = "lists", Icon = "icon-indent")] public class DropDownWithKeysPropertyEditor : PropertyEditor { @@ -24,4 +24,4 @@ namespace Umbraco.Web.PropertyEditors return new ValueListPreValueEditor(); } } -} +} \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/DropdownFlexiblePropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DropdownFlexiblePropertyEditor.cs deleted file mode 100644 index 236aa273c3..0000000000 --- a/src/Umbraco.Web/PropertyEditors/DropdownFlexiblePropertyEditor.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; -using Umbraco.Core; -using Umbraco.Core.Models; -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Web.PropertyEditors -{ - [PropertyEditor(Constants.PropertyEditors.DropDownListFlexibleAlias, "Dropdown", "dropdownFlexible", Group = "lists", Icon = "icon-indent")] - public class DropdownFlexiblePropertyEditor : PropertyEditor - { - private static readonly string _multipleKey = "multiple"; - - /// - /// Return a custom pre-value editor - /// - /// - /// - /// We are just going to re-use the ValueListPreValueEditor - /// - protected override PreValueEditor CreatePreValueEditor() - { - return new DropdownFlexiblePreValueEditor(); - } - - /// - /// We need to override the value editor so that we can ensure the string value is published in cache and not the integer ID value. - /// - /// - protected override PropertyValueEditor CreateValueEditor() - { - return new PublishValuesMultipleValueEditor(false, base.CreateValueEditor()); - } - - internal class DropdownFlexiblePreValueEditor : ValueListPreValueEditor - { - public DropdownFlexiblePreValueEditor() - { - Fields.Insert(0, new PreValueField - { - Key = "multiple", - Name = "Enable multiple choice", - Description = "When checked, the dropdown will be a select multiple / combo box style dropdown", - View = "boolean" - }); - } - - public override IDictionary ConvertEditorToDb(IDictionary editorValue, PreValueCollection currentValue) - { - - var result = base.ConvertEditorToDb(editorValue, currentValue); - - // get multiple config - var multipleValue = editorValue[_multipleKey] != null ? editorValue[_multipleKey].ToString() : "0"; - result.Add(_multipleKey, new PreValue(-1, multipleValue)); - - return result; - } - - public override IDictionary ConvertDbToEditor(IDictionary defaultPreVals, PreValueCollection persistedPreVals) - { - // weird way, but as the value stored is 0 or 1 need to do it this way - string multipleMode = "0"; - if (persistedPreVals != null && persistedPreVals.PreValuesAsDictionary[_multipleKey] != null) - { - multipleMode = persistedPreVals.PreValuesAsDictionary[_multipleKey].Value; - - // remove from the collection sent to the base multiple values collection - persistedPreVals.PreValuesAsDictionary.Remove(_multipleKey); - } - - var returnVal = base.ConvertDbToEditor(defaultPreVals, persistedPreVals); - - returnVal[_multipleKey] = multipleMode; - return returnVal; - } - - } - } -} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index d11475c0fb..c6d528bb3d 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -337,7 +337,6 @@ -