Commit 0b81b9375d2072370d7265cdbd3cb3ff6ad176c7
1 parent
9f75f1f9
Exists in
master
redmine #4738 Migracao do cadastro de unidade de medida.
Showing
16 changed files
with
691 additions
and
4 deletions
Show diff stats
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/dao/UnidadeMedidaDao.java
0 → 100644
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/dao/impl/UnidadeMedidaDaoHibernate.java
0 → 100644
... | ... | @@ -0,0 +1,14 @@ |
1 | +package br.com.centralit.api.dao.impl; | |
2 | + | |
3 | +import br.com.centralit.api.model.UnidadeMedida; | |
4 | +import br.com.centralit.api.dao.UnidadeMedidaDao; | |
5 | + | |
6 | +import org.springframework.stereotype.Repository; | |
7 | +import br.com.centralit.framework.dao.arquitetura.CitGenericDAOImpl; | |
8 | + | |
9 | +@Repository("unidadeMedidaDao") | |
10 | +public class UnidadeMedidaDaoHibernate extends CitGenericDAOImpl implements UnidadeMedidaDao { | |
11 | + public UnidadeMedidaDaoHibernate() { | |
12 | + super(UnidadeMedida.class); | |
13 | + } | |
14 | +} | ... | ... |
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/framework/json/ViewsTabelasCorp.java
... | ... | @@ -57,5 +57,9 @@ public class ViewsTabelasCorp extends Views { |
57 | 57 | public static class CentroCustoEditView extends CentroCustoListView {}; |
58 | 58 | |
59 | 59 | public static class CentroCustoListView extends GenericView {}; |
60 | + | |
61 | + public static class UnidadeMedidaListView extends GenericView {} | |
60 | 62 | |
63 | + public static class UnidadeMedidaEditView extends UnidadeMedidaListView {} | |
64 | + | |
61 | 65 | } | ... | ... |
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/model/UnidadeMedida.java
0 → 100644
... | ... | @@ -0,0 +1,230 @@ |
1 | +package br.com.centralit.api.model; | |
2 | + | |
3 | +import java.math.BigDecimal; | |
4 | + | |
5 | +import javax.persistence.Column; | |
6 | +import javax.persistence.Entity; | |
7 | +import javax.persistence.FetchType; | |
8 | +import javax.persistence.GeneratedValue; | |
9 | +import javax.persistence.GenerationType; | |
10 | +import javax.persistence.Id; | |
11 | +import javax.persistence.ManyToOne; | |
12 | + | |
13 | +import org.hibernate.envers.Audited; | |
14 | + | |
15 | +import br.com.centralit.framework.json.Views; | |
16 | +import br.com.centralit.framework.model.Dominio; | |
17 | +import br.com.centralit.framework.model.arquitetura.PersistentObject; | |
18 | + | |
19 | +import com.fasterxml.jackson.annotation.JsonView; | |
20 | + | |
21 | +/** | |
22 | + * <p> | |
23 | + * <img src="http://centralit.com.br/images/logo_central.png"> | |
24 | + * </p> | |
25 | + * | |
26 | + * <p> | |
27 | + * <b>Company: </b> Central IT - Governança Corporativa - | |
28 | + * </p> | |
29 | + * | |
30 | + * <p> | |
31 | + * <b>Title: </b> | |
32 | + * </p> | |
33 | + * | |
34 | + * <p> | |
35 | + * <b>Description: </b> | |
36 | + * </p> | |
37 | + * | |
38 | + * <p> | |
39 | + * <b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a> | |
40 | + * </p> | |
41 | + * | |
42 | + * <p> | |
43 | + * <b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a> | |
44 | + * </p> | |
45 | + * | |
46 | + * @since 29/05/2015 - 15:41:54 | |
47 | + * | |
48 | + * @version 1.0.0 | |
49 | + * | |
50 | + * @author rogerio.costa | |
51 | + * | |
52 | + */ | |
53 | +@Audited | |
54 | +@Entity | |
55 | +public class UnidadeMedida extends PersistentObject { | |
56 | + | |
57 | + /** Atributo serialVersionUID. */ | |
58 | + private static final long serialVersionUID = -7573208249312737668L; | |
59 | + | |
60 | + /** Atributo id. */ | |
61 | + @Id | |
62 | + @GeneratedValue(strategy = GenerationType.AUTO) | |
63 | + @JsonView({ Views.GenericView.class }) | |
64 | + private Long id; | |
65 | + | |
66 | + @Column(length = 30) | |
67 | + @JsonView({ Views.GenericView.class }) | |
68 | + private String codigo; | |
69 | + | |
70 | + @JsonView({ Views.GenericView.class }) | |
71 | + private String sigla; | |
72 | + | |
73 | + @JsonView({ Views.GenericView.class }) | |
74 | + private String descricao; | |
75 | + | |
76 | + /** Atributo tipoNumerico. */ | |
77 | + @ManyToOne(fetch = FetchType.LAZY) | |
78 | + @JsonView({ Views.GenericView.class }) | |
79 | + private Dominio tipoNumerico; | |
80 | + | |
81 | + @Column(name = "quantidadePadrao") | |
82 | + @JsonView({ Views.GenericView.class }) | |
83 | + private BigDecimal quantidadePadrao; | |
84 | + | |
85 | + @Column(name = "isUnidadePadrao") | |
86 | + @JsonView({ Views.GenericView.class }) | |
87 | + private Boolean isUnidadePadrao; | |
88 | + | |
89 | + /** | |
90 | + * Responsável pela criação de novas instâncias desta classe. | |
91 | + */ | |
92 | + public UnidadeMedida() { | |
93 | + | |
94 | + super(); | |
95 | + } | |
96 | + | |
97 | + /** | |
98 | + * Responsável pela criação de novas instâncias desta classe. | |
99 | + * | |
100 | + * @param tipoNumerico | |
101 | + * @param tipoUnidadeMedida | |
102 | + */ | |
103 | + public UnidadeMedida( String sigla, Dominio tipoNumerico, String descricao, String codigo ) { | |
104 | + | |
105 | + this.tipoNumerico = tipoNumerico; | |
106 | + | |
107 | + this.descricao = descricao; | |
108 | + | |
109 | + this.sigla = sigla; | |
110 | + | |
111 | + this.codigo = codigo; | |
112 | + } | |
113 | + | |
114 | + /** | |
115 | + * Retorna o valor do atributo <code>id</code> | |
116 | + * | |
117 | + * @return <code>Long</code> | |
118 | + */ | |
119 | + public Long getId() { | |
120 | + | |
121 | + return id; | |
122 | + } | |
123 | + | |
124 | + /** | |
125 | + * Define o valor do atributo <code>id</code>. | |
126 | + * | |
127 | + * @param id | |
128 | + */ | |
129 | + public void setId(Long id) { | |
130 | + | |
131 | + this.id = id; | |
132 | + } | |
133 | + | |
134 | + /** | |
135 | + * Retorna o valor do atributo <code>tipoNumerico</code> | |
136 | + * | |
137 | + * @return <code>Dominio</code> | |
138 | + */ | |
139 | + public Dominio getTipoNumerico() { | |
140 | + | |
141 | + return tipoNumerico; | |
142 | + } | |
143 | + | |
144 | + /** | |
145 | + * Define o valor do atributo <code>tipoNumerico</code>. | |
146 | + * | |
147 | + * @param tipoNumerico | |
148 | + */ | |
149 | + public void setTipoNumerico(Dominio tipoNumerico) { | |
150 | + | |
151 | + this.tipoNumerico = tipoNumerico; | |
152 | + } | |
153 | + | |
154 | + /** | |
155 | + * Retorna o valor do atributo <code>descricao</code> | |
156 | + * | |
157 | + * @return <code>String</code> | |
158 | + */ | |
159 | + public String getDescricao() { | |
160 | + | |
161 | + return descricao; | |
162 | + } | |
163 | + | |
164 | + /** | |
165 | + * Define o valor do atributo <code>descricao</code>. | |
166 | + * | |
167 | + * @param descricao | |
168 | + */ | |
169 | + public void setDescricao(String descricao) { | |
170 | + | |
171 | + this.descricao = descricao; | |
172 | + } | |
173 | + | |
174 | + /** | |
175 | + * Retorna o valor do atributo <code>sigla</code> | |
176 | + * | |
177 | + * @return <code>String</code> | |
178 | + */ | |
179 | + public String getSigla() { | |
180 | + | |
181 | + return sigla; | |
182 | + } | |
183 | + | |
184 | + /** | |
185 | + * Define o valor do atributo <code>sigla</code>. | |
186 | + * | |
187 | + * @param sigla | |
188 | + */ | |
189 | + public void setSigla(String sigla) { | |
190 | + | |
191 | + this.sigla = sigla; | |
192 | + } | |
193 | + | |
194 | + /** | |
195 | + * Retorna o valor do atributo <code>codigo</code> | |
196 | + * | |
197 | + * @return <code>String</code> | |
198 | + */ | |
199 | + public String getCodigo() { | |
200 | + | |
201 | + return codigo; | |
202 | + } | |
203 | + | |
204 | + /** | |
205 | + * Define o valor do atributo <code>codigo</code>. | |
206 | + * | |
207 | + * @param codigo | |
208 | + */ | |
209 | + public void setCodigo(String codigo) { | |
210 | + | |
211 | + this.codigo = codigo; | |
212 | + } | |
213 | + | |
214 | + public BigDecimal getQuantidadePadrao() { | |
215 | + return quantidadePadrao; | |
216 | + } | |
217 | + | |
218 | + public void setQuantidadePadrao(BigDecimal quantidadePadrao) { | |
219 | + this.quantidadePadrao = quantidadePadrao; | |
220 | + } | |
221 | + | |
222 | + public Boolean getIsUnidadePadrao() { | |
223 | + return isUnidadePadrao; | |
224 | + } | |
225 | + | |
226 | + public void setIsUnidadePadrao(Boolean isUnidadePadrao) { | |
227 | + this.isUnidadePadrao = isUnidadePadrao; | |
228 | + } | |
229 | + | |
230 | +} | ... | ... |
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/service/UnidadeMedidaService.java
0 → 100644
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/service/impl/InicializarTabelasCorpServiceImpl.java
... | ... | @@ -152,7 +152,17 @@ public class InicializarTabelasCorpServiceImpl extends UtilStartup { |
152 | 152 | Menu menuCaracteristica = new Menu("Definir características", pgCaracteristica, menuAtributos, null, 1, null, null, null, null, moduloSelecionado); |
153 | 153 | menuCaracteristica.setIncludes(this.gerarArquivosMenu(menuCaracteristica, CIT_TABELAS_CORP_WEB_ANGULAR_CUSTOM, "Caracteristica", true, true, true)); |
154 | 154 | this.menuService.mergeIfNotExist(menuCaracteristica); |
155 | - | |
155 | + //Menu Unidade Medida | |
156 | + Pagina pgUnidadeMedida = new Pagina("Unidade Medida", "/cit-tabelas-corp-web/html/unidadeMedida/unidadeMedida.html"); | |
157 | + pgUnidadeMedida = this.paginaService.saveIfNotExist(pgUnidadeMedida); | |
158 | + Menu menuUnidadeMedida = new Menu("Unidade Medida", pgUnidadeMedida, menuAtributos, null, 2, null, null, null, null, moduloSelecionado); | |
159 | + List<MenuFile> filesMenuUnidadeMedida = new ArrayList<MenuFile>(); | |
160 | + filesMenuUnidadeMedida.addAll(this.gerarArquivosMenu(menuUnidadeMedida, CIT_TABELAS_CORP_WEB_ANGULAR_CUSTOM, "UnidadeMedida", true, true, true)); | |
161 | + filesMenuUnidadeMedida.add(new MenuFile(CIT_TABELAS_CORP_WEB_ANGULAR_CUSTOM + "repository/UnidadeMedidaRepository.js", dominioJS, menuUnidadeMedida)); | |
162 | + filesMenuUnidadeMedida.add(new MenuFile(CIT_TABELAS_CORP_WEB_ANGULAR_CUSTOM + "repository/UnidadeMedidaRepository.min.js", dominioJS, menuUnidadeMedida)); | |
163 | + menuUnidadeMedida.setIncludes(filesMenuUnidadeMedida); | |
164 | + this.menuService.mergeIfNotExist(menuUnidadeMedida); | |
165 | + | |
156 | 166 | // Submenu Estrutura organizacional |
157 | 167 | Menu menuEstrutura = new Menu("Estrutura organizacional", null, menuTabelasCorp, 0, 2, null, null, null, null, moduloSelecionado); |
158 | 168 | menuEstrutura.setParent(menuTabelasCorp); | ... | ... |
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/service/impl/UnidadeMedidaServiceImpl.java
0 → 100644
... | ... | @@ -0,0 +1,56 @@ |
1 | +package br.com.centralit.api.service.impl; | |
2 | + | |
3 | +import java.math.BigDecimal; | |
4 | + | |
5 | +import org.springframework.beans.factory.annotation.Autowired; | |
6 | +import org.springframework.beans.factory.annotation.Qualifier; | |
7 | +import org.springframework.stereotype.Service; | |
8 | +import org.springframework.validation.Validator; | |
9 | + | |
10 | +import br.com.centralit.api.dao.UnidadeMedidaDao; | |
11 | +import br.com.centralit.api.model.UnidadeMedida; | |
12 | +import br.com.centralit.api.service.UnidadeMedidaService; | |
13 | +import br.com.centralit.framework.exception.BusinessException; | |
14 | +import br.com.centralit.framework.exception.CodigoErro; | |
15 | +import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; | |
16 | +import br.com.centralit.framework.util.UtilObjeto; | |
17 | + | |
18 | +@Service("unidadeMedidaService") | |
19 | +public class UnidadeMedidaServiceImpl extends GenericServiceImpl<UnidadeMedida, Long> implements UnidadeMedidaService { | |
20 | + | |
21 | + private UnidadeMedidaDao unidadeMedidaDao; | |
22 | + | |
23 | + @Autowired | |
24 | + public UnidadeMedidaServiceImpl(UnidadeMedidaDao unidadeMedidaDao, @Qualifier("unidadeMedidaValidator") Validator validator) { | |
25 | + this.dao = unidadeMedidaDao; | |
26 | + this.unidadeMedidaDao = unidadeMedidaDao; | |
27 | + this.validator = validator; | |
28 | + } | |
29 | + | |
30 | + @Override | |
31 | + public UnidadeMedida save(UnidadeMedida entity) { | |
32 | + | |
33 | + if(!UtilObjeto.isReferencia(entity.getIsUnidadePadrao())){ | |
34 | + entity.setIsUnidadePadrao(Boolean.FALSE); | |
35 | + } | |
36 | + | |
37 | + if(UtilObjeto.isReferencia(entity.getQuantidadePadrao()) && entity.getQuantidadePadrao().equals(BigDecimal.ZERO)){ | |
38 | + throw new BusinessException("CORPORATIVO.MSG.QTDE_VALOR_PADRAO_NAO_PERMITIDO", CodigoErro.REGRA_NEGOCIO.getValue(), ""); | |
39 | + } | |
40 | + return super.save(entity); | |
41 | + } | |
42 | + | |
43 | + @Override | |
44 | + public UnidadeMedida merge(UnidadeMedida entity) { | |
45 | + | |
46 | + if(!UtilObjeto.isReferencia(entity.getIsUnidadePadrao())){ | |
47 | + entity.setIsUnidadePadrao(Boolean.FALSE); | |
48 | + } | |
49 | + | |
50 | + if(UtilObjeto.isReferencia(entity.getQuantidadePadrao()) && entity.getQuantidadePadrao().equals(BigDecimal.ZERO)){ | |
51 | + throw new BusinessException("CORPORATIVO.MSG.QTDE_VALOR_PADRAO_NAO_PERMITIDO", CodigoErro.REGRA_NEGOCIO.getValue(), ""); | |
52 | + } | |
53 | + // TODO Auto-generated method stub | |
54 | + return super.merge(entity); | |
55 | + } | |
56 | +} | ... | ... |
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/service/validation/UnidadeMedidaValidator.java
0 → 100644
... | ... | @@ -0,0 +1,31 @@ |
1 | +package br.com.centralit.api.service.validation; | |
2 | + | |
3 | +import br.com.centralit.api.model.UnidadeMedida; | |
4 | +import org.springframework.stereotype.Component; | |
5 | +import org.springframework.validation.Errors; | |
6 | +import org.springframework.validation.ValidationUtils; | |
7 | +import org.springframework.validation.Validator; | |
8 | + | |
9 | +import br.com.centralit.framework.exception.CodigoErro; | |
10 | + | |
11 | +@Component("unidadeMedidaValidator") | |
12 | +public class UnidadeMedidaValidator implements Validator { | |
13 | + | |
14 | + @Override | |
15 | + public boolean supports(Class<?> clazz) { | |
16 | + | |
17 | + return UnidadeMedida.class.isAssignableFrom(clazz); | |
18 | + } | |
19 | + | |
20 | + @Override | |
21 | + public void validate(Object target, Errors errors) { | |
22 | + | |
23 | + ValidationUtils.rejectIfEmpty(errors, "descricao", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "LABEL.DESCRICAO"); | |
24 | + | |
25 | + ValidationUtils.rejectIfEmpty(errors, "codigo", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "LABEL.DESCRICAO"); | |
26 | + | |
27 | + ValidationUtils.rejectIfEmpty(errors, "tipoNumerico", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "ADMINISTRACAODEMATERIAIS.LABEL.TIPO_NUMERICO"); | |
28 | + | |
29 | + } | |
30 | +} | |
31 | + | ... | ... |
cit-tabelas-corp-web/src/main/java/br/com/centralit/controller/UnidadeMedidaController.java
0 → 100644
... | ... | @@ -0,0 +1,48 @@ |
1 | +package br.com.centralit.controller; | |
2 | + | |
3 | +import java.util.Collection; | |
4 | + | |
5 | +import org.springframework.beans.factory.annotation.Autowired; | |
6 | +import org.springframework.stereotype.Controller; | |
7 | +import org.springframework.web.bind.annotation.RequestMapping; | |
8 | +import org.springframework.web.bind.annotation.RequestMethod; | |
9 | +import org.springframework.web.bind.annotation.ResponseBody; | |
10 | + | |
11 | +import br.com.centralit.api.framework.json.ViewsTabelasCorp; | |
12 | +import br.com.centralit.api.model.UnidadeMedida; | |
13 | +import br.com.centralit.api.service.UnidadeMedidaService; | |
14 | +import br.com.centralit.framework.controller.GenericController; | |
15 | +import br.com.centralit.framework.json.ResponseBodyWrapper; | |
16 | + | |
17 | +@Controller | |
18 | +@RequestMapping("/rest/unidadeMedida") | |
19 | +public class UnidadeMedidaController extends GenericController<UnidadeMedida>{ | |
20 | + | |
21 | + @Autowired | |
22 | + public UnidadeMedidaController(UnidadeMedidaService unidadeMedidaService) { | |
23 | + super(unidadeMedidaService); | |
24 | + } | |
25 | + | |
26 | + @RequestMapping(method = RequestMethod.GET, produces = "application/json") | |
27 | + @ResponseBody | |
28 | + public ResponseBodyWrapper getList() { | |
29 | + | |
30 | + Collection<UnidadeMedida> listaUnidadeMedidas = this.genericService.findAll(); | |
31 | + | |
32 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(listaUnidadeMedidas, ViewsTabelasCorp.UnidadeMedidaListView.class); | |
33 | + | |
34 | + return responseBody; | |
35 | + } | |
36 | + | |
37 | + @Override | |
38 | + public Class<ViewsTabelasCorp.UnidadeMedidaEditView> getEditView() { | |
39 | + | |
40 | + return ViewsTabelasCorp.UnidadeMedidaEditView.class; | |
41 | + } | |
42 | + | |
43 | + @Override | |
44 | + public Class<ViewsTabelasCorp.UnidadeMedidaListView> getListView() { | |
45 | + | |
46 | + return ViewsTabelasCorp.UnidadeMedidaListView.class; | |
47 | + } | |
48 | +} | ... | ... |
cit-tabelas-corp-web/src/main/java/br/com/centralit/listener/StartupListenerTabelasCorp.java
... | ... | @@ -288,8 +288,9 @@ public class StartupListenerTabelasCorp extends UtilStartup implements Applicati |
288 | 288 | internacionalizacaoList.add(new Internacionalizacao("CORPORATIVO.LABEL.ESTADO", "Estado", dominio, modulo)); |
289 | 289 | internacionalizacaoList.add(new Internacionalizacao("CORPORATIVO.LABEL.DADOS_CENTRO_CUSTO", "Dados do centro de custo", dominio, modulo)); |
290 | 290 | internacionalizacaoList.add(new Internacionalizacao("CORPORATIVO.LABEL.ATUALIZA_ESI", "Atualiza ESI", dominio, modulo)); |
291 | - | |
292 | - | |
291 | + internacionalizacaoList.add(new Internacionalizacao("CORPORATIVO.LABEL.TIPO_NUMERICO", "Tipo numérico", dominio, modulo)); | |
292 | + internacionalizacaoList.add(new Internacionalizacao("CORPORATIVO.LABEL.DADOS_UNIDADE_MEDIDA", "Dados da unidade de medida", dominio, modulo)); | |
293 | + internacionalizacaoList.add(new Internacionalizacao("CORPORATIVO.LABEL.QUANTIDADE_PADRAO", "Qtde. Padrão", dominio, modulo)); | |
293 | 294 | } |
294 | 295 | |
295 | 296 | private void gerarValidacao(Dominio dominio, Modulo modulo, List<Internacionalizacao> internacionalizacaoList) { |
... | ... | @@ -340,7 +341,7 @@ public class StartupListenerTabelasCorp extends UtilStartup implements Applicati |
340 | 341 | internacionalizacaoList.add(new Internacionalizacao("CORPORATIVO.MSG.SUCESSO_REGIAO", "Região salva com sucesso!", dominio, modulo)); |
341 | 342 | internacionalizacaoList.add(new Internacionalizacao("CORPORATIVO.MSG.SUCESSO_REGIAO_EXCLUIDO", "Região excluída com sucesso!", dominio, modulo)); |
342 | 343 | internacionalizacaoList.add(new Internacionalizacao("CORPORATIVO.MSG.HIERARQUIA_UNICA", "Não pode existir mais de um nível de autoridade com a mesma hierarquia!", dominio, modulo)); |
343 | - | |
344 | + internacionalizacaoList.add(new Internacionalizacao("CORPORATIVO.MSG.QTDE_VALOR_PADRAO_NAO_PERMITIDO", "Quantidade padrão não permitida para esta operação!", dominio, modulo)); | |
344 | 345 | |
345 | 346 | } |
346 | 347 | ... | ... |
cit-tabelas-corp-web/src/main/webapp/assets/js/angular/custom/controller/UnidadeMedidaController.js
0 → 100644
... | ... | @@ -0,0 +1,82 @@ |
1 | +'use strict'; | |
2 | + | |
3 | +citApp.controller('UnidadeMedidaController', ['$scope', 'UnidadeMedidaRepository', '$translate', '$timeout', 'DominioRepository', | |
4 | + function UnidadeMedidaController($scope, UnidadeMedidaRepository, $translate, $timeout, DominioRepository) { | |
5 | + | |
6 | + $scope.unidadeMedida = {}; | |
7 | + | |
8 | + // Limpa formulário para novo cadastro | |
9 | + $scope.resetForm = function() { | |
10 | + $scope.limparUnidadeMedida(); | |
11 | + $scope.edit = true; | |
12 | + $timeout(function(){ | |
13 | + $scope.unidadeMedidaForm.$submitted = false; | |
14 | + $scope.unidadeMedidaForm.$setPristine(); | |
15 | + }); | |
16 | + }; | |
17 | + | |
18 | + // Atualiza pagina de pesquisa | |
19 | + $scope.atualizaPaginaPesquisa = function () { | |
20 | + angular.element('#searchUnidadeMedida').scope().fetchResult(); | |
21 | + }; | |
22 | + | |
23 | + // MODAL QUE CONFIRMA REMOVER DA CIDADE | |
24 | + $scope.remove = function(unidadeMedida){ | |
25 | + $scope.unidadeMedida = unidadeMedida; | |
26 | + $scope.$openModalConfirm({ | |
27 | + message: $translate.instant('MSG.CONFIRMA_EXCLUSAO'), | |
28 | + callback: function () { | |
29 | + UnidadeMedidaRepository.remove($scope.unidadeMedida).then(function() { | |
30 | + | |
31 | + $scope.$modalConfirmInstance.dismiss('cancel'); | |
32 | + $scope.showAlert("success", $translate.instant('MSG.REGISTRO_EXCLUIDO')); | |
33 | + angular.element('#searchUnidadeMedida').scope().fetchResult(); | |
34 | + | |
35 | + $scope.resetForm(); | |
36 | + }); | |
37 | + } | |
38 | + }); | |
39 | + }; | |
40 | + | |
41 | + // SALVA O UnidadeMedida | |
42 | + $scope.saveOrUpdate = function(){ | |
43 | + $scope.unidadeMedidaForm.$submitted = true; | |
44 | + | |
45 | + //verifica se o formulario está valido para salvar | |
46 | + if($scope.unidadeMedidaForm.$valid){ | |
47 | + | |
48 | + $scope.setLoadingSalva(true); | |
49 | + | |
50 | + UnidadeMedidaRepository.save($scope.unidadeMedida).then(function(result) { | |
51 | + $scope.unidadeMedida = result.originalElement; | |
52 | + $scope.showAlert("success", $translate.instant('MSG.REGISTRO_SALVO')); | |
53 | + $scope.unidadeMedidaForm.$submitted = false; | |
54 | + }); | |
55 | + $scope.setLoading(false); | |
56 | + }else{ | |
57 | + //Mensagem de erro de campos obrigatorios não preenchidos | |
58 | + $scope.showAlert('error', $translate.instant('VALIDACAO.ALERTA_OBRIGATORIOS'), " ", false); | |
59 | + } | |
60 | + }; | |
61 | + | |
62 | + // Limpa o formulario preenchido | |
63 | + $scope.limparUnidadeMedida = function(){ | |
64 | + $scope.unidadeMedida = {}; | |
65 | + }; | |
66 | + | |
67 | + // Consulta entidade e mostra no formulario | |
68 | + $scope.getUnidadeMedida = function(unidadeMedida, edit){ | |
69 | + $scope.setLoadingGet(true); | |
70 | + | |
71 | + UnidadeMedidaRepository.get(unidadeMedida.id).then(function(result) { | |
72 | + $scope.unidadeMedida = result.originalElement; | |
73 | + $scope.edit = edit; | |
74 | + $scope.setLoading(false); | |
75 | + }); | |
76 | + }; | |
77 | + | |
78 | + DominioRepository.findAllDominio('tipoNumerico').then(function(result) { | |
79 | + $scope.tipoNumericoList = result; | |
80 | + }); | |
81 | + | |
82 | +}]); | ... | ... |
cit-tabelas-corp-web/src/main/webapp/assets/js/angular/custom/controller/UnidadeMedidaListController.js
0 → 100644
... | ... | @@ -0,0 +1,43 @@ |
1 | +'use strict'; | |
2 | + | |
3 | +citApp.controller('UnidadeMedidaListController', ['$scope', 'UnidadeMedidaRepository', '$translate', '$timeout', 'DominioRepository', | |
4 | + function UnidadeMedidaListController($scope, UnidadeMedidaRepository, $translate, $timeout, DominioRepository) { | |
5 | + $scope.$showAdvancedFilters = false; | |
6 | + | |
7 | + $scope.resetForm = function() { | |
8 | + angular.element("#editUnidadeMedida").scope().resetForm(); | |
9 | + }; | |
10 | + | |
11 | + $scope.headers = [ {title : $translate.instant('LABEL.CODIGO'), value : 'codigo' } , | |
12 | + {title : $translate.instant('LABEL.DESCRICAO'), value : 'descricao' } , | |
13 | + {title : $translate.instant('CORPORATIVO.LABEL.TIPO_NUMERICO'), value : 'tipoNumerico.descricao' } , | |
14 | + {title : $translate.instant('LABEL.SIGLA'), value : 'sigla' }]; | |
15 | + | |
16 | + $scope.filterCriteria = { | |
17 | + start : 1, | |
18 | + dir : 'asc', | |
19 | + sort : 'id', | |
20 | + limit : 10, | |
21 | + fields: ['id', 'codigo', 'descricao', 'tipoNumerico.descricao', 'sigla'], | |
22 | + filters : [ {type : 'string', field : 'codigo'} , | |
23 | + {type : 'string', field : 'descricao'} , | |
24 | + {type : 'string', field : 'tipoNumerico.descricao', listaDominio : [] } , | |
25 | + {type : 'string', field : 'sigla' }] | |
26 | + }; | |
27 | + | |
28 | + DominioRepository.findAllDominio('tipoNumerico').then(function(result) { | |
29 | + $scope.filterCriteria.filters[2].listaDominio = result; | |
30 | + }); | |
31 | + | |
32 | + // ABRI UnidadeMedida SELECIONADA | |
33 | + $scope.abrirVisualizar = function(edit){ | |
34 | + var unidadeMedida = $scope.unidadeMedidaChecked; | |
35 | + | |
36 | + if(!unidadeMedida) { | |
37 | + $scope.showAlert('warning', !edit ? $translate.instant('MSG.SELECIONE_UM_ITEM_PARA_VISUALIZACAO') : $translate.instant('MSG.SELECIONE_UM_ITEM_PARA_EDICAO')); | |
38 | + return; | |
39 | + } | |
40 | + angular.element('#editUnidadeMedida').scope().getUnidadeMedida(unidadeMedida, edit); | |
41 | + $scope.$showPageEditWorkspace($scope.workspace); | |
42 | + }; | |
43 | +}]); | ... | ... |
cit-tabelas-corp-web/src/main/webapp/assets/js/angular/custom/repository/UnidadeMedidaRepository.js
0 → 100644
... | ... | @@ -0,0 +1,12 @@ |
1 | +'use strict'; | |
2 | + | |
3 | +citApp.factory('UnidadeMedidaRepository', ['RestangularTabelasCorp', 'AbstractRepository', function (restangularTabelasCorp, AbstractRepository) { | |
4 | + | |
5 | + function UnidadeMedidaRepository() { | |
6 | + AbstractRepository.call(this, restangularTabelasCorp, 'rest/unidadeMedida'); | |
7 | + } | |
8 | + | |
9 | + AbstractRepository.extend(UnidadeMedidaRepository); | |
10 | + | |
11 | + return new UnidadeMedidaRepository(); | |
12 | +}]); | ... | ... |
cit-tabelas-corp-web/src/main/webapp/html/unidadeMedida/unidadeMedida.html
0 → 100644
cit-tabelas-corp-web/src/main/webapp/html/unidadeMedida/unidadeMedidaEdit.html
0 → 100644
... | ... | @@ -0,0 +1,97 @@ |
1 | +<div id="editUnidadeMedida" class="page-content clearfix" ng-controller="UnidadeMedidaController"> | |
2 | + <div class="bar-buttons-action fixed"> | |
3 | + <div class="row"> | |
4 | + <div class="col-sm-8 text-left"> | |
5 | + | |
6 | + <button class="btn btn-clear" ng-click="saveOrUpdate()" ng-show="edit"> | |
7 | + <i class="fa fa-save green"></i> <translate>LABEL.SALVAR</translate> | |
8 | + </button> | |
9 | + | |
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> | |
12 | + </button> | |
13 | + | |
14 | + <button class="btn btn-clear" ng-show="!edit" ng-click="edit = true"> | |
15 | + <i class="fa fa-pencil blue"></i> | |
16 | + <translate>LABEL.EDITAR</translate> | |
17 | + </button> | |
18 | + | |
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> | |
21 | + </button> | |
22 | + | |
23 | + <bloquear-desbloquear ng-model="unidadeMedida" ng-repository="UnidadeMedidaRepository" ng-edit="edit" form="unidadeMedidaForm"></bloquear-desbloquear> | |
24 | + | |
25 | + <button class="btn btn-clear" ng-click="$showPageSearchWorkspace(workspace); atualizaPaginaPesquisa();"> | |
26 | + <i class="fa fa-search"></i> <translate>LABEL.PESQUISAR</translate> | |
27 | + </button> | |
28 | + | |
29 | + </div><!-- .col --> | |
30 | + | |
31 | + <div class="col-sm-4 text-right"> | |
32 | + | |
33 | + <favorito/> | |
34 | + | |
35 | + <help-button workspace="workspace" /> | |
36 | + | |
37 | + </div><!-- .col --> | |
38 | + </div><!-- .row --> | |
39 | + </div><!-- .bar-buttons-action --> | |
40 | + | |
41 | + <breadcrumb ng-workspace="workspace"></breadcrumb> | |
42 | + | |
43 | + <form name="unidadeMedidaForm"> | |
44 | + <p> | |
45 | + <small>( <span class="red">*</span> ) <translate>LABEL.CAMPOS_OBRIGATORIOS</translate></small> | |
46 | + </p> | |
47 | + | |
48 | + <fieldset> | |
49 | + | |
50 | + <legend><translate>CORPORATIVO.LABEL.DADOS_UNIDADE_MEDIDA</translate></legend> | |
51 | + | |
52 | + <div class="row"> | |
53 | + | |
54 | + <div class="col-md-6"> | |
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"/> | |
57 | + | |
58 | + </div> | |
59 | + | |
60 | + <div class="col-md-6"> | |
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" /> | |
63 | + | |
64 | + </div> | |
65 | + </div> | |
66 | + <div class="row"> | |
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 | + | |
71 | + </div> | |
72 | + | |
73 | + <div class="col-md-4"> | |
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" /> | |
76 | + | |
77 | + </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> | |
84 | + </div> | |
85 | + | |
86 | + </div> | |
87 | + | |
88 | + </fieldset> | |
89 | + </form> | |
90 | +</div><!-- .page-content --> | |
91 | + | |
92 | + | |
93 | + | |
94 | + | |
95 | + | |
96 | + | |
97 | + | ... | ... |
cit-tabelas-corp-web/src/main/webapp/html/unidadeMedida/unidadeMedidaList.html
0 → 100644
... | ... | @@ -0,0 +1,46 @@ |
1 | +<div id="searchUnidadeMedida" class="page-content" ng-controller="UnidadeMedidaListController"> | |
2 | + <div class="bar-buttons-action fixed"> | |
3 | + <div class="row"> | |
4 | + <div class="col-sm-8 text-left"> | |
5 | + | |
6 | + <button class="btn btn-clear" ng-click="$showPageEditWorkspace(workspace); resetForm();"> | |
7 | + <i class="fa fa-plus-circle yellow-dark"></i> | |
8 | + <translate>LABEL.CADASTRAR</translate> | |
9 | + </button> | |
10 | + | |
11 | + <button class="btn btn-clear" ng-click="abrirVisualizar(false);"> | |
12 | + <i class="fa fa-search blue"></i> | |
13 | + <translate>LABEL.VISUALIZAR</translate> | |
14 | + </button> | |
15 | + | |
16 | + <button class="btn btn-clear" ng-click="abrirVisualizar(true);"> | |
17 | + <i class="fa fa-pencil blue"></i> | |
18 | + <translate>LABEL.EDITAR</translate> | |
19 | + </button> | |
20 | + | |
21 | + <button class="btn btn-clear" ng-click="remove();"> | |
22 | + <i class="fa fa-times red"></i> | |
23 | + <translate>LABEL.REMOVER</translate> | |
24 | + </button> | |
25 | + | |
26 | + <span class="divider-vertical"></span> | |
27 | + | |
28 | + <filtros ng-filter="filterCriteria" ng-workspace="workspace"></filtros> | |
29 | + | |
30 | + </div><!-- .col --> | |
31 | + | |
32 | + <div class="col-sm-4 text-right"> | |
33 | + | |
34 | + <favorito/> | |
35 | + | |
36 | + <help-button workspace="workspace" /> | |
37 | + | |
38 | + </div><!-- .col --> | |
39 | + </div><!-- .row --> | |
40 | + </div><!-- .bar-buttons-action --> | |
41 | + | |
42 | + <breadcrumb ng-workspace="workspace"></breadcrumb> | |
43 | + | |
44 | + <list-view ng-lista="unidadeMedidaList" ng-repository="UnidadeMedidaRepository" ng-use-custom-remove="false" ng-headers="headers" ng-filter-criteria="filterCriteria" ng-item-selecionado="unidadeMedidaChecked"></list-view> | |
45 | + | |
46 | +</div><!-- .page-content --> | ... | ... |