Commit c183ce019acc9691d22d66c295a4f23acd600eed
Exists in
master
Merge branch 'master' of http://ferramentasgo.centralit.com.br:8080/scm/git/cit-grp-corporativo
Showing
3 changed files
with
53 additions
and
66 deletions
Show diff stats
cit-portal-web/src/main/webapp/assets/js/angular/custom/directive/LabelInputDecimalDirective.js
... | ... | @@ -13,7 +13,8 @@ citApp.directive("labelInputDecimal", ["$translate", function($translate) { |
13 | 13 | model : "=ngModel", |
14 | 14 | form : "=form", |
15 | 15 | eventoChange : "&ngEventoChange", |
16 | - precisao : "=ngPrecisao", | |
16 | + eventoBlur: "=ngEventoBlur", | |
17 | + precisao : "@ngPrecisao", | |
17 | 18 | labelAlertTooltip: '@', |
18 | 19 | labelInfoTooltip: '@', |
19 | 20 | labelQuestionTooltip: '@', |
... | ... | @@ -23,8 +24,9 @@ citApp.directive("labelInputDecimal", ["$translate", function($translate) { |
23 | 24 | restrict : 'E', |
24 | 25 | template : "<div class='form-group' ng-class=\"{'has-error': form[id].$error.required && (!form[id].$pristine || form.$submitted)}\">" + |
25 | 26 | " <label for='{{id}}' class='control-label' ng-if='labelRender'><translate>{{label}}</translate> <span class='red' ng-show='obrigatorio'>*</span> <i ng-if='obrigatorio' ng-show='form[id].$error.required && (!form[id].$pristine || form.$submitted)' class='fa fa-warning red' tooltip='{{labelAlertTooltipCopy}}' tooltip-placement='top'></i> <i ng-if='labelInfoTooltipRender' class='fa fa-info-circle blue' tooltip='{{labelInfoTooltip}}' tooltip-placement='top'></i> <i ng-if='labelQuestionTooltipRender' class='fa fa-question-circle green' tooltip='{{labelQuestionTooltip}}' tooltip-placement='top'></i></label>"+ |
26 | - " <input type='text' class='form-control' ng-change='eventoChange()' ng-keydown='removeModel($event)' id='{{id}}' name='{{id}}' ng-model='model' ng-disabled='disabled' maxlength='{{maxlength ? maxlength : 23}}' ng-required='obrigatorio' ui-number-mask='precisao'/>" + | |
27 | + " <input type='text' class='form-control' ng-change='eventoChange()' ng-blur='eventoBlur()' ng-keydown='removeModel($event)' id='{{id}}' name='{{id}}' ng-model='model' ng-disabled='disabled' maxlength='{{maxlength ? maxlength : 23}}' ng-required='obrigatorio' ui-number-mask='{{precisao}}'/>" + | |
27 | 28 | "</div>", |
29 | + | |
28 | 30 | controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) { |
29 | 31 | if($scope.id === undefined){ |
30 | 32 | $scope.id = $attrs['ngModel']; | ... | ... |
cit-portal-web/src/main/webapp/assets/js/angular/custom/directive/MasksDirective.js
... | ... | @@ -13,7 +13,7 @@ var StringMask = (function() { |
13 | 13 | '9': {pattern: /\d/, optional: true}, |
14 | 14 | '#': {pattern: /\d/, optional: true, recursive: true}, |
15 | 15 | 'S': {pattern: /[a-zA-Z]/}, |
16 | - '$': {escape: true} | |
16 | + '$': {escape: true} | |
17 | 17 | }; |
18 | 18 | var isEscaped = function(pattern, pos) { |
19 | 19 | var count = 0; |
... | ... | @@ -24,7 +24,7 @@ var StringMask = (function() { |
24 | 24 | count += token && token.escape ? 1 : 0; |
25 | 25 | i--; |
26 | 26 | } |
27 | - return count > 0 && count%2 === 1; | |
27 | + return count > 0 && count%2 === 1; | |
28 | 28 | }; |
29 | 29 | var calcOptionalNumbersToUse = function(pattern, value) { |
30 | 30 | var numbersInP = pattern.replace(/[^0]/g,'').length; |
... | ... | @@ -189,7 +189,7 @@ var objectTypes = { |
189 | 189 | }; |
190 | 190 | |
191 | 191 | if (objectTypes[typeof module]) { |
192 | - module.exports = StringMask; | |
192 | + module.exports = StringMask; | |
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
... | ... | @@ -827,7 +827,7 @@ var objectTypes = { |
827 | 827 | 'object': true |
828 | 828 | }; |
829 | 829 | if (objectTypes[typeof module]) { |
830 | - module.exports = BrV; | |
830 | + module.exports = BrV; | |
831 | 831 | } else { |
832 | 832 | root.BrV = BrV; |
833 | 833 | } |
... | ... | @@ -1562,32 +1562,61 @@ angular.module('ui.utils.masks.number', []) |
1562 | 1562 | modelMask = NumberMasks.modelMask(decimals); |
1563 | 1563 | |
1564 | 1564 | function parse(value) { |
1565 | + | |
1565 | 1566 | if(!value) { |
1566 | 1567 | return value; |
1567 | 1568 | } |
1568 | 1569 | |
1569 | - var valueToFormat = PreFormatters.clearDelimitersAndLeadingZeros(value) || '0'; | |
1570 | - var formatedValue = viewMask.apply(valueToFormat); | |
1571 | - var actualNumber = parseFloat(modelMask.apply(valueToFormat)); | |
1570 | + if(attrs.uiNumberMask == 'decimal'){ | |
1571 | + | |
1572 | + var pos = value.indexOf(","); | |
1573 | + var result; | |
1574 | + if (pos !== -1) { | |
1575 | + var part1 = value.substr(0, pos > 6 ? 6 : pos); | |
1576 | + var part2 = value.substr(pos > 6 ? 6 : pos + 1); | |
1577 | + //2 casas decimais...... | |
1578 | + part2 = part2.substr(0,2); | |
1579 | + result = cleanForDecimal(part1) + "," + cleanForDecimal(part2); | |
1580 | + } else { | |
1581 | + result = cleanForDecimal(value).substr(0,6); | |
1582 | + } | |
1572 | 1583 | |
1573 | - if(angular.isDefined(attrs.uiNegativeNumber)){ | |
1574 | - var isNegative = (value[0] === '-'), | |
1575 | - needsToInvertSign = (value.slice(-1) === '-'); | |
1584 | + result = result ==',' ? '' : result; | |
1576 | 1585 | |
1577 | - //only apply the minus sign if it is negative or(exclusive) | |
1578 | - //needs to be negative and the number is different from zero | |
1579 | - if(needsToInvertSign ^ isNegative && !!actualNumber) { | |
1580 | - actualNumber *= -1; | |
1581 | - formatedValue = '-' + formatedValue; | |
1586 | + if (ctrl.$viewValue !== result) { | |
1587 | + ctrl.$setViewValue(result); | |
1588 | + ctrl.$render(); | |
1582 | 1589 | } |
1583 | - } | |
1584 | 1590 | |
1585 | - if (ctrl.$viewValue !== formatedValue) { | |
1586 | - ctrl.$setViewValue(formatedValue); | |
1587 | - ctrl.$render(); | |
1591 | + return result.length > 0 ? parseFloat(result.replace(',','.')) : 0; | |
1592 | + }else{ | |
1593 | + var valueToFormat = PreFormatters.clearDelimitersAndLeadingZeros(value) || '0'; | |
1594 | + var formatedValue = viewMask.apply(valueToFormat); | |
1595 | + var actualNumber = parseFloat(modelMask.apply(valueToFormat)); | |
1596 | + | |
1597 | + if(angular.isDefined(attrs.uiNegativeNumber)){ | |
1598 | + var isNegative = (value[0] === '-'), | |
1599 | + needsToInvertSign = (value.slice(-1) === '-'); | |
1600 | + | |
1601 | + //only apply the minus sign if it is negative or(exclusive) | |
1602 | + //needs to be negative and the number is different from zero | |
1603 | + if(needsToInvertSign ^ isNegative && !!actualNumber) { | |
1604 | + actualNumber *= -1; | |
1605 | + formatedValue = '-' + formatedValue; | |
1606 | + } | |
1607 | + } | |
1608 | + | |
1609 | + if (ctrl.$viewValue !== formatedValue) { | |
1610 | + ctrl.$setViewValue(formatedValue); | |
1611 | + ctrl.$render(); | |
1612 | + } | |
1613 | + | |
1614 | + return actualNumber; | |
1588 | 1615 | } |
1616 | + } | |
1589 | 1617 | |
1590 | - return actualNumber; | |
1618 | + function cleanForDecimal(string) { | |
1619 | + return string.replace(/[^0-9]/g, ""); | |
1591 | 1620 | } |
1592 | 1621 | |
1593 | 1622 | ctrl.$formatters.push(function(value) { | ... | ... |
cit-portal-web/src/main/webapp/html/configuracao/configuracao.html
... | ... | @@ -608,50 +608,6 @@ |
608 | 608 | <div class="row"> |
609 | 609 | <div class="col-sm-12"> |
610 | 610 | <div class="form-group"> |
611 | - <label-text-area ng-id="parametro.DEVERES_RESPONSABILIDADES_CONTRATANTE" | |
612 | - name="definicoesContrato.deveresResponsabilidadeContratante" | |
613 | - ng-model="parametro.DEVERES_RESPONSABILIDADES_CONTRATANTE" | |
614 | - ng-label="PORTAL.LABEL.DEVERES_RESPONSABILIDADES_CONTRATANTE" ng-custom-maxlength="100000" | |
615 | - ng-obrigatorio="false" form="definicoesContratoForm" ng-disabled="edit" rows="20"/> | |
616 | - </div><!-- .form-group --> | |
617 | - </div><!-- .col --> | |
618 | - </div><!-- .row --> | |
619 | - <div class="row"> | |
620 | - <div class="col-sm-12"> | |
621 | - <div class="form-group"> | |
622 | - <label-text-area ng-id="parametro.DEVERES_RESPONSABILIDADES_CONTRATADA" | |
623 | - name="definicoesContrato.deveresResponsabilidadeContratada" | |
624 | - ng-model="parametro.DEVERES_RESPONSABILIDADES_CONTRATADA" | |
625 | - ng-label="PORTAL.LABEL.DEVERES_RESPONSABILIDADES_CONTRATADA" ng-custom-maxlength="100000" | |
626 | - ng-obrigatorio="false" form="definicoesContratoForm" ng-disabled="edit" rows="20"/> | |
627 | - </div><!-- .form-group --> | |
628 | - </div><!-- .col --> | |
629 | - </div><!-- .row --> | |
630 | - <div class="row"> | |
631 | - <div class="col-sm-12"> | |
632 | - <div class="form-group"> | |
633 | - <label-text-area ng-id="parametro.DEVERES_RESPONSABILIDADES_ORGAO" | |
634 | - name="definicoesContrato.deveresResponsabilidadeOrgao" | |
635 | - ng-model="parametro.DEVERES_RESPONSABILIDADES_ORGAO" | |
636 | - ng-label="PORTAL.LABEL.DEVERES_RESPONSABILIDADES_ORGAO" ng-custom-maxlength="100000" | |
637 | - ng-obrigatorio="false" form="definicoesContratoForm" ng-disabled="edit" rows="20"/> | |
638 | - </div><!-- .form-group --> | |
639 | - </div><!-- .col --> | |
640 | - </div><!-- .row --> | |
641 | - <div class="row"> | |
642 | - <div class="col-sm-12"> | |
643 | - <div class="form-group"> | |
644 | - <label-text-area ng-id="parametro.MECANISMOS_FORMAIS_COMUNICACAO" | |
645 | - name="definicoesContrato.mecanismosFormaisComunicacao" | |
646 | - ng-model="parametro.MECANISMOS_FORMAIS_COMUNICACAO" | |
647 | - ng-label="PORTAL.LABEL.MECANISMOS_FORMAIS_COMUNICACAO" ng-custom-maxlength="100000" | |
648 | - ng-obrigatorio="false" form="definicoesContratoForm" ng-disabled="edit" rows="20"/> | |
649 | - </div><!-- .form-group --> | |
650 | - </div><!-- .col --> | |
651 | - </div><!-- .row --> | |
652 | - <div class="row"> | |
653 | - <div class="col-sm-12"> | |
654 | - <div class="form-group"> | |
655 | 611 | <label-text-area ng-id="parametro.TERMO_ENCERRAMENTO_INTRODUCAO" |
656 | 612 | name="definicoesContrato.termoEncerramentoIntroducao" |
657 | 613 | ng-model="parametro.TERMO_ENCERRAMENTO_INTRODUCAO" | ... | ... |