Commit 16f4c3d1ff6b272f65ec9644a76f5e7497c91f00
Exists in
master
Merge branch 'tarefa-4738' into cnt-1.1.0-alfa2
Showing
3 changed files
with
111 additions
and
40 deletions
Show diff stats
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/model/UnidadeMedida.java
@@ -9,15 +9,16 @@ import javax.persistence.GeneratedValue; | @@ -9,15 +9,16 @@ import javax.persistence.GeneratedValue; | ||
9 | import javax.persistence.GenerationType; | 9 | import javax.persistence.GenerationType; |
10 | import javax.persistence.Id; | 10 | import javax.persistence.Id; |
11 | import javax.persistence.ManyToOne; | 11 | import javax.persistence.ManyToOne; |
12 | +import javax.persistence.Transient; | ||
12 | 13 | ||
13 | import org.hibernate.envers.Audited; | 14 | import org.hibernate.envers.Audited; |
14 | 15 | ||
16 | +import com.fasterxml.jackson.annotation.JsonView; | ||
17 | + | ||
15 | import br.com.centralit.framework.json.Views; | 18 | import br.com.centralit.framework.json.Views; |
16 | import br.com.centralit.framework.model.Dominio; | 19 | import br.com.centralit.framework.model.Dominio; |
17 | import br.com.centralit.framework.model.arquitetura.PersistentObject; | 20 | import br.com.centralit.framework.model.arquitetura.PersistentObject; |
18 | 21 | ||
19 | -import com.fasterxml.jackson.annotation.JsonView; | ||
20 | - | ||
21 | /** | 22 | /** |
22 | * <p> | 23 | * <p> |
23 | * <img src="http://centralit.com.br/images/logo_central.png"> | 24 | * <img src="http://centralit.com.br/images/logo_central.png"> |
@@ -56,7 +57,12 @@ public class UnidadeMedida extends PersistentObject { | @@ -56,7 +57,12 @@ public class UnidadeMedida extends PersistentObject { | ||
56 | 57 | ||
57 | /** Atributo serialVersionUID. */ | 58 | /** Atributo serialVersionUID. */ |
58 | private static final long serialVersionUID = -7573208249312737668L; | 59 | private static final long serialVersionUID = -7573208249312737668L; |
59 | - | 60 | + |
61 | + @Transient | ||
62 | + private final Long TIPO_NUMERICO_INTEIRO = new Long (1l); | ||
63 | + @Transient | ||
64 | + private final Long TIPO_NUMERICO_DECIMAL = new Long (2l); | ||
65 | + | ||
60 | /** Atributo id. */ | 66 | /** Atributo id. */ |
61 | @Id | 67 | @Id |
62 | @GeneratedValue(strategy = GenerationType.AUTO) | 68 | @GeneratedValue(strategy = GenerationType.AUTO) |
@@ -85,7 +91,15 @@ public class UnidadeMedida extends PersistentObject { | @@ -85,7 +91,15 @@ public class UnidadeMedida extends PersistentObject { | ||
85 | @Column(name = "isUnidadePadrao") | 91 | @Column(name = "isUnidadePadrao") |
86 | @JsonView({ Views.GenericView.class }) | 92 | @JsonView({ Views.GenericView.class }) |
87 | private Boolean isUnidadePadrao; | 93 | private Boolean isUnidadePadrao; |
94 | + | ||
95 | + @Transient | ||
96 | + @JsonView({ Views.GenericView.class }) | ||
97 | + private BigDecimal quantidadeInteiro; | ||
88 | 98 | ||
99 | + @Transient | ||
100 | + @JsonView({ Views.GenericView.class }) | ||
101 | + private BigDecimal quantidadeDecimal; | ||
102 | + | ||
89 | /** | 103 | /** |
90 | * Responsável pela criação de novas instâncias desta classe. | 104 | * Responsável pela criação de novas instâncias desta classe. |
91 | */ | 105 | */ |
@@ -226,5 +240,25 @@ public class UnidadeMedida extends PersistentObject { | @@ -226,5 +240,25 @@ public class UnidadeMedida extends PersistentObject { | ||
226 | public void setIsUnidadePadrao(Boolean isUnidadePadrao) { | 240 | public void setIsUnidadePadrao(Boolean isUnidadePadrao) { |
227 | this.isUnidadePadrao = isUnidadePadrao; | 241 | this.isUnidadePadrao = isUnidadePadrao; |
228 | } | 242 | } |
243 | + | ||
244 | + public BigDecimal getQuantidadeInteiro() { | ||
245 | + return quantidadePadrao; | ||
246 | + } | ||
229 | 247 | ||
248 | + public void setQuantidadeInteiro(BigDecimal quantidadeInteiro) { | ||
249 | + if(this.tipoNumerico != null && this.tipoNumerico.getCodigo().equals(TIPO_NUMERICO_INTEIRO)){ | ||
250 | + this.quantidadePadrao = quantidadeInteiro; | ||
251 | + } | ||
252 | + } | ||
253 | + | ||
254 | + public BigDecimal getQuantidadeDecimal() { | ||
255 | + return quantidadePadrao; | ||
256 | + } | ||
257 | + | ||
258 | + public void setQuantidadeDecimal(BigDecimal quantidadeDecimal) { | ||
259 | + if(this.tipoNumerico != null && this.tipoNumerico.getCodigo().equals(TIPO_NUMERICO_DECIMAL)){ | ||
260 | + this.quantidadePadrao = quantidadeDecimal; | ||
261 | + } | ||
262 | + } | ||
263 | + | ||
230 | } | 264 | } |
cit-tabelas-corp-web/src/main/webapp/assets/js/angular/custom/controller/UnidadeMedidaController.js
@@ -3,7 +3,10 @@ | @@ -3,7 +3,10 @@ | ||
3 | citApp.controller('UnidadeMedidaController', ['$scope', 'UnidadeMedidaRepository', '$translate', '$timeout', 'DominioRepository', | 3 | citApp.controller('UnidadeMedidaController', ['$scope', 'UnidadeMedidaRepository', '$translate', '$timeout', 'DominioRepository', |
4 | function UnidadeMedidaController($scope, UnidadeMedidaRepository, $translate, $timeout, DominioRepository) { | 4 | function UnidadeMedidaController($scope, UnidadeMedidaRepository, $translate, $timeout, DominioRepository) { |
5 | 5 | ||
6 | - $scope.unidadeMedida = {}; | 6 | + $scope.unidadeMedida = { |
7 | + showDecimal: false, | ||
8 | + showInteiro: false | ||
9 | + }; | ||
7 | 10 | ||
8 | // Limpa formulário para novo cadastro | 11 | // Limpa formulário para novo cadastro |
9 | $scope.resetForm = function() { | 12 | $scope.resetForm = function() { |
@@ -79,4 +82,41 @@ citApp.controller('UnidadeMedidaController', ['$scope', 'UnidadeMedidaRepository | @@ -79,4 +82,41 @@ citApp.controller('UnidadeMedidaController', ['$scope', 'UnidadeMedidaRepository | ||
79 | $scope.tipoNumericoList = result; | 82 | $scope.tipoNumericoList = result; |
80 | }); | 83 | }); |
81 | 84 | ||
82 | -}]); | 85 | + $scope.atualizaCampoQTDEPadrao = function(){ |
86 | + $scope.unidadeMedida.quantidadePadrao; | ||
87 | + }; | ||
88 | + | ||
89 | + $scope.alternaTipoNumerico = function(){ | ||
90 | + $timeout(function(){ | ||
91 | + 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 | + } | ||
106 | + }else{ | ||
107 | + $scope.showDecimal = false; | ||
108 | + $scope.showInteiro= false; | ||
109 | + $scope.unidadeMedida.quantidadeInteiro = ''; | ||
110 | + $scope.unidadeMedida.quantidadeDecimal = ''; | ||
111 | + } | ||
112 | + }); | ||
113 | + }; | ||
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 | + } | ||
121 | + }; | ||
122 | +}]); | ||
83 | \ No newline at end of file | 123 | \ No newline at end of file |
cit-tabelas-corp-web/src/main/webapp/html/unidadeMedida/unidadeMedidaEdit.html
@@ -2,26 +2,26 @@ | @@ -2,26 +2,26 @@ | ||
2 | <div class="bar-buttons-action fixed"> | 2 | <div class="bar-buttons-action fixed"> |
3 | <div class="row"> | 3 | <div class="row"> |
4 | <div class="col-sm-8 text-left"> | 4 | <div class="col-sm-8 text-left"> |
5 | - | 5 | + |
6 | <button class="btn btn-clear" ng-click="saveOrUpdate()" ng-show="edit"> | 6 | <button class="btn btn-clear" ng-click="saveOrUpdate()" ng-show="edit"> |
7 | <i class="fa fa-save green"></i> <translate>LABEL.SALVAR</translate> | 7 | <i class="fa fa-save green"></i> <translate>LABEL.SALVAR</translate> |
8 | </button> | 8 | </button> |
9 | - | 9 | + |
10 | <button class="btn btn-clear" ng-click="limparUnidadeMedida()" ng-show="unidadeMedida.id === undefined"> | 10 | <button class="btn btn-clear" ng-click="limparUnidadeMedida()" ng-show="unidadeMedida.id === undefined"> |
11 | <i class="fa fa-eraser yellow-dark"></i> <translate>LABEL.LIMPAR</translate> | 11 | <i class="fa fa-eraser yellow-dark"></i> <translate>LABEL.LIMPAR</translate> |
12 | </button> | 12 | </button> |
13 | - | 13 | + |
14 | <button class="btn btn-clear" ng-show="!edit" ng-click="edit = true"> | 14 | <button class="btn btn-clear" ng-show="!edit" ng-click="edit = true"> |
15 | <i class="fa fa-pencil blue"></i> | 15 | <i class="fa fa-pencil blue"></i> |
16 | <translate>LABEL.EDITAR</translate> | 16 | <translate>LABEL.EDITAR</translate> |
17 | </button> | 17 | </button> |
18 | - | 18 | + |
19 | <button class="btn btn-clear" ng-click="remove(unidadeMedida);" ng-show="unidadeMedida.id !== undefined"> | 19 | <button class="btn btn-clear" ng-click="remove(unidadeMedida);" ng-show="unidadeMedida.id !== undefined"> |
20 | <i class="fa fa-times red"></i> <translate>LABEL.REMOVER</translate> | 20 | <i class="fa fa-times red"></i> <translate>LABEL.REMOVER</translate> |
21 | </button> | 21 | </button> |
22 | - | 22 | + |
23 | <bloquear-desbloquear ng-model="unidadeMedida" ng-repository="UnidadeMedidaRepository" ng-edit="edit" form="unidadeMedidaForm"></bloquear-desbloquear> | 23 | <bloquear-desbloquear ng-model="unidadeMedida" ng-repository="UnidadeMedidaRepository" ng-edit="edit" form="unidadeMedidaForm"></bloquear-desbloquear> |
24 | - | 24 | + |
25 | <button class="btn btn-clear" ng-click="$showPageSearchWorkspace(workspace); atualizaPaginaPesquisa();"> | 25 | <button class="btn btn-clear" ng-click="$showPageSearchWorkspace(workspace); atualizaPaginaPesquisa();"> |
26 | <i class="fa fa-search"></i> <translate>LABEL.PESQUISAR</translate> | 26 | <i class="fa fa-search"></i> <translate>LABEL.PESQUISAR</translate> |
27 | </button> | 27 | </button> |
@@ -29,17 +29,17 @@ | @@ -29,17 +29,17 @@ | ||
29 | </div><!-- .col --> | 29 | </div><!-- .col --> |
30 | 30 | ||
31 | <div class="col-sm-4 text-right"> | 31 | <div class="col-sm-4 text-right"> |
32 | - | 32 | + |
33 | <favorito/> | 33 | <favorito/> |
34 | - | 34 | + |
35 | <help-button workspace="workspace" /> | 35 | <help-button workspace="workspace" /> |
36 | - | 36 | + |
37 | </div><!-- .col --> | 37 | </div><!-- .col --> |
38 | </div><!-- .row --> | 38 | </div><!-- .row --> |
39 | </div><!-- .bar-buttons-action --> | 39 | </div><!-- .bar-buttons-action --> |
40 | - | 40 | + |
41 | <breadcrumb ng-workspace="workspace"></breadcrumb> | 41 | <breadcrumb ng-workspace="workspace"></breadcrumb> |
42 | - | 42 | + |
43 | <form name="unidadeMedidaForm"> | 43 | <form name="unidadeMedidaForm"> |
44 | <p> | 44 | <p> |
45 | <small>( <span class="red">*</span> ) <translate>LABEL.CAMPOS_OBRIGATORIOS</translate></small> | 45 | <small>( <span class="red">*</span> ) <translate>LABEL.CAMPOS_OBRIGATORIOS</translate></small> |
@@ -48,44 +48,41 @@ | @@ -48,44 +48,41 @@ | ||
48 | <fieldset> | 48 | <fieldset> |
49 | 49 | ||
50 | <legend><translate>CORPORATIVO.LABEL.DADOS_UNIDADE_MEDIDA</translate></legend> | 50 | <legend><translate>CORPORATIVO.LABEL.DADOS_UNIDADE_MEDIDA</translate></legend> |
51 | - | 51 | + |
52 | <div class="row"> | 52 | <div class="row"> |
53 | - | 53 | + |
54 | <div class="col-md-6"> | 54 | <div class="col-md-6"> |
55 | - | 55 | + |
56 | <label-input-number ng-id="unidadeMedida.codigo" ng-label="LABEL.CODIGO" ng-obrigatorio="true" ng-disabled="!edit" form="unidadeMedidaForm" ng-model="unidadeMedida.codigo" ng-custom-maxlength="5"/> | 56 | <label-input-number ng-id="unidadeMedida.codigo" ng-label="LABEL.CODIGO" ng-obrigatorio="true" ng-disabled="!edit" form="unidadeMedidaForm" ng-model="unidadeMedida.codigo" ng-custom-maxlength="5"/> |
57 | - | 57 | + |
58 | </div> | 58 | </div> |
59 | - | 59 | + |
60 | <div class="col-md-6"> | 60 | <div class="col-md-6"> |
61 | - | 61 | + |
62 | <label-input ng-id="unidadeMedida.descricao" ng-label="LABEL.DESCRICAO" ng-obrigatorio="true" ng-disabled="!edit" form="unidadeMedidaForm" ng-model="unidadeMedida.descricao" ng-custom-maxlength="100" /> | 62 | <label-input ng-id="unidadeMedida.descricao" ng-label="LABEL.DESCRICAO" ng-obrigatorio="true" ng-disabled="!edit" form="unidadeMedidaForm" ng-model="unidadeMedida.descricao" ng-custom-maxlength="100" /> |
63 | - | 63 | + |
64 | </div> | 64 | </div> |
65 | - </div> | ||
66 | - <div class="row"> | 65 | + </div> |
66 | + <div class="row"> | ||
67 | <div class="col-md-4"> | 67 | <div class="col-md-4"> |
68 | - | ||
69 | - <label-select ng-id="unidadeMedida.tipoNumerico" ng-label="CORPORATIVO.LABEL.TIPO_NUMERICO" ng-model="unidadeMedida.tipoNumerico" form="unidadeMedidaForm" ng-obrigatorio="true" ng-disabled="!edit" ng-custom-options="dominio.originalElement as dominio.descricao for dominio" track-by="track by dominio.id" ng-list="tipoNumericoList" /> | ||
70 | - | 68 | + |
69 | + <label-select ng-id="unidadeMedida.tipoNumerico" ng-custom-change="alternaTipoNumerico()" ng-label="CORPORATIVO.LABEL.TIPO_NUMERICO" ng-model="unidadeMedida.tipoNumerico" form="unidadeMedidaForm" ng-obrigatorio="true" ng-disabled="!edit" ng-custom-options="dominio.originalElement as dominio.descricao for dominio" track-by="track by dominio.id" ng-list="tipoNumericoList" /> | ||
70 | + | ||
71 | </div> | 71 | </div> |
72 | - | 72 | + |
73 | <div class="col-md-4"> | 73 | <div class="col-md-4"> |
74 | - | 74 | + |
75 | <label-input ng-id="unidadeMedida.sigla" ng-label="LABEL.SIGLA" ng-model="unidadeMedida.sigla" form="unidadeMedidaForm" ng-obrigatorio="true" ng-custom-maxlength="3" ng-type="text" ng-disabled="!edit" /> | 75 | <label-input ng-id="unidadeMedida.sigla" ng-label="LABEL.SIGLA" ng-model="unidadeMedida.sigla" form="unidadeMedidaForm" ng-obrigatorio="true" ng-custom-maxlength="3" ng-type="text" ng-disabled="!edit" /> |
76 | - | ||
77 | </div> | 76 | </div> |
78 | - | ||
79 | - <div class="col-md-4"> | ||
80 | - | ||
81 | - <i tooltip="{{$translate.instant('MSG.ALTERACAO_QUANTIDADE_PADRAO')}}"> | ||
82 | - <label-input-number ng-id="unidadeMedida.quantidadePadrao" ng-label="CORPORATIVO.LABEL.QUANTIDADE_PADRAO" ng-model="unidadeMedida.quantidadePadrao" form="unidadeMedidaForm" ng-obrigatorio="false" ng-custom-maxlength="3" ng-type="text" ng-disabled="unidadeMedida.isUnidadePadrao || !edit"/> | ||
83 | - </i> | 77 | + |
78 | + <div class="col-md-4" ng-show="showInteiro"> | ||
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 | + </div> | ||
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"/> | ||
84 | </div> | 83 | </div> |
85 | - | ||
86 | </div> | 84 | </div> |
87 | - | ||
88 | - </fieldset> | 85 | + </fieldset> |
89 | </form> | 86 | </form> |
90 | </div><!-- .page-content --> | 87 | </div><!-- .page-content --> |
91 | 88 |