Only show characters left is a number of characters is configured on the datatype, hide otherwise
This commit is contained in:
committed by
Sebastiaan Janssen
parent
51fec0c7d3
commit
b1ceeb23b3
@@ -5,12 +5,20 @@ function textboxController($scope) {
|
||||
$scope.model.config = {};
|
||||
}
|
||||
|
||||
$scope.model.maxlength = false;
|
||||
if ($scope.model.config && $scope.model.config.maxChars) {
|
||||
$scope.model.maxlength = true;
|
||||
}
|
||||
|
||||
if (!$scope.model.config.maxChars) {
|
||||
// 500 is the maximum number that can be stored
|
||||
// in the database, so set it to the max, even
|
||||
// if no max is specified in the config
|
||||
$scope.model.config.maxChars = 500;
|
||||
}
|
||||
|
||||
if ($scope.model.config && $scope.model.config.maxChars) {
|
||||
if ($scope.model.value == undefined) {
|
||||
if ($scope.model.maxlength) {
|
||||
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;
|
||||
@@ -19,7 +27,7 @@ function textboxController($scope) {
|
||||
|
||||
$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;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
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">
|
||||
<div class="help" ng-if="model.maxlength">
|
||||
<strong>{{model.count}}</strong>
|
||||
<localize key="textbox_characters_left">characters left</localize>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user