From 27115e579429ae282ab9175a248b6836c6ef8cdd Mon Sep 17 00:00:00 2001 From: Alejandro Ocampo Date: Thu, 2 Nov 2017 17:14:13 +0100 Subject: [PATCH 1/6] U4-854 Add MaxLength to Textstring fields --> Fixed --- .../prevalueeditors/textstringnumber.html | 12 +++++++++++ .../textbox/textbox.controller.js | 21 +++++++++++-------- .../propertyeditors/textbox/textbox.html | 10 ++++----- .../PropertyEditors/TextboxPropertyEditor.cs | 7 +++---- 4 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textstringnumber.html diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textstringnumber.html b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textstringnumber.html new file mode 100644 index 0000000000..5409741ca5 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textstringnumber.html @@ -0,0 +1,12 @@ +
+ + + Not a number + {{propertyForm.requiredField.errorMsg}} +
\ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js index 3bb909c717..5ab37fcb65 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js @@ -1,33 +1,36 @@ function textboxController($scope) { - // macro parameter editor doesn't contains a config object, - // so we create a new one to hold any properties + // so we create a new one to hold any properties if (!$scope.model.config) { $scope.model.config = {}; } if (!$scope.model.config.maxChars) { - $scope.model.config.maxChars = false; + $scope.model.config.maxChars = 500; } - $scope.model.maxlength = false; if ($scope.model.config && $scope.model.config.maxChars) { - $scope.model.maxlength = true; - if($scope.model.value == undefined) { + if ($scope.model.config.maxChars < 500) { + $scope.model.showcharacterslefttext = true; + } else { + $scope.model.showcharacterslefttext = false; + } + + if ($scope.model.value == undefined) { $scope.model.count = ($scope.model.config.maxChars * 1); } else { $scope.model.count = ($scope.model.config.maxChars * 1) - $scope.model.value.length; } } - $scope.model.change = function() { + $scope.model.change = function () { if ($scope.model.config && $scope.model.config.maxChars) { - if($scope.model.value == undefined) { + if ($scope.model.value == undefined) { $scope.model.count = ($scope.model.config.maxChars * 1); } else { $scope.model.count = ($scope.model.config.maxChars * 1) - $scope.model.value.length; } - if($scope.model.count < 0) { + if ($scope.model.count < 0) { $scope.model.value = $scope.model.value.substring(0, ($scope.model.config.maxChars * 1)); $scope.model.count = 0; } diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html index d8c51ce9e0..c409048096 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html @@ -4,11 +4,11 @@ val-server="value" ng-required="model.validation.mandatory" ng-trim="false" - ng-keyup="model.change()" /> + ng-keyup="model.change()" /> Required -
- {{model.count}} - characters left -
+
+ {{model.count}} + characters left +
\ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs index bd07d503fa..d36e7a5ad5 100644 --- a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs @@ -24,9 +24,8 @@ namespace Umbraco.Web.PropertyEditors internal class TextboxPreValueEditor : PreValueEditor { - [PreValueField("maxChars", "Maximum allowed characters", "number", Description = "If empty - no character limit")] + [PreValueField("maxChars", "Maximum allowed characters", "textstringnumber", Description = "If empty - 500 character limit")] public bool MaxChars { get; set; } - } - + } } -} +} \ No newline at end of file From 29f93160b7d791697af19dbe2db643b27b7a66c1 Mon Sep 17 00:00:00 2001 From: Alejandro Ocampo Date: Fri, 3 Nov 2017 11:51:39 +0100 Subject: [PATCH 2/6] removing unnecessary if statement --- .../src/views/propertyeditors/textbox/textbox.controller.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js index 5ab37fcb65..e88f118c49 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js @@ -10,11 +10,7 @@ function textboxController($scope) { } if ($scope.model.config && $scope.model.config.maxChars) { - if ($scope.model.config.maxChars < 500) { - $scope.model.showcharacterslefttext = true; - } else { - $scope.model.showcharacterslefttext = false; - } + $scope.model.showcharacterslefttext = $scope.model.config.maxChars < 500; if ($scope.model.value == undefined) { $scope.model.count = ($scope.model.config.maxChars * 1); From d1b7063e442df85ae67137946fd78d8e081d6c9f Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 6 Nov 2017 17:02:08 +0100 Subject: [PATCH 3/6] Rename textstringnumber.html to textstringlimited.html --- .../{textstringnumber.html => textstringlimited.html} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/Umbraco.Web.UI.Client/src/views/prevalueeditors/{textstringnumber.html => textstringlimited.html} (98%) diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textstringnumber.html b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textstringlimited.html similarity index 98% rename from src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textstringnumber.html rename to src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textstringlimited.html index 5409741ca5..d91013a76f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textstringnumber.html +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textstringlimited.html @@ -9,4 +9,4 @@ Not a number {{propertyForm.requiredField.errorMsg}} - \ No newline at end of file + From db51a5bb44512e72ceb065affd3a3cdc9f4a9ce4 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 6 Nov 2017 17:02:34 +0100 Subject: [PATCH 4/6] Update TextboxPropertyEditor.cs --- src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs index d36e7a5ad5..72748c17ed 100644 --- a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs @@ -24,8 +24,8 @@ namespace Umbraco.Web.PropertyEditors internal class TextboxPreValueEditor : PreValueEditor { - [PreValueField("maxChars", "Maximum allowed characters", "textstringnumber", Description = "If empty - 500 character limit")] + [PreValueField("maxChars", "Maximum allowed characters", "textstringlimited", Description = "If empty - 500 character limit")] public bool MaxChars { get; set; } } } -} \ No newline at end of file +} From 0231a6037e80e0ee149385c2b5eb9f6559c9ccc1 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 6 Nov 2017 17:03:23 +0100 Subject: [PATCH 5/6] Always show number of characters left Makes it less magical as to why you can't type any more characters. --- .../src/views/propertyeditors/textbox/textbox.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html index c409048096..a386bd38b9 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html @@ -7,8 +7,8 @@ ng-keyup="model.change()" /> Required -
+
{{model.count}} characters left
-
\ No newline at end of file + From 4f2650277aa61cc1012240525856b60fc3ec68df Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 6 Nov 2017 17:07:14 +0100 Subject: [PATCH 6/6] Don't need `showcharacterslefttext` if we're always showing number of chars left --- .../src/views/propertyeditors/textbox/textbox.controller.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js index e88f118c49..2d0515d764 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js @@ -10,8 +10,6 @@ function textboxController($scope) { } if ($scope.model.config && $scope.model.config.maxChars) { - $scope.model.showcharacterslefttext = $scope.model.config.maxChars < 500; - if ($scope.model.value == undefined) { $scope.model.count = ($scope.model.config.maxChars * 1); } else { @@ -33,4 +31,4 @@ function textboxController($scope) { } } } -angular.module('umbraco').controller("Umbraco.PropertyEditors.textboxController", textboxController); \ No newline at end of file +angular.module('umbraco').controller("Umbraco.PropertyEditors.textboxController", textboxController);