Merge pull request #2294 from ja0b/U4-854
U4-854 Add MaxLength to Textstring fields --> Fixed
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
<div>
|
||||
<input name="numberField" class="umb-editor umb-number"
|
||||
type="number"
|
||||
ng-model="model.value"
|
||||
val-server="value"
|
||||
min="0"
|
||||
max="500"
|
||||
fix-number />
|
||||
|
||||
<span class="help-inline" val-msg-for="numberField" val-toggle-msg="number">Not a number</span>
|
||||
<span class="help-inline" val-msg-for="numberField" val-toggle-msg="valServer">{{propertyForm.requiredField.errorMsg}}</span>
|
||||
</div>
|
||||
@@ -1,37 +1,34 @@
|
||||
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.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
angular.module('umbraco').controller("Umbraco.PropertyEditors.textboxController", textboxController);
|
||||
angular.module('umbraco').controller("Umbraco.PropertyEditors.textboxController", textboxController);
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
val-server="value"
|
||||
ng-required="model.validation.mandatory"
|
||||
ng-trim="false"
|
||||
ng-keyup="model.change()" />
|
||||
ng-keyup="model.change()" />
|
||||
<span class="help-inline" val-msg-for="textbox" val-toggle-msg="valServer"></span>
|
||||
<span class="help-inline" val-msg-for="textbox" val-toggle-msg="required"><localize key="general_required">Required</localize></span>
|
||||
<div class="help" ng-if="model.maxlength">
|
||||
<strong>{{model.count}}</strong>
|
||||
<localize key="textbox_characters_left">characters left</localize>
|
||||
</div>
|
||||
</div>
|
||||
<div class="help">
|
||||
<strong>{{model.count}}</strong>
|
||||
<localize key="textbox_characters_left">characters left</localize>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user