From 02b6b77d38a9c8c632a5d6b93ef8e06cac5eca7a Mon Sep 17 00:00:00 2001 From: ashallcross <1766330+ashallcross@users.noreply.github.com> Date: Tue, 31 Jul 2018 09:39:51 +0100 Subject: [PATCH 01/11] Updated links in readme file (#2822) Updated the links from our.umbraco.org > our.umbraco.com also the case study and cloud links --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 067a4b83d0..5316ad0604 100644 --- a/docs/README.md +++ b/docs/README.md @@ -46,6 +46,6 @@ Umbraco is contribution focused and community driven. If you want to contribute ## Found a bug? -Another way you can contribute to Umbraco is by providing issue reports. For information on how to submit an issue report refer to our [online guide for reporting issues](https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/docs/CONTRIBUTING.md). +Another way you can contribute to Umbraco is by providing issue reports. For information on how to submit an issue report refer to our [online guide for reporting issues](CONTRIBUTING_DETAILED.md#reporting-bugs). To view existing issues, please visit [http://issues.umbraco.org](http://issues.umbraco.org). From 80db20fdfb1575b5665b82fa108ceae4cd11ea0d Mon Sep 17 00:00:00 2001 From: Warren Date: Tue, 31 Jul 2018 11:18:24 +0100 Subject: [PATCH 02/11] Fix up failing JS unit test from a recent change from V8 hackathon to the query builder syntax (was curly's on new lines) --- .../unit/common/services/template-helper.spec.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/test/unit/common/services/template-helper.spec.js b/src/Umbraco.Web.UI.Client/test/unit/common/services/template-helper.spec.js index 0ccc9ab1dc..08a69b7e80 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/common/services/template-helper.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/common/services/template-helper.spec.js @@ -58,13 +58,14 @@ describe('service: templateHelper', function () { it('should return the snippet for a query', function () { var queryExpression = "queryExpression"; var snippet = "\n@{\n" + "\tvar selection = " + queryExpression + ";\n}\n"; - snippet += "\n\n"; + snippet += "\n\n"; expect(templateHelper.getQuerySnippet(queryExpression)).toBe(snippet); }); From f30171bcfda3862404b200a0efe8577c6b280c8c Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 31 Jul 2018 10:09:40 +0200 Subject: [PATCH 03/11] Cleanup filenames --- .../{Settings1.Designer.cs => Settings.Designer.cs} | 4 ++-- src/Umbraco.Web/Properties/Settings.settings | 2 +- src/Umbraco.Web/Umbraco.Web.csproj | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename src/Umbraco.Web/Properties/{Settings1.Designer.cs => Settings.Designer.cs} (98%) diff --git a/src/Umbraco.Web/Properties/Settings1.Designer.cs b/src/Umbraco.Web/Properties/Settings.Designer.cs similarity index 98% rename from src/Umbraco.Web/Properties/Settings1.Designer.cs rename to src/Umbraco.Web/Properties/Settings.Designer.cs index 2f68c9774c..5a5a863f4f 100644 --- a/src/Umbraco.Web/Properties/Settings1.Designer.cs +++ b/src/Umbraco.Web/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace Umbraco.Web.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.6.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -44,7 +44,7 @@ namespace Umbraco.Web.Properties { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Somthing")] + [global::System.Configuration.DefaultSettingValueAttribute("Something")] public string test { get { return ((string)(this["test"])); diff --git a/src/Umbraco.Web/Properties/Settings.settings b/src/Umbraco.Web/Properties/Settings.settings index d6489e3251..757b363da2 100644 --- a/src/Umbraco.Web/Properties/Settings.settings +++ b/src/Umbraco.Web/Properties/Settings.settings @@ -9,7 +9,7 @@ http://update.umbraco.org/checkforupgrade.asmx - Somthing + Something https://our.umbraco.com/umbraco/webservices/api/repository.asmx diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 0da2704c6c..b71750fe2b 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -1204,7 +1204,7 @@ Code - + True True Settings.settings @@ -1524,7 +1524,7 @@ SettingsSingleFileGenerator - Settings1.Designer.cs + Settings.Designer.cs From 3c446a3ba004d3c548080c5c9f9b34171cae3782 Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 31 Jul 2018 12:23:06 +0200 Subject: [PATCH 04/11] Cleanup merge of Color Picker editor --- .../ColorListPreValueEditor.cs | 183 ------------------ .../ColorPickerConfigurationEditor.cs | 80 ++++++-- 2 files changed, 65 insertions(+), 198 deletions(-) delete mode 100644 src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs diff --git a/src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs b/src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs deleted file mode 100644 index 60785d283e..0000000000 --- a/src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Umbraco.Core; -using Umbraco.Core.Logging; -using Umbraco.Core.Models; -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Web.PropertyEditors -{ - internal class ColorListPreValueEditor : ValueListPreValueEditor - { - - public ColorListPreValueEditor() - { - var field = Fields.First(); - - //use a custom editor too - field.View = "views/propertyeditors/colorpicker/colorpicker.prevalues.html"; - //change the description - field.Description = "Add, remove or sort colors."; - //change the label - field.Name = "Colors"; - //need to have some custom validation happening here - field.Validators.Add(new ColorListValidator()); - - Fields.Insert(0, new PreValueField - { - Name = "Include labels?", - View = "boolean", - Key = "useLabel", - Description = "Stores colors as a Json object containing both the color hex string and label, rather than just the hex string." - }); - } - - public override IDictionary ConvertDbToEditor(IDictionary defaultPreVals, PreValueCollection persistedPreVals) - { - var dictionary = persistedPreVals.FormatAsDictionary(); - var items = dictionary.Where(x => x.Key != "useLabel") - .OrderBy(x => x.Value.SortOrder); - - var items2 = new Dictionary(); - foreach (var item in items) - { - var valueItem = new ColorPickerColor - { - Color = item.Value.Value, - Label = item.Value.Value, - SortOrder = item.Value.SortOrder - }; - - if (item.Value.Value.DetectIsJson()) - { - try - { - var valueObject = JsonConvert.DeserializeObject(item.Value.Value); - valueItem = new ColorPickerColor - { - Color = valueObject.Color, - Label = valueObject.Label, - SortOrder = valueObject.SortOrder - }; - } - catch - { - // let's say parsing Json failed, we'll not do anything, - // we'll just use the valueItem we built in the first place - } - } - - items2[item.Value.Id] = new JObject - { - { "value", valueItem.Color }, - { "label", valueItem.Label }, - { "sortOrder", valueItem.SortOrder } - }; - } - - var result = new Dictionary { { "items", items2 } }; - var useLabel = dictionary.ContainsKey("useLabel") && dictionary["useLabel"].Value == "1"; - if (useLabel) - result["useLabel"] = dictionary["useLabel"].Value; - - return result; - } - - public override IDictionary ConvertEditorToDb(IDictionary editorValue, PreValueCollection currentValue) - { - var val = editorValue["items"] as JArray; - var result = new Dictionary(); - if (val == null) return result; - - try - { - var useLabel = false; - if (editorValue.TryGetValue("useLabel", out var useLabelObj)) - { - useLabel = useLabelObj is string && (string) useLabelObj == "1"; - result["useLabel"] = new PreValue(useLabel ? "1" : "0"); - } - - // get all non-empty values - var index = 0; - // items get submitted in the sorted order, so just count them up - var sortOrder = -1; - foreach (var preValue in val.OfType() - .Where(x => x["value"] != null) - .Select(x => - { - var idString = x["id"] == null ? "0" : x["id"].ToString(); - int.TryParse(idString, out var id); - - var color = x["value"].ToString(); - if (string.IsNullOrWhiteSpace(color)) return null; - - var label = x["label"].ToString(); - - sortOrder++; - var value = useLabel - ? JsonConvert.SerializeObject(new { value = color, label = label, sortOrder = sortOrder }) - : color; - - return new PreValue(id, value, sortOrder); - }) - .WhereNotNull()) - { - result.Add(index.ToInvariantString(), preValue); - index++; - } - } - catch (Exception ex) - { - LogHelper.Error("Could not deserialize the posted value: " + val, ex); - } - - return result; - } - - internal class ColorListValidator : IPropertyValidator - { - public IEnumerable Validate(object value, PreValueCollection preValues, PropertyEditor editor) - { - var json = value as JArray; - if (json == null) yield break; - - //validate each item which is a json object - for (var index = 0; index < json.Count; index++) - { - var i = json[index]; - var jItem = i as JObject; - if (jItem == null || jItem["value"] == null) continue; - - //NOTE: we will be removing empty values when persisting so no need to validate - var asString = jItem["value"].ToString(); - if (asString.IsNullOrWhiteSpace()) continue; - - if (Regex.IsMatch(asString, "^([0-9a-f]{3}|[0-9a-f]{6})$", RegexOptions.IgnoreCase) == false) - { - yield return new ValidationResult("The value " + asString + " is not a valid hex color", new[] - { - //we'll make the server field the index number of the value so it can be wired up to the view - "item_" + index.ToInvariantString() - }); - } - } - } - } - } - - internal class ColorPickerColor - { - [JsonProperty("value")] - public string Color { get; set; } - [JsonProperty("label")] - public string Label { get; set; } - [JsonProperty("sortOrder")] - public int SortOrder { get; set; } - } -} diff --git a/src/Umbraco.Web/PropertyEditors/ColorPickerConfigurationEditor.cs b/src/Umbraco.Web/PropertyEditors/ColorPickerConfigurationEditor.cs index ddc4b50858..cbd4e69a9e 100644 --- a/src/Umbraco.Web/PropertyEditors/ColorPickerConfigurationEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ColorPickerConfigurationEditor.cs @@ -17,39 +17,85 @@ namespace Umbraco.Web.PropertyEditors // customize the items field items.View = "views/propertyeditors/colorpicker/colorpicker.prevalues.html"; - items.Description = "Add and remove colors"; - items.Name = "Add color"; + items.Description = "Add, remove or sort colors"; + items.Name = "Colors"; items.Validators.Add(new ColorListValidator()); } public override Dictionary ToConfigurationEditor(ColorPickerConfiguration configuration) { - var items = configuration?.Items.ToDictionary(x => x.Id.ToString(), x => GetItemValue(x, configuration.UseLabel)) ?? new object(); + var configuredItems = configuration?.Items; // ordered + object editorItems; + + if (configuredItems == null) + { + editorItems = new object(); + } + else + { + var d = new Dictionary(); + editorItems = d; + var sortOrder = 0; + foreach (var item in configuredItems) + d[item.Id.ToString()] = GetItemValue(item, configuration.UseLabel, sortOrder++); + } + var useLabel = configuration?.UseLabel ?? false; return new Dictionary { - { "items", items }, + { "items", editorItems }, { "useLabel", useLabel } }; } - private object GetItemValue(ValueListConfiguration.ValueListItem item, bool useLabel) + private object GetItemValue(ValueListConfiguration.ValueListItem item, bool useLabel, int sortOrder) { - if (useLabel) + // in: ValueListItem, Id = , Value = | { "value": "", "label": "