Commit 1ab92440bd92990bf49eeb1d2392a6c965a49ca4

Authored by thiago.coimbra
2 parents 3888f029 c6b9d853
Exists in master

Merge branch 'adm-1.15.0'

cit-tabelas-corp-web/src/main/webapp/assets/js/angular/custom/controller/UnidadeMedidaController.js
... ... @@ -3,10 +3,7 @@
3 3 citApp.controller('UnidadeMedidaController', ['$scope', 'UnidadeMedidaRepository', '$translate', '$timeout', 'DominioRepository',
4 4 function UnidadeMedidaController($scope, UnidadeMedidaRepository, $translate, $timeout, DominioRepository) {
5 5  
6   - $scope.unidadeMedida = {
7   - showDecimal: false,
8   - showInteiro: false
9   - };
  6 + $scope.showInteiro= true;
10 7  
11 8 // Limpa formulário para novo cadastro
12 9 $scope.resetForm = function() {
... ... @@ -75,7 +72,9 @@ citApp.controller('UnidadeMedidaController', ['$scope', 'UnidadeMedidaRepository
75 72 $scope.unidadeMedida = result.originalElement;
76 73 $scope.edit = edit;
77 74 $scope.setLoading(false);
  75 + $scope.alternaTipoNumerico();
78 76 });
  77 +
79 78 };
80 79  
81 80 DominioRepository.findAllDominio('tipoNumerico').then(function(result) {
... ... @@ -89,34 +88,27 @@ citApp.controller('UnidadeMedidaController', ['$scope', 'UnidadeMedidaRepository
89 88 $scope.alternaTipoNumerico = function(){
90 89 $timeout(function(){
91 90 if($scope.unidadeMedida.tipoNumerico){
92   - switch($scope.unidadeMedida.tipoNumerico.codigo){
93   - case 1:
94   - $scope.showInteiro= true;
95   - $scope.showDecimal = false;
96   - $scope.unidadeMedida.quantidadeDecimal = '';
97   - break;
98   -
99   - case 2:
100   - $scope.showDecimal = true;
101   - $scope.showInteiro= false;
102   - $scope.unidadeMedida.quantidadeInteiro = '';
103   - break;
104   -
105   - }
  91 + $scope.defineTipoNumerico();
106 92 }else{
107   - $scope.showDecimal = false;
108   - $scope.showInteiro= false;
  93 + $scope.showInteiro= true;
109 94 $scope.unidadeMedida.quantidadeInteiro = '';
110 95 $scope.unidadeMedida.quantidadeDecimal = '';
111 96 }
112 97 });
113 98 };
114   -
115   - $scope.aplicarValidacaoDecimal = function(){
116   - if($scope.unidadeMedida.quantidadeDecimal){
117   - $scope.unidadeMedida.quantidadeDecimal = parseFloat($scope.unidadeMedida.quantidadeDecimal).toFixed(2);
118   - }else{
119   - $scope.unidadeMedida.quantidadeDecimal = '';
120   - }
  99 + $scope.defineTipoNumerico = function(){
  100 + switch($scope.unidadeMedida.tipoNumerico.codigo){
  101 + case 1:
  102 + $scope.showInteiro= true;
  103 + $scope.showDecimal = false;
  104 + $scope.unidadeMedida.quantidadeDecimal = '';
  105 + break;
  106 +
  107 + case 2:
  108 + $scope.showDecimal = true;
  109 + $scope.showInteiro= false;
  110 + $scope.unidadeMedida.quantidadeInteiro = '';
  111 + break;
  112 + }
121 113 };
122 114 }]);
123 115 \ No newline at end of file
... ...
cit-tabelas-corp-web/src/main/webapp/html/unidadeMedida/unidadeMedidaEdit.html
... ... @@ -79,7 +79,7 @@
79 79 <label-input-number ng-id="unidadeMedida.quantidadeInteiro" ng-model="unidadeMedida.quantidadeInteiro" ng-custom-maxlength="4" ng-type="text" ng-label="CORPORATIVO.LABEL.QUANTIDADE_PADRAO" ng-obrigatorio="showInteiro" form="unidadeMedidaForm" ng-disabled="unidadeMedida.isUnidadePadrao || !edit"/>
80 80 </div>
81 81 <div class="col-md-4" ng-show="showDecimal">
82   - <label-input-decimal ng-precisao="decimal" ng-custom-maxlength="11" ng-evento-blur="aplicarValidacaoDecimal" ng-id="unidadeMedida.quantidadeDecimal" ng-model="unidadeMedida.quantidadeDecimal" ng-label="CORPORATIVO.LABEL.QUANTIDADE_PADRAO" ng-obrigatorio="showDecimal" form="unidadeMedidaForm" ng-disabled="unidadeMedida.isUnidadePadrao || !edit"/>
  82 + <label-input-decimal ng-precisao="decimal" ng-custom-maxlength="9" ng-evento-blur="aplicarValidacaoDecimal" ng-id="unidadeMedida.quantidadeDecimal" ng-model="unidadeMedida.quantidadeDecimal" ng-label="CORPORATIVO.LABEL.QUANTIDADE_PADRAO" ng-obrigatorio="showDecimal" form="unidadeMedidaForm" ng-disabled="unidadeMedida.isUnidadePadrao || !edit"/>
83 83 </div>
84 84 </div>
85 85 </fieldset>
... ...