@stiunb/unb-lib-components 18.0.22 → 18.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/unb-pessoa/unb-pessoa-email-form/unb-pessoa-email-form.mjs +34 -11
- package/esm2022/lib/unb-pessoa/unb-pessoa-email-form/unb-pessoa-email-list.mjs +65 -47
- package/esm2022/lib/unb-pessoa/unb-pessoa-endereco-form/unb-pessoa-endereco-form.mjs +102 -14
- package/esm2022/lib/unb-pessoa/unb-pessoa-endereco-form/unb-pessoa-endereco-list.mjs +71 -55
- package/esm2022/lib/unb-pessoa/unb-pessoa-form/unb-pessoa-form.component.mjs +227 -42
- package/esm2022/lib/unb-pessoa/unb-pessoa-models/unb-pessoa-email.model.mjs +1 -1
- package/esm2022/lib/unb-pessoa/unb-pessoa-models/unb-pessoa-endereco.model.mjs +1 -1
- package/esm2022/lib/unb-pessoa/unb-pessoa-models/unb-pessoa.model.mjs +2 -1
- package/esm2022/lib/unb-pessoa/unb-pessoa-pesquisar/unb-pessoa-pesquisar.component.mjs +141 -8
- package/esm2022/lib/unb-pessoa/unb-pessoa-telefone-form/unb-pessoa-telefone-form.mjs +62 -8
- package/esm2022/lib/unb-pessoa/unb-pessoa-telefone-form/unb-pessoa-telefone-list.mjs +62 -32
- package/esm2022/lib/unb-pessoa/unb-pessoa.module.mjs +9 -1
- package/esm2022/lib/unb-pessoa/unb-pessoa.service.mjs +9 -9
- package/esm2022/lib/unb-pessoa/unb-tipo-pessoa.enum.mjs +1 -1
- package/esm2022/lib/unb-usuario/oidc-decoded-token.mjs +1 -1
- package/esm2022/lib/unb-usuario/oidc-user-data.mjs +1 -1
- package/esm2022/public-api.mjs +14 -13
- package/esm2022/stiunb-unb-lib-components.mjs +5 -0
- package/fesm2022/stiunb-unb-lib-components.mjs +2469 -0
- package/fesm2022/stiunb-unb-lib-components.mjs.map +1 -0
- package/index.d.ts +1 -1
- package/lib/unb-pessoa/unb-pessoa-email-form/unb-pessoa-email-form.d.ts +3 -3
- package/lib/unb-pessoa/unb-pessoa-email-form/unb-pessoa-email-list.d.ts +6 -5
- package/lib/unb-pessoa/unb-pessoa-endereco-form/unb-pessoa-endereco-form.d.ts +6 -3
- package/lib/unb-pessoa/unb-pessoa-endereco-form/unb-pessoa-endereco-list.d.ts +6 -5
- package/lib/unb-pessoa/unb-pessoa-form/unb-pessoa-form.component.d.ts +17 -5
- package/lib/unb-pessoa/unb-pessoa-models/unb-pessoa-email.model.d.ts +1 -0
- package/lib/unb-pessoa/unb-pessoa-models/unb-pessoa-endereco.model.d.ts +3 -2
- package/lib/unb-pessoa/unb-pessoa-models/unb-pessoa.model.d.ts +5 -4
- package/lib/unb-pessoa/unb-pessoa-pesquisar/unb-pessoa-pesquisar.component.d.ts +14 -1
- package/lib/unb-pessoa/unb-pessoa-telefone-form/unb-pessoa-telefone-form.d.ts +2 -2
- package/lib/unb-pessoa/unb-pessoa-telefone-form/unb-pessoa-telefone-list.d.ts +6 -5
- package/lib/unb-pessoa/unb-pessoa.module.d.ts +20 -18
- package/lib/unb-pessoa/unb-pessoa.service.d.ts +2 -1
- package/package.json +5 -5
- package/public-api.d.ts +10 -10
- package/esm2022/unb-lib-components.mjs +0 -5
- package/fesm2022/unb-lib-components.mjs +0 -1923
- package/fesm2022/unb-lib-components.mjs.map +0 -1
|
@@ -0,0 +1,2469 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Component, Input, NgModule, ViewChild, Inject, EventEmitter, Output } from '@angular/core';
|
|
3
|
+
import { Subject, BehaviorSubject, catchError, throwError, of, map, forkJoin } from 'rxjs';
|
|
4
|
+
import * as i4 from '@angular/common';
|
|
5
|
+
import { CommonModule, DatePipe, CurrencyPipe } from '@angular/common';
|
|
6
|
+
import * as i5 from '@angular/material/icon';
|
|
7
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
8
|
+
import * as i7 from '@angular/material/button';
|
|
9
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
10
|
+
import * as i4$1 from '@angular/material/sidenav';
|
|
11
|
+
import { MatSidenav, MatSidenavModule } from '@angular/material/sidenav';
|
|
12
|
+
import * as i1 from '@angular/cdk/layout';
|
|
13
|
+
import { LayoutModule } from '@angular/cdk/layout';
|
|
14
|
+
import * as i3$1 from '@angular/material/toolbar';
|
|
15
|
+
import { MatToolbarModule } from '@angular/material/toolbar';
|
|
16
|
+
import * as i3 from '@angular/material/menu';
|
|
17
|
+
import { MatMenuModule } from '@angular/material/menu';
|
|
18
|
+
import * as i5$1 from '@angular/material/divider';
|
|
19
|
+
import { MatDividerModule } from '@angular/material/divider';
|
|
20
|
+
import * as i7$1 from '@angular/material/card';
|
|
21
|
+
import { MatCardModule } from '@angular/material/card';
|
|
22
|
+
import * as i8 from '@angular/material/tooltip';
|
|
23
|
+
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
24
|
+
import { MatListModule } from '@angular/material/list';
|
|
25
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
26
|
+
import * as i5$2 from '@angular/forms';
|
|
27
|
+
import { FormsModule } from '@angular/forms';
|
|
28
|
+
import * as i10 from '@angular/material/core';
|
|
29
|
+
import { MatNativeDateModule } from '@angular/material/core';
|
|
30
|
+
import * as i14 from '@angular/material/datepicker';
|
|
31
|
+
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
32
|
+
import { MatExpansionModule } from '@angular/material/expansion';
|
|
33
|
+
import * as i7$2 from '@angular/material/form-field';
|
|
34
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
35
|
+
import * as i8$1 from '@angular/material/input';
|
|
36
|
+
import { MatInputModule } from '@angular/material/input';
|
|
37
|
+
import { MatPaginatorModule } from '@angular/material/paginator';
|
|
38
|
+
import * as i13 from '@angular/material/progress-bar';
|
|
39
|
+
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
40
|
+
import * as i9$1 from '@angular/material/progress-spinner';
|
|
41
|
+
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
42
|
+
import * as i10$1 from '@angular/material/radio';
|
|
43
|
+
import { MatRadioModule } from '@angular/material/radio';
|
|
44
|
+
import * as i9 from '@angular/material/select';
|
|
45
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
46
|
+
import * as i1$2 from '@angular/material/snack-bar';
|
|
47
|
+
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
|
48
|
+
import * as i3$2 from '@angular/material/dialog';
|
|
49
|
+
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
|
50
|
+
import * as i1$1 from '@angular/common/http';
|
|
51
|
+
import { HttpHeaders } from '@angular/common/http';
|
|
52
|
+
import * as i6 from '@angular/cdk/drag-drop';
|
|
53
|
+
import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
|
|
54
|
+
|
|
55
|
+
class UnbMensagemModel {
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// faz com que a enum seja uma contagem de 0 a 3
|
|
59
|
+
var UnbTipoMensagemEnum;
|
|
60
|
+
(function (UnbTipoMensagemEnum) {
|
|
61
|
+
UnbTipoMensagemEnum[UnbTipoMensagemEnum["SUCCESS"] = 0] = "SUCCESS";
|
|
62
|
+
UnbTipoMensagemEnum[UnbTipoMensagemEnum["INFO"] = 1] = "INFO";
|
|
63
|
+
UnbTipoMensagemEnum[UnbTipoMensagemEnum["WARNING"] = 2] = "WARNING";
|
|
64
|
+
UnbTipoMensagemEnum[UnbTipoMensagemEnum["DANGER"] = 3] = "DANGER";
|
|
65
|
+
})(UnbTipoMensagemEnum || (UnbTipoMensagemEnum = {}));
|
|
66
|
+
class UnbMensagemService {
|
|
67
|
+
constructor() {
|
|
68
|
+
this.messageSubject = new Subject();
|
|
69
|
+
// [background_color, font_color, border_color]
|
|
70
|
+
this.cores = [
|
|
71
|
+
['#dff0d8', '#3c763d', '#d6e9c6'], // SUCCESS
|
|
72
|
+
['#d9edf7', '#31708f', '#bce8f1'], // INFO
|
|
73
|
+
['#fcf8e3', '#8a6d3b', '#faebcc'], // WARNING
|
|
74
|
+
['#f2dede', '#a94442', '#ebccd1'] // DANGER
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @param message mensagem que vai aparecer na tela
|
|
80
|
+
* @param tipo tipo da mensagem: success, info, warning, danger.
|
|
81
|
+
*/
|
|
82
|
+
showMessage(message, type) {
|
|
83
|
+
this.messageSubject.next(this.createAlertMessage(message, ...this.cores[type]));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Esconde o componente de mensagem passando um valor vazio
|
|
87
|
+
*/
|
|
88
|
+
hideMessage() {
|
|
89
|
+
this.messageSubject.next(new UnbMensagemModel());
|
|
90
|
+
}
|
|
91
|
+
getMessageSubject() {
|
|
92
|
+
return this.messageSubject.asObservable();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @param message Cria a mensagem passando os parametros com base nas cores criadas no construturo
|
|
97
|
+
* @param background_color cor de fundo
|
|
98
|
+
* @param font_color cor da fonte
|
|
99
|
+
* @param border_color cor da borda
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
createAlertMessage(message, background_color, font_color, border_color) {
|
|
103
|
+
return { message, background_color, font_color, border_color };
|
|
104
|
+
}
|
|
105
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbMensagemService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
106
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbMensagemService, providedIn: 'root' }); }
|
|
107
|
+
}
|
|
108
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbMensagemService, decorators: [{
|
|
109
|
+
type: Injectable,
|
|
110
|
+
args: [{
|
|
111
|
+
providedIn: 'root'
|
|
112
|
+
}]
|
|
113
|
+
}], ctorParameters: () => [] });
|
|
114
|
+
|
|
115
|
+
class UnbMensagemComponent {
|
|
116
|
+
constructor(mensagemService) {
|
|
117
|
+
this.mensagemService = mensagemService;
|
|
118
|
+
}
|
|
119
|
+
ngOnInit() {
|
|
120
|
+
this.subscription = this.mensagemService.getMessageSubject().subscribe(message => {
|
|
121
|
+
if (message) {
|
|
122
|
+
this.alertMessage = message;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
//this.alertMessage = undefined;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
ngAfterContentInit() {
|
|
130
|
+
if (this.mensagem != null && this.mensagem != undefined) {
|
|
131
|
+
this.showMessage(this.mensagem, this.getTipo());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Esconde o componente de mensagem
|
|
136
|
+
*/
|
|
137
|
+
hide() {
|
|
138
|
+
this.mensagemService.hideMessage();
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
*
|
|
142
|
+
* @param message mensagem que vai aparecer na tela
|
|
143
|
+
* @param tipo tipo da mensagem: success, info, warning, danger.
|
|
144
|
+
*/
|
|
145
|
+
showMessage(message, tipo) {
|
|
146
|
+
this.mensagemService.showMessage(message, tipo);
|
|
147
|
+
}
|
|
148
|
+
ngOnDestroy() {
|
|
149
|
+
// unsubscribe to ensure no memory leaks
|
|
150
|
+
if (this.subscription) {
|
|
151
|
+
this.subscription.unsubscribe();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Recupera qual o tipo da mensagem.
|
|
156
|
+
* O método tenta achar o tipo conforme o valor informado, incluido erros de digitação
|
|
157
|
+
*
|
|
158
|
+
* @returns o valor correspondente do informa. Caso não encontra, emite um erro e coloca retorna o padrão info como default
|
|
159
|
+
*/
|
|
160
|
+
getTipo() {
|
|
161
|
+
if (this.tipo != null && this.tipo != undefined) {
|
|
162
|
+
let valor = this.tipo.toLowerCase();
|
|
163
|
+
if (valor == 'warning' || valor == 'warn' || valor == 'aviso') {
|
|
164
|
+
return UnbTipoMensagemEnum.WARNING;
|
|
165
|
+
}
|
|
166
|
+
else if (valor == 'sucesso' || valor == 'success' || valor == 'sucess') {
|
|
167
|
+
return UnbTipoMensagemEnum.SUCCESS;
|
|
168
|
+
}
|
|
169
|
+
else if (valor == 'danger' || valor == 'erro' || valor == 'error') {
|
|
170
|
+
return UnbTipoMensagemEnum.DANGER;
|
|
171
|
+
}
|
|
172
|
+
else if (valor == 'info') {
|
|
173
|
+
return UnbTipoMensagemEnum.INFO;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// o padrao eh o info
|
|
177
|
+
console.log("Erro: Input [tipo] do componente unb-mensagem tem um valor inválido. Utilize: " + UnbTipoMensagemEnum.SUCCESS + " | " + UnbTipoMensagemEnum.INFO + " | " + UnbTipoMensagemEnum.WARNING + " | " + UnbTipoMensagemEnum.DANGER);
|
|
178
|
+
return UnbTipoMensagemEnum.INFO;
|
|
179
|
+
}
|
|
180
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbMensagemComponent, deps: [{ token: UnbMensagemService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
181
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: UnbMensagemComponent, selector: "unb-mensagem", inputs: { mensagem: "mensagem", tipo: "tipo" }, ngImport: i0, template: "\r\n<div class=\"alert\" *ngIf=\"alertMessage && alertMessage.message && alertMessage.message.length > 1\" [ngStyle]=\"{background: alertMessage.background_color, 'border-color': alertMessage.border_color}\"> \r\n <div class=\"mensagem\" [ngStyle]=\"{color: alertMessage.font_color}\" [innerHtml]= \"alertMessage.message\"></div>\r\n <a class=\"close\" (click)=\"hide()\" aria-label=\"fechar\" [ngStyle]=\"{color: alertMessage.font_color}\">x</a>\r\n</div> \r\n\r\n", styles: [".alert{display:flex;text-align:center;justify-content:space-between;border-top-color:darken(1px,5%);padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:4px;font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:15px;line-height:1.42857143;font-weight:400;border-color:#fff}.mensagem{margin:0 auto}.close{float:right;font-size:21px;font-weight:700;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;cursor:pointer;justify-content:flex-end}.close:hover{opacity:.7}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] }); }
|
|
182
|
+
}
|
|
183
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbMensagemComponent, decorators: [{
|
|
184
|
+
type: Component,
|
|
185
|
+
args: [{ selector: 'unb-mensagem', template: "\r\n<div class=\"alert\" *ngIf=\"alertMessage && alertMessage.message && alertMessage.message.length > 1\" [ngStyle]=\"{background: alertMessage.background_color, 'border-color': alertMessage.border_color}\"> \r\n <div class=\"mensagem\" [ngStyle]=\"{color: alertMessage.font_color}\" [innerHtml]= \"alertMessage.message\"></div>\r\n <a class=\"close\" (click)=\"hide()\" aria-label=\"fechar\" [ngStyle]=\"{color: alertMessage.font_color}\">x</a>\r\n</div> \r\n\r\n", styles: [".alert{display:flex;text-align:center;justify-content:space-between;border-top-color:darken(1px,5%);padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:4px;font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:15px;line-height:1.42857143;font-weight:400;border-color:#fff}.mensagem{margin:0 auto}.close{float:right;font-size:21px;font-weight:700;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;cursor:pointer;justify-content:flex-end}.close:hover{opacity:.7}\n"] }]
|
|
186
|
+
}], ctorParameters: () => [{ type: UnbMensagemService }], propDecorators: { mensagem: [{
|
|
187
|
+
type: Input
|
|
188
|
+
}], tipo: [{
|
|
189
|
+
type: Input
|
|
190
|
+
}] } });
|
|
191
|
+
|
|
192
|
+
class UnbMensagemModule {
|
|
193
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbMensagemModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
194
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.1.2", ngImport: i0, type: UnbMensagemModule, declarations: [UnbMensagemComponent], imports: [CommonModule,
|
|
195
|
+
MatIconModule,
|
|
196
|
+
MatButtonModule], exports: [UnbMensagemComponent] }); }
|
|
197
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbMensagemModule, imports: [CommonModule,
|
|
198
|
+
MatIconModule,
|
|
199
|
+
MatButtonModule] }); }
|
|
200
|
+
}
|
|
201
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbMensagemModule, decorators: [{
|
|
202
|
+
type: NgModule,
|
|
203
|
+
args: [{
|
|
204
|
+
declarations: [UnbMensagemComponent],
|
|
205
|
+
imports: [CommonModule,
|
|
206
|
+
MatIconModule,
|
|
207
|
+
MatButtonModule],
|
|
208
|
+
exports: [UnbMensagemComponent]
|
|
209
|
+
}]
|
|
210
|
+
}] });
|
|
211
|
+
|
|
212
|
+
class UnbUsuarioModel {
|
|
213
|
+
constructor() {
|
|
214
|
+
this.autenticado = false;
|
|
215
|
+
this.usuarioNome = "";
|
|
216
|
+
this.perfis = [];
|
|
217
|
+
this.expiration = 0;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
class UnbAuthService {
|
|
222
|
+
constructor() {
|
|
223
|
+
// Inicializamos o BehaviorSubject com uma lista vazia de perfis
|
|
224
|
+
this.usuarioSubject = new BehaviorSubject(new UnbUsuarioModel);
|
|
225
|
+
this.usuario$ = this.usuarioSubject.asObservable();
|
|
226
|
+
this.usuarioModel = new UnbUsuarioModel();
|
|
227
|
+
}
|
|
228
|
+
initiate(oidcSecurityService) {
|
|
229
|
+
this.oidcSecurityService = oidcSecurityService;
|
|
230
|
+
this.logAuthenticatedState();
|
|
231
|
+
}
|
|
232
|
+
logAuthenticatedState() {
|
|
233
|
+
this.oidcSecurityService.checkAuth().subscribe((loginResponse) => {
|
|
234
|
+
if (!loginResponse.isAuthenticated) {
|
|
235
|
+
this.usuarioModel.autenticado = false;
|
|
236
|
+
this.usuarioSubject.next(this.usuarioModel);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
this.usuarioModel.autenticado = true;
|
|
240
|
+
this.setUserData(loginResponse.userData);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
setUserData(userData) {
|
|
245
|
+
const nomeCompleto = userData.given_name.trim();
|
|
246
|
+
const nomes = nomeCompleto.split(' ');
|
|
247
|
+
this.usuarioModel.usuarioNome = nomes.length > 1
|
|
248
|
+
? `${nomes[0]} ${nomes[nomes.length - 1]}`
|
|
249
|
+
: nomes[0];
|
|
250
|
+
this.oidcSecurityService.getPayloadFromAccessToken().subscribe((authResult) => {
|
|
251
|
+
this.usuarioModel.perfis = authResult.realm_access.roles || [];
|
|
252
|
+
// Atualiza o BehaviorSubject com o modelo atualizado
|
|
253
|
+
this.usuarioSubject.next(this.usuarioModel);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
login() {
|
|
257
|
+
this.oidcSecurityService.authorize();
|
|
258
|
+
}
|
|
259
|
+
logout() {
|
|
260
|
+
this.oidcSecurityService
|
|
261
|
+
.logoff()
|
|
262
|
+
.subscribe(() => this.usuarioSubject.next(new UnbUsuarioModel()));
|
|
263
|
+
}
|
|
264
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbAuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
265
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbAuthService, providedIn: 'root' }); }
|
|
266
|
+
}
|
|
267
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbAuthService, decorators: [{
|
|
268
|
+
type: Injectable,
|
|
269
|
+
args: [{
|
|
270
|
+
providedIn: 'root'
|
|
271
|
+
}]
|
|
272
|
+
}], ctorParameters: () => [] });
|
|
273
|
+
|
|
274
|
+
class UnbUsuarioComponent {
|
|
275
|
+
constructor(authService) {
|
|
276
|
+
this.authService = authService;
|
|
277
|
+
}
|
|
278
|
+
ngOnInit() {
|
|
279
|
+
if (this.oidcSecurityService == null) {
|
|
280
|
+
console.log("Erro: oidcService está null!");
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
this.authService.initiate(this.oidcSecurityService);
|
|
284
|
+
this.usuario$ = this.authService.usuario$;
|
|
285
|
+
}
|
|
286
|
+
login() {
|
|
287
|
+
this.authService.login();
|
|
288
|
+
}
|
|
289
|
+
logout() {
|
|
290
|
+
this.authService.logout();
|
|
291
|
+
}
|
|
292
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbUsuarioComponent, deps: [{ token: UnbAuthService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
293
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: UnbUsuarioComponent, selector: "unb-usuario", inputs: { oidcSecurityService: "oidcSecurityService" }, ngImport: i0, template: "<button mat-mini-fab color=\"primary\" aria-label=\"Login Button\" [matMenuTriggerFor]=\"menu\">\r\n <mat-icon>person</mat-icon>\r\n</button>\r\n<mat-menu #menu=\"matMenu\">\r\n <div *ngIf=\"usuario$ | async as usuario\"> \r\n <mat-card-header class=\"menuHeader\" *ngIf=\"usuario && usuario.autenticado; else notAuthenticated\">\r\n <mat-card-title>\r\n <div class=\"user-info-container\">\r\n <span>{{ usuario.usuarioNome }}</span>\r\n <mat-icon matTooltip=\"{{ usuario.perfis.join(', ') }}\" aria-label=\"Perfis de usu\u00E1rio\" *ngIf=\"usuario.perfis\">\r\n account_circle\r\n </mat-icon>\r\n </div>\r\n </mat-card-title>\r\n </mat-card-header>\r\n\r\n <ng-template #notAuthenticated>\r\n <mat-card-header class=\"menuHeader\">\r\n <button mat-menu-item (click)=\"login()\">\r\n <mat-icon>login</mat-icon>\r\n <span>Login</span>\r\n </button>\r\n </mat-card-header>\r\n </ng-template>\r\n\r\n <mat-divider *ngIf=\"usuario.autenticado\"></mat-divider>\r\n\r\n <mat-card-actions *ngIf=\"usuario.autenticado\">\r\n <button mat-menu-item (click)=\"logout()\">\r\n <mat-icon>exit_to_app</mat-icon>\r\n <span>Sair</span>\r\n </button>\r\n </mat-card-actions>\r\n </div>\r\n</mat-menu>", styles: [".sidenav-container{height:100%}.sidenav{width:200px}.sidenav .mat-toolbar{background:inherit}.mat-toolbar.mat-primary{position:sticky;top:0;z-index:1}button.login_button{outline:none;padding:0;border:none;background:none;cursor:pointer}.mat-card{background:#036;padding:5px 20px 0 0}.menu{min-width:500px;max-width:400px}.menuHeader{padding:10px}.user-info-container{display:flex;align-items:center;justify-content:center;gap:8px}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i3.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i3.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i5$1.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "component", type: i7.MatMiniFabButton, selector: "button[mat-mini-fab]", exportAs: ["matButton"] }, { kind: "directive", type: i7$1.MatCardActions, selector: "mat-card-actions", inputs: ["align"], exportAs: ["matCardActions"] }, { kind: "component", type: i7$1.MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: i7$1.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "directive", type: i8.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }] }); }
|
|
294
|
+
}
|
|
295
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbUsuarioComponent, decorators: [{
|
|
296
|
+
type: Component,
|
|
297
|
+
args: [{ selector: 'unb-usuario', template: "<button mat-mini-fab color=\"primary\" aria-label=\"Login Button\" [matMenuTriggerFor]=\"menu\">\r\n <mat-icon>person</mat-icon>\r\n</button>\r\n<mat-menu #menu=\"matMenu\">\r\n <div *ngIf=\"usuario$ | async as usuario\"> \r\n <mat-card-header class=\"menuHeader\" *ngIf=\"usuario && usuario.autenticado; else notAuthenticated\">\r\n <mat-card-title>\r\n <div class=\"user-info-container\">\r\n <span>{{ usuario.usuarioNome }}</span>\r\n <mat-icon matTooltip=\"{{ usuario.perfis.join(', ') }}\" aria-label=\"Perfis de usu\u00E1rio\" *ngIf=\"usuario.perfis\">\r\n account_circle\r\n </mat-icon>\r\n </div>\r\n </mat-card-title>\r\n </mat-card-header>\r\n\r\n <ng-template #notAuthenticated>\r\n <mat-card-header class=\"menuHeader\">\r\n <button mat-menu-item (click)=\"login()\">\r\n <mat-icon>login</mat-icon>\r\n <span>Login</span>\r\n </button>\r\n </mat-card-header>\r\n </ng-template>\r\n\r\n <mat-divider *ngIf=\"usuario.autenticado\"></mat-divider>\r\n\r\n <mat-card-actions *ngIf=\"usuario.autenticado\">\r\n <button mat-menu-item (click)=\"logout()\">\r\n <mat-icon>exit_to_app</mat-icon>\r\n <span>Sair</span>\r\n </button>\r\n </mat-card-actions>\r\n </div>\r\n</mat-menu>", styles: [".sidenav-container{height:100%}.sidenav{width:200px}.sidenav .mat-toolbar{background:inherit}.mat-toolbar.mat-primary{position:sticky;top:0;z-index:1}button.login_button{outline:none;padding:0;border:none;background:none;cursor:pointer}.mat-card{background:#036;padding:5px 20px 0 0}.menu{min-width:500px;max-width:400px}.menuHeader{padding:10px}.user-info-container{display:flex;align-items:center;justify-content:center;gap:8px}\n"] }]
|
|
298
|
+
}], ctorParameters: () => [{ type: UnbAuthService }], propDecorators: { oidcSecurityService: [{
|
|
299
|
+
type: Input
|
|
300
|
+
}] } });
|
|
301
|
+
|
|
302
|
+
class UnbNavBarComponent {
|
|
303
|
+
constructor(observer) {
|
|
304
|
+
this.observer = observer;
|
|
305
|
+
this.nomeSistema = "Nome do Sistema"; /* O nome do sistema */
|
|
306
|
+
this.menuSize = 300; /** O tamanho do menu em px */
|
|
307
|
+
this.widthToHideMenu = 800; /* O tamanho da tela ateh esconder o menu */
|
|
308
|
+
this.contentBackgroundColor = '#f0f3f7'; /* A cor do Content */
|
|
309
|
+
this.containerPadding = 10; /* O tamanho do padding to container que fica o content */
|
|
310
|
+
this.isMobile = true;
|
|
311
|
+
}
|
|
312
|
+
ngOnInit() {
|
|
313
|
+
this.observer.observe(['(max-width: ' + this.widthToHideMenu + 'px)']).subscribe((screenSize) => {
|
|
314
|
+
if (screenSize.matches) {
|
|
315
|
+
this.isMobile = true;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
this.isMobile = false;
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbNavBarComponent, deps: [{ token: i1.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
323
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: UnbNavBarComponent, selector: "unb-nav-bar", inputs: { nomeSistema: "nomeSistema", menuSize: "menuSize", widthToHideMenu: "widthToHideMenu", contentBackgroundColor: "contentBackgroundColor", containerPadding: "containerPadding", oidcSecurityService: "oidcSecurityService" }, viewQueries: [{ propertyName: "sidenav", first: true, predicate: MatSidenav, descendants: true }], ngImport: i0, template: "<div class=\"example-container\" >\r\n <mat-toolbar class=\"example-toolbar\">\r\n <button mat-icon-button class=\"minifab\" type=\"button\" aria-label=\"Toggle sidenav\" color=\"accent\" (click)=\"snav.toggle()\"><mat-icon>menu</mat-icon></button> \r\n <img src=\"assets/img/unb_icon_branco.svg\" alt=\"\" style=\"width: 40px\"> \r\n <span style=\"color: white;\">{{nomeSistema}}</span>\r\n <span class=\"spacer\"></span> \r\n <unb-usuario [oidcSecurityService]=\"oidcSecurityService\"></unb-usuario>\r\n </mat-toolbar>\r\n\r\n <mat-sidenav-container class=\"example-sidenav-container\" [ngStyle]=\"{'background-color': contentBackgroundColor}\" > \r\n <mat-sidenav #snav [mode]=\"isMobile ? 'over' : 'side'\" [opened]=\"isMobile ? 'false' : 'true'\" [style.max-width.px]=\"menuSize\" > \r\n <ng-content select=\"[menu]\"></ng-content> \r\n </mat-sidenav>\r\n\r\n <mat-sidenav-content [ngStyle]=\"{'padding.px': containerPadding}\">\r\n <ng-content select=\"[body]\"></ng-content> \r\n </mat-sidenav-content>\r\n\r\n </mat-sidenav-container>\r\n</div>", styles: [".example-container{display:flex;flex-direction:column;position:absolute;inset:0}.example-is-mobile .example-toolbar{position:fixed;z-index:2}.spacer{flex:1 1 auto}.example-sidenav-container{flex:1}.example-is-mobile .example-sidenav-container{flex:1 0 auto}.minifab{margin:5px;color:#fff;fill:#fff}\n"], dependencies: [{ kind: "directive", type: i4.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: i3$1.MatToolbar, selector: "mat-toolbar", inputs: ["color"], exportAs: ["matToolbar"] }, { kind: "component", type: i4$1.MatSidenav, selector: "mat-sidenav", inputs: ["fixedInViewport", "fixedTopGap", "fixedBottomGap"], exportAs: ["matSidenav"] }, { kind: "component", type: i4$1.MatSidenavContainer, selector: "mat-sidenav-container", exportAs: ["matSidenavContainer"] }, { kind: "component", type: i4$1.MatSidenavContent, selector: "mat-sidenav-content" }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i7.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: UnbUsuarioComponent, selector: "unb-usuario", inputs: ["oidcSecurityService"] }] }); }
|
|
324
|
+
}
|
|
325
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbNavBarComponent, decorators: [{
|
|
326
|
+
type: Component,
|
|
327
|
+
args: [{ selector: 'unb-nav-bar', template: "<div class=\"example-container\" >\r\n <mat-toolbar class=\"example-toolbar\">\r\n <button mat-icon-button class=\"minifab\" type=\"button\" aria-label=\"Toggle sidenav\" color=\"accent\" (click)=\"snav.toggle()\"><mat-icon>menu</mat-icon></button> \r\n <img src=\"assets/img/unb_icon_branco.svg\" alt=\"\" style=\"width: 40px\"> \r\n <span style=\"color: white;\">{{nomeSistema}}</span>\r\n <span class=\"spacer\"></span> \r\n <unb-usuario [oidcSecurityService]=\"oidcSecurityService\"></unb-usuario>\r\n </mat-toolbar>\r\n\r\n <mat-sidenav-container class=\"example-sidenav-container\" [ngStyle]=\"{'background-color': contentBackgroundColor}\" > \r\n <mat-sidenav #snav [mode]=\"isMobile ? 'over' : 'side'\" [opened]=\"isMobile ? 'false' : 'true'\" [style.max-width.px]=\"menuSize\" > \r\n <ng-content select=\"[menu]\"></ng-content> \r\n </mat-sidenav>\r\n\r\n <mat-sidenav-content [ngStyle]=\"{'padding.px': containerPadding}\">\r\n <ng-content select=\"[body]\"></ng-content> \r\n </mat-sidenav-content>\r\n\r\n </mat-sidenav-container>\r\n</div>", styles: [".example-container{display:flex;flex-direction:column;position:absolute;inset:0}.example-is-mobile .example-toolbar{position:fixed;z-index:2}.spacer{flex:1 1 auto}.example-sidenav-container{flex:1}.example-is-mobile .example-sidenav-container{flex:1 0 auto}.minifab{margin:5px;color:#fff;fill:#fff}\n"] }]
|
|
328
|
+
}], ctorParameters: () => [{ type: i1.BreakpointObserver }], propDecorators: { nomeSistema: [{
|
|
329
|
+
type: Input
|
|
330
|
+
}], menuSize: [{
|
|
331
|
+
type: Input
|
|
332
|
+
}], widthToHideMenu: [{
|
|
333
|
+
type: Input
|
|
334
|
+
}], contentBackgroundColor: [{
|
|
335
|
+
type: Input
|
|
336
|
+
}], containerPadding: [{
|
|
337
|
+
type: Input
|
|
338
|
+
}], oidcSecurityService: [{
|
|
339
|
+
type: Input
|
|
340
|
+
}], sidenav: [{
|
|
341
|
+
type: ViewChild,
|
|
342
|
+
args: [MatSidenav]
|
|
343
|
+
}] } });
|
|
344
|
+
|
|
345
|
+
class UnbUsuarioModule {
|
|
346
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbUsuarioModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
347
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.1.2", ngImport: i0, type: UnbUsuarioModule, declarations: [UnbUsuarioComponent], imports: [BrowserModule,
|
|
348
|
+
MatToolbarModule,
|
|
349
|
+
MatSidenavModule,
|
|
350
|
+
LayoutModule,
|
|
351
|
+
MatMenuModule,
|
|
352
|
+
MatIconModule,
|
|
353
|
+
MatListModule,
|
|
354
|
+
MatButtonModule,
|
|
355
|
+
MatCardModule,
|
|
356
|
+
MatTooltipModule,
|
|
357
|
+
MatMenuModule,
|
|
358
|
+
MatDividerModule], exports: [UnbUsuarioComponent] }); }
|
|
359
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbUsuarioModule, providers: [UnbAuthService], imports: [BrowserModule,
|
|
360
|
+
MatToolbarModule,
|
|
361
|
+
MatSidenavModule,
|
|
362
|
+
LayoutModule,
|
|
363
|
+
MatMenuModule,
|
|
364
|
+
MatIconModule,
|
|
365
|
+
MatListModule,
|
|
366
|
+
MatButtonModule,
|
|
367
|
+
MatCardModule,
|
|
368
|
+
MatTooltipModule,
|
|
369
|
+
MatMenuModule,
|
|
370
|
+
MatDividerModule] }); }
|
|
371
|
+
}
|
|
372
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbUsuarioModule, decorators: [{
|
|
373
|
+
type: NgModule,
|
|
374
|
+
args: [{
|
|
375
|
+
declarations: [UnbUsuarioComponent],
|
|
376
|
+
imports: [
|
|
377
|
+
BrowserModule,
|
|
378
|
+
MatToolbarModule,
|
|
379
|
+
MatSidenavModule,
|
|
380
|
+
LayoutModule,
|
|
381
|
+
MatMenuModule,
|
|
382
|
+
MatIconModule,
|
|
383
|
+
MatListModule,
|
|
384
|
+
MatButtonModule,
|
|
385
|
+
MatCardModule,
|
|
386
|
+
MatTooltipModule,
|
|
387
|
+
MatMenuModule,
|
|
388
|
+
MatDividerModule
|
|
389
|
+
],
|
|
390
|
+
exports: [UnbUsuarioComponent],
|
|
391
|
+
providers: [UnbAuthService]
|
|
392
|
+
}]
|
|
393
|
+
}] });
|
|
394
|
+
|
|
395
|
+
class UnbNavBarModule {
|
|
396
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbNavBarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
397
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.1.2", ngImport: i0, type: UnbNavBarModule, declarations: [UnbNavBarComponent], imports: [BrowserModule,
|
|
398
|
+
MatToolbarModule,
|
|
399
|
+
MatSidenavModule,
|
|
400
|
+
LayoutModule,
|
|
401
|
+
MatIconModule,
|
|
402
|
+
MatListModule,
|
|
403
|
+
MatButtonModule,
|
|
404
|
+
UnbUsuarioModule,
|
|
405
|
+
MatCardModule], exports: [UnbNavBarComponent] }); }
|
|
406
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbNavBarModule, imports: [BrowserModule,
|
|
407
|
+
MatToolbarModule,
|
|
408
|
+
MatSidenavModule,
|
|
409
|
+
LayoutModule,
|
|
410
|
+
MatIconModule,
|
|
411
|
+
MatListModule,
|
|
412
|
+
MatButtonModule,
|
|
413
|
+
UnbUsuarioModule,
|
|
414
|
+
MatCardModule] }); }
|
|
415
|
+
}
|
|
416
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbNavBarModule, decorators: [{
|
|
417
|
+
type: NgModule,
|
|
418
|
+
args: [{
|
|
419
|
+
declarations: [UnbNavBarComponent],
|
|
420
|
+
imports: [
|
|
421
|
+
BrowserModule,
|
|
422
|
+
MatToolbarModule,
|
|
423
|
+
MatSidenavModule,
|
|
424
|
+
LayoutModule,
|
|
425
|
+
MatIconModule,
|
|
426
|
+
MatListModule,
|
|
427
|
+
MatButtonModule,
|
|
428
|
+
UnbUsuarioModule,
|
|
429
|
+
MatCardModule
|
|
430
|
+
],
|
|
431
|
+
exports: [UnbNavBarComponent]
|
|
432
|
+
}]
|
|
433
|
+
}] });
|
|
434
|
+
|
|
435
|
+
class UnbPessoaEmail {
|
|
436
|
+
}
|
|
437
|
+
class UnbPessoaEmailTipo {
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
var TipoPessoaEnum;
|
|
441
|
+
(function (TipoPessoaEnum) {
|
|
442
|
+
TipoPessoaEnum["FISICA"] = "F\u00EDsica";
|
|
443
|
+
TipoPessoaEnum["JURIDICA"] = "Jur\u00EDdica";
|
|
444
|
+
TipoPessoaEnum["ESTRANGEIRA"] = "Estrangeira";
|
|
445
|
+
})(TipoPessoaEnum || (TipoPessoaEnum = {}));
|
|
446
|
+
|
|
447
|
+
class UnBPessoaService {
|
|
448
|
+
constructor(http) {
|
|
449
|
+
this.http = http;
|
|
450
|
+
this.apiConfigSubject = new BehaviorSubject({ url: '', token: '' });
|
|
451
|
+
this.apiConfig$ = this.apiConfigSubject.asObservable();
|
|
452
|
+
}
|
|
453
|
+
// Atualiza a configuração global
|
|
454
|
+
setApiConfig(config) {
|
|
455
|
+
this.apiConfigSubject.next(config);
|
|
456
|
+
}
|
|
457
|
+
// Retorna a configuração atual
|
|
458
|
+
getApiConfig() {
|
|
459
|
+
return this.apiConfigSubject.getValue();
|
|
460
|
+
}
|
|
461
|
+
// Headers padrão
|
|
462
|
+
getHeaders() {
|
|
463
|
+
const { token } = this.getApiConfig();
|
|
464
|
+
return {
|
|
465
|
+
headers: new HttpHeaders({
|
|
466
|
+
'Content-Type': 'application/json',
|
|
467
|
+
Authorization: `Bearer ${token}`
|
|
468
|
+
})
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
// Métodos de busca
|
|
472
|
+
findByCpf(cpf) {
|
|
473
|
+
const url = `${this.getApiConfig().url}/pessoa-api/pessoas/fisicas?cpf=${cpf}`;
|
|
474
|
+
return this.http.get(url, this.getHeaders()).pipe(catchError(this.handleError));
|
|
475
|
+
}
|
|
476
|
+
findByCnpj(cnpj) {
|
|
477
|
+
const url = `${this.getApiConfig().url}/pessoa-api/pessoas/juridicas?cnpj=${cnpj}`;
|
|
478
|
+
return this.http.get(url, this.getHeaders()).pipe(catchError(this.handleError));
|
|
479
|
+
}
|
|
480
|
+
findByPassaporte(passaporte) {
|
|
481
|
+
const url = `${this.getApiConfig().url}/pessoa-api/pessoas/fisicas?passaporte=${passaporte}`;
|
|
482
|
+
return this.http.get(url, this.getHeaders()).pipe(catchError(this.handleError));
|
|
483
|
+
}
|
|
484
|
+
findPessoaFisicaById(id) {
|
|
485
|
+
const url = `${this.getApiConfig().url}/pessoa-api/pessoas/fisicas/${id}`;
|
|
486
|
+
return this.http.get(url, this.getHeaders()).pipe(catchError(this.handleError));
|
|
487
|
+
}
|
|
488
|
+
pesquisarCep(cep) {
|
|
489
|
+
const url = `${this.getApiConfig().url}/pessoa-api/public/busca-cep/servico-1/${cep}`;
|
|
490
|
+
return this.http.get(url, this.getHeaders()).pipe(catchError(this.handleError));
|
|
491
|
+
}
|
|
492
|
+
// Salvar (decide fisica ou juridica)
|
|
493
|
+
salvar(payload, tipoPessoa) {
|
|
494
|
+
if (!payload)
|
|
495
|
+
return throwError(() => new Error('Erro Local: Payload não pode ser null'));
|
|
496
|
+
if (!tipoPessoa)
|
|
497
|
+
return throwError(() => new Error('Erro Local: Tipo pessoa não pode ser null'));
|
|
498
|
+
if (tipoPessoa == TipoPessoaEnum.FISICA || tipoPessoa == TipoPessoaEnum.ESTRANGEIRA) {
|
|
499
|
+
return this.savePessoaFisica(payload);
|
|
500
|
+
}
|
|
501
|
+
else if (tipoPessoa == TipoPessoaEnum.JURIDICA) {
|
|
502
|
+
return this.savePessoaJuridica(payload);
|
|
503
|
+
}
|
|
504
|
+
return of(null);
|
|
505
|
+
}
|
|
506
|
+
// Salvar Pessoa Física
|
|
507
|
+
savePessoaFisica(pessoa) {
|
|
508
|
+
const url = this.getApiConfig().url;
|
|
509
|
+
const httpOptions = this.getHeaders();
|
|
510
|
+
const body = JSON.stringify(pessoa);
|
|
511
|
+
if (pessoa.codigoPessoa == null) {
|
|
512
|
+
return this.http.post(`${url}/pessoa-api/pessoas/fisicas`, body, httpOptions);
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
return this.http.put(`${url}/pessoa-api/pessoas/fisicas/${pessoa.codigoPessoa}`, body, httpOptions);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
// Salvar Pessoa Jurídica
|
|
519
|
+
savePessoaJuridica(pessoa) {
|
|
520
|
+
const url = this.getApiConfig().url;
|
|
521
|
+
const httpOptions = this.getHeaders();
|
|
522
|
+
const body = JSON.stringify(pessoa);
|
|
523
|
+
if (pessoa.codigoPessoa == null) {
|
|
524
|
+
return this.http.post(`${url}/pessoa-api/pessoas/juridicas`, body, httpOptions);
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
return this.http.put(`${url}/pessoa-api/pessoas/juridicas/${pessoa.codigoPessoa}`, body, httpOptions);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
// Dados auxiliares públicos
|
|
531
|
+
getEscolaridade() {
|
|
532
|
+
return this.http.get(`${this.getApiConfig().url}/pessoa-api/public/escolaridades/listagem`);
|
|
533
|
+
}
|
|
534
|
+
getEstadoCivil() {
|
|
535
|
+
return this.http.get(`${this.getApiConfig().url}/pessoa-api/public/estados-civis/listagem`);
|
|
536
|
+
}
|
|
537
|
+
getMunicipios() {
|
|
538
|
+
return this.http.get(`${this.getApiConfig().url}/pessoa-api/public/municipios/listagem`);
|
|
539
|
+
}
|
|
540
|
+
getPaises() {
|
|
541
|
+
return this.http.get(`${this.getApiConfig().url}/pessoa-api/public/paises/listagem?&page=0&size=200&sort=denominacao,asc`).pipe(map(response => {
|
|
542
|
+
return response.content.sort((a, b) => {
|
|
543
|
+
const nomeA = a?.denominacao?.toUpperCase() || '';
|
|
544
|
+
const nomeB = b?.denominacao?.toUpperCase() || '';
|
|
545
|
+
if (nomeA === 'BRASIL')
|
|
546
|
+
return -1;
|
|
547
|
+
if (nomeB === 'BRASIL')
|
|
548
|
+
return 1;
|
|
549
|
+
return nomeA.localeCompare(nomeB);
|
|
550
|
+
});
|
|
551
|
+
}));
|
|
552
|
+
}
|
|
553
|
+
getRacaCor() {
|
|
554
|
+
return this.http.get(`${this.getApiConfig().url}/pessoa-api/public/etnias/listagem`).pipe(map(lista => lista.map((item, index) => ({
|
|
555
|
+
codigo: index, // gera um código numérico sequencial
|
|
556
|
+
denominacao: this.formatarLabel(item) // formata se quiser
|
|
557
|
+
}))));
|
|
558
|
+
}
|
|
559
|
+
getTipoEmail() {
|
|
560
|
+
return this.http.get(`${this.getApiConfig().url}/pessoa-api/tipos-email/public/listagem`).pipe(map(lista => lista.map((item, index) => ({
|
|
561
|
+
codigo: index, // gera um código numérico sequencial
|
|
562
|
+
denominacao: this.formatarLabel(item) // formata se quiser
|
|
563
|
+
}))));
|
|
564
|
+
}
|
|
565
|
+
getTipoEndereco() {
|
|
566
|
+
return this.http.get(`${this.getApiConfig().url}/pessoa-api/tipos-endereco/public/listagem`).pipe(map(lista => lista.map((item, index) => ({
|
|
567
|
+
codigo: index, // gera um código numérico sequencial
|
|
568
|
+
denominacao: this.formatarLabel(item) // formata se quiser
|
|
569
|
+
}))));
|
|
570
|
+
}
|
|
571
|
+
getTipoTelefone() {
|
|
572
|
+
return this.http.get(`${this.getApiConfig().url}/pessoa-api/tipos-telefone/public/listagem`).pipe(map(lista => lista.map((item, index) => ({
|
|
573
|
+
codigo: index, // gera um código numérico sequencial
|
|
574
|
+
denominacao: this.formatarLabel(item) // formata se quiser
|
|
575
|
+
}))));
|
|
576
|
+
}
|
|
577
|
+
formatarLabel(text) {
|
|
578
|
+
return text
|
|
579
|
+
.toLowerCase()
|
|
580
|
+
.replace(/_/g, ' ')
|
|
581
|
+
.replace(/\b\w/g, l => l.toUpperCase());
|
|
582
|
+
}
|
|
583
|
+
// Handler de erro padrão
|
|
584
|
+
handleError(error) {
|
|
585
|
+
console.error('[UnBPessoaService] Erro na chamada HTTP:', error);
|
|
586
|
+
return throwError(() => error);
|
|
587
|
+
}
|
|
588
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnBPessoaService, deps: [{ token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
589
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnBPessoaService, providedIn: 'root' }); }
|
|
590
|
+
}
|
|
591
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnBPessoaService, decorators: [{
|
|
592
|
+
type: Injectable,
|
|
593
|
+
args: [{
|
|
594
|
+
providedIn: 'root'
|
|
595
|
+
}]
|
|
596
|
+
}], ctorParameters: () => [{ type: i1$1.HttpClient }] });
|
|
597
|
+
|
|
598
|
+
class UnbPessoaEmailFormComponent {
|
|
599
|
+
constructor(snackBar, service, dialogRef, data) {
|
|
600
|
+
this.snackBar = snackBar;
|
|
601
|
+
this.service = service;
|
|
602
|
+
this.dialogRef = dialogRef;
|
|
603
|
+
this.data = data;
|
|
604
|
+
this.email = new UnbPessoaEmail();
|
|
605
|
+
this.listaTipoEmail = [];
|
|
606
|
+
this.email = JSON.parse(JSON.stringify(data.email)); // O e-mail específico para edição
|
|
607
|
+
// Verifique se a lista de e-mails foi passada e atribua-a
|
|
608
|
+
if (data.emailsList) {
|
|
609
|
+
this.emailsList = JSON.parse(JSON.stringify(data.emailsList)); // Faça uma cópia profunda se for manipular
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
this.emailsList = []; // Inicialize como vazio se não for passada
|
|
613
|
+
}
|
|
614
|
+
if (!this.email) {
|
|
615
|
+
this.email = new UnbPessoaEmail();
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
ngOnInit() {
|
|
619
|
+
this.tipoEmail = this.service.getTipoEmail();
|
|
620
|
+
// Inscreve para guardar a lista em uma variável comum
|
|
621
|
+
this.tipoEmail.subscribe(lista => {
|
|
622
|
+
this.listaTipoEmail = lista;
|
|
623
|
+
// Se já tiver tipoEmailCodigo, preenche o nome correspondente
|
|
624
|
+
if (this.email.tipoEmailCodigo != null) {
|
|
625
|
+
const tipoEncontrado = lista.find(t => t.codigo === this.email.tipoEmailCodigo);
|
|
626
|
+
if (tipoEncontrado) {
|
|
627
|
+
this.email.tipo = tipoEncontrado.denominacao;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
else if (this.email.tipo) {
|
|
631
|
+
const tipoEncontrado = lista.find(t => t.denominacao?.toLowerCase() === this.email.tipo?.toLowerCase());
|
|
632
|
+
if (tipoEncontrado) {
|
|
633
|
+
this.email.tipoEmailCodigo = tipoEncontrado.codigo;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
salvar(form) {
|
|
639
|
+
if (form.invalid) {
|
|
640
|
+
this.openSnackBar('Existem erros no formulário, por favor, verificar.');
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
// 1. Define o 'tipo' padrão (ex: 1 para 'Pessoal') se não for preenchido
|
|
644
|
+
if (!this.email.tipoEmailCodigo) {
|
|
645
|
+
this.email.tipoEmailCodigo = 1; // 1 é geralmente 'Pessoal'
|
|
646
|
+
}
|
|
647
|
+
// 2. Define a 'ordem' (que o back-end chama de 'ordemEmail')
|
|
648
|
+
if (!this.email.ordem || this.email.ordem === 0) {
|
|
649
|
+
let maxOrdem = 0;
|
|
650
|
+
// Verifica se a lista de emails já existe e tem itens
|
|
651
|
+
if (this.emailsList && this.emailsList.length > 0) {
|
|
652
|
+
maxOrdem = Math.max(...this.emailsList.map(e => e.ordem || 0));
|
|
653
|
+
}
|
|
654
|
+
// Define a ordem do novo email como a maior ordem + 1
|
|
655
|
+
this.email.ordem = maxOrdem + 1;
|
|
656
|
+
}
|
|
657
|
+
// --- Fim da Modificação ---
|
|
658
|
+
if (this.validar(this.email) == false)
|
|
659
|
+
return;
|
|
660
|
+
this.emailSalvo = this.email;
|
|
661
|
+
this.salvarclose();
|
|
662
|
+
}
|
|
663
|
+
compararTipos(t1, t2) {
|
|
664
|
+
return t1 && t2 && t1 === t2;
|
|
665
|
+
}
|
|
666
|
+
onTipoSelecionado(codigoSelecionado) {
|
|
667
|
+
const tipoSelecionado = this.listaTipoEmail.find(t => t.codigo === codigoSelecionado);
|
|
668
|
+
if (tipoSelecionado) {
|
|
669
|
+
this.email.tipo = tipoSelecionado.denominacao;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Valida o objeto de e-mail, replicando as regras do validador do backend.
|
|
674
|
+
* Retorna true se o e-mail for válido, false caso contrário.
|
|
675
|
+
*/
|
|
676
|
+
validar(emailToValidate) {
|
|
677
|
+
// 1. Validação de campo obrigatório (do Java)
|
|
678
|
+
if (!emailToValidate.email || emailToValidate.email.trim() === '') {
|
|
679
|
+
this.openSnackBar("E-mail é um campo obrigatório.");
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
// 2. Validação de Tamanho Máximo (do Java)
|
|
683
|
+
if (emailToValidate.email.trim().length > 60) {
|
|
684
|
+
this.openSnackBar("E-mail deve ter no máximo 60 caracteres.");
|
|
685
|
+
return false;
|
|
686
|
+
}
|
|
687
|
+
// 3. Validação de formato de e-mail (do Java e do Angular)
|
|
688
|
+
// [Java: !Validadores.validarEmail(request.getEmail())]
|
|
689
|
+
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
690
|
+
if (!emailRegex.test(emailToValidate.email)) {
|
|
691
|
+
this.openSnackBar("Digite um E-mail válido.");
|
|
692
|
+
return false;
|
|
693
|
+
}
|
|
694
|
+
// 4. Validação de e-mail duplicado (do seu Angular)
|
|
695
|
+
const isDuplicate = this.emailsList.some(existingEmail => existingEmail.email?.toLowerCase() === emailToValidate.email?.toLowerCase() &&
|
|
696
|
+
existingEmail.codigo !== emailToValidate.codigo // Ignora o próprio e-mail se estiver sendo editado
|
|
697
|
+
);
|
|
698
|
+
if (isDuplicate) {
|
|
699
|
+
this.openSnackBar("Este e-mail já existe na lista.");
|
|
700
|
+
return false;
|
|
701
|
+
}
|
|
702
|
+
// Nota: As validações de 'ordemEmail' e 'tipoEmailCodigo' do Java
|
|
703
|
+
// já são tratadas na sua função 'salvar()',
|
|
704
|
+
// que atribui valores padrão antes desta função 'validar()' ser chamada.
|
|
705
|
+
return true; // Passou em todas as validações!
|
|
706
|
+
}
|
|
707
|
+
close() {
|
|
708
|
+
this.dialogRef.close(null);
|
|
709
|
+
}
|
|
710
|
+
salvarclose() {
|
|
711
|
+
this.dialogRef.close(this.emailSalvo);
|
|
712
|
+
}
|
|
713
|
+
openSnackBar(message) {
|
|
714
|
+
this.snackBar.open(message, 'x', {
|
|
715
|
+
duration: 5000,
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaEmailFormComponent, deps: [{ token: i1$2.MatSnackBar }, { token: UnBPessoaService }, { token: i3$2.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
719
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: UnbPessoaEmailFormComponent, selector: "lib-unb-pessoa-email-form", ngImport: i0, template: "<h1 mat-dialog-title>Cadastro de E-mail</h1>\r\n<form (ngSubmit)=\"salvar(form)\" #form=\"ngForm\">\r\n <mat-dialog-content>\r\n <div class=\"form-container\">\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>Tipo</mat-label>\r\n <mat-select [(ngModel)]=\"email.tipoEmailCodigo\" [compareWith]=\"compararTipos\" name=\"tipoEmailCodigo\" (selectionChange)=\"onTipoSelecionado($event.value)\" required>\r\n <mat-option *ngFor=\"let tipo of tipoEmail | async\" [value]=\"tipo.codigo\">\r\n {{tipo.denominacao}}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>E-mail</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"email.email\" name=\"emailValue\" #emailValue=\"ngModel\" />\r\n </mat-form-field>\r\n\r\n </div>\r\n </mat-dialog-content>\r\n\r\n <mat-dialog-actions align=\"end\">\r\n <button mat-stroked-button type=\"button\" color=\"warn\" (click)=\"close()\">Fechar</button>\r\n <button mat-flat-button type=\"submit\" color=\"primary\">Salvar</button>\r\n </mat-dialog-actions>\r\n</form>", styles: [".card-actions-buttons{display:flex;gap:5px;flex-wrap:wrap}.form-container{display:flex;flex-wrap:wrap;column-gap:10px;margin:10px}@media (max-width: 1000px){.form-container{flex-direction:column;gap:5px}}.break{flex-basis:100%;height:0}.form-5{flex:1 1 5%}.inline-table-container{display:flex;align-items:center;justify-content:space-between;padding:5px}@media (max-width: 600px){.form-5,.form-10,.form-15{flex:1 1 100%}}.form-10{flex:1 1 10%}.form-15{flex:1 1 15%}.form-20{flex:1 1 20%}.form-25{flex:1 1 25%}.form-30{flex:1 1 30%}.form-35{flex:1 1 35%}.form-40{flex:1 1 40%}.form-45{flex:1 1 45%}.form-50{flex:1 1 50%}.form-60{flex:1 1 60%}.form-70{flex:1 1 70%}.form-80{flex:1 1 80%}.form-100{flex:1 1 100%;min-width:250px}.botoes-container{display:flex;gap:5px}@media (max-width: 600px){.botoes-container{margin-bottom:10px}.botoes-container button{flex:1;max-width:50%}}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i5$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i5$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i5$2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i5$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i5$2.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i7.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: i7$2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i7$2.MatLabel, selector: "mat-label" }, { kind: "directive", type: i8$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "directive", type: i3$2.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i3$2.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i3$2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "component", type: i9.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i10.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }] }); }
|
|
720
|
+
}
|
|
721
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaEmailFormComponent, decorators: [{
|
|
722
|
+
type: Component,
|
|
723
|
+
args: [{ standalone: false, selector: 'lib-unb-pessoa-email-form', template: "<h1 mat-dialog-title>Cadastro de E-mail</h1>\r\n<form (ngSubmit)=\"salvar(form)\" #form=\"ngForm\">\r\n <mat-dialog-content>\r\n <div class=\"form-container\">\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>Tipo</mat-label>\r\n <mat-select [(ngModel)]=\"email.tipoEmailCodigo\" [compareWith]=\"compararTipos\" name=\"tipoEmailCodigo\" (selectionChange)=\"onTipoSelecionado($event.value)\" required>\r\n <mat-option *ngFor=\"let tipo of tipoEmail | async\" [value]=\"tipo.codigo\">\r\n {{tipo.denominacao}}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>E-mail</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"email.email\" name=\"emailValue\" #emailValue=\"ngModel\" />\r\n </mat-form-field>\r\n\r\n </div>\r\n </mat-dialog-content>\r\n\r\n <mat-dialog-actions align=\"end\">\r\n <button mat-stroked-button type=\"button\" color=\"warn\" (click)=\"close()\">Fechar</button>\r\n <button mat-flat-button type=\"submit\" color=\"primary\">Salvar</button>\r\n </mat-dialog-actions>\r\n</form>", styles: [".card-actions-buttons{display:flex;gap:5px;flex-wrap:wrap}.form-container{display:flex;flex-wrap:wrap;column-gap:10px;margin:10px}@media (max-width: 1000px){.form-container{flex-direction:column;gap:5px}}.break{flex-basis:100%;height:0}.form-5{flex:1 1 5%}.inline-table-container{display:flex;align-items:center;justify-content:space-between;padding:5px}@media (max-width: 600px){.form-5,.form-10,.form-15{flex:1 1 100%}}.form-10{flex:1 1 10%}.form-15{flex:1 1 15%}.form-20{flex:1 1 20%}.form-25{flex:1 1 25%}.form-30{flex:1 1 30%}.form-35{flex:1 1 35%}.form-40{flex:1 1 40%}.form-45{flex:1 1 45%}.form-50{flex:1 1 50%}.form-60{flex:1 1 60%}.form-70{flex:1 1 70%}.form-80{flex:1 1 80%}.form-100{flex:1 1 100%;min-width:250px}.botoes-container{display:flex;gap:5px}@media (max-width: 600px){.botoes-container{margin-bottom:10px}.botoes-container button{flex:1;max-width:50%}}\n"] }]
|
|
724
|
+
}], ctorParameters: () => [{ type: i1$2.MatSnackBar }, { type: UnBPessoaService }, { type: i3$2.MatDialogRef }, { type: undefined, decorators: [{
|
|
725
|
+
type: Inject,
|
|
726
|
+
args: [MAT_DIALOG_DATA]
|
|
727
|
+
}] }] });
|
|
728
|
+
|
|
729
|
+
class UnbPessoaEndereco {
|
|
730
|
+
}
|
|
731
|
+
class UnbPessoaEnderecoTipo {
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
class UnbPessoaEnderecoFormComponent {
|
|
735
|
+
constructor(snackBar, service, dialogRef, data) {
|
|
736
|
+
this.snackBar = snackBar;
|
|
737
|
+
this.service = service;
|
|
738
|
+
this.dialogRef = dialogRef;
|
|
739
|
+
this.data = data;
|
|
740
|
+
this.endereco = new UnbPessoaEndereco();
|
|
741
|
+
this.listaTipoEndereco = [];
|
|
742
|
+
this.listaPaises = [];
|
|
743
|
+
this.endereco = JSON.parse(JSON.stringify(data.endereco)); // O e-mail específico para edição
|
|
744
|
+
// Verifique se a lista de e-mails foi passada e atribua-a
|
|
745
|
+
if (data.enderecosList) {
|
|
746
|
+
this.enderecosList = JSON.parse(JSON.stringify(data.enderecosList)); // Faça uma cópia profunda se for manipular
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
this.enderecosList = []; // Inicialize como vazio se não for passada
|
|
750
|
+
}
|
|
751
|
+
if (!this.endereco) {
|
|
752
|
+
this.endereco = new UnbPessoaEndereco();
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
ngOnInit() {
|
|
756
|
+
this.tipoEndereco = this.service.getTipoEndereco();
|
|
757
|
+
this.paises = this.service.getPaises(); // Você já tinha isso
|
|
758
|
+
// --- Preenche o Tipos de Endereço ---
|
|
759
|
+
this.tipoEndereco.subscribe(lista => {
|
|
760
|
+
this.listaTipoEndereco = lista;
|
|
761
|
+
// Se já tiver tipoEnderecoCodigo, preenche o nome correspondente
|
|
762
|
+
if (this.endereco.tipoEnderecoCodigo != null) {
|
|
763
|
+
const tipoEncontrado = lista.find(t => t.codigo === this.endereco.tipoEnderecoCodigo);
|
|
764
|
+
if (tipoEncontrado) {
|
|
765
|
+
this.endereco.tipo = tipoEncontrado.denominacao;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
else if (this.endereco.tipo) {
|
|
769
|
+
// Se tiver só o nome, preenche o código
|
|
770
|
+
const tipoEncontrado = lista.find(t => t.denominacao?.toLowerCase() === this.endereco.tipo?.toLowerCase());
|
|
771
|
+
if (tipoEncontrado) {
|
|
772
|
+
this.endereco.tipoEnderecoCodigo = tipoEncontrado.codigo;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
// O metodo get retorna uf, mas o put espera ufEndereco
|
|
776
|
+
if (this.endereco.uf) {
|
|
777
|
+
this.endereco.ufEndereco = this.endereco.uf; // Converte uf para ufEndereco
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
// --- Preenche o País ---
|
|
781
|
+
this.paises.subscribe(listaDePaises => {
|
|
782
|
+
this.listaPaises = listaDePaises; // Armazena a lista de países
|
|
783
|
+
const CODIGO_BRASIL = 22; // Código padrão para o Brasil
|
|
784
|
+
// Lógica 1: Se o ID do país já existe (ex: 22), encontra o nome (ex: "Brasil")
|
|
785
|
+
if (this.endereco.paisEnderecoCodigo != null) {
|
|
786
|
+
const paisEncontrado = this.listaPaises.find(p => p.codigo === this.endereco.paisEnderecoCodigo);
|
|
787
|
+
if (paisEncontrado) {
|
|
788
|
+
this.endereco.pais = paisEncontrado.denominacao;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
// Lógica 2: Se o nome do país existe (ex: "Brasil"), encontra o ID (ex: 22)
|
|
792
|
+
else if (this.endereco.pais) {
|
|
793
|
+
const paisEncontrado = this.listaPaises.find(p => p.denominacao?.toLowerCase() === this.endereco.pais?.toLowerCase());
|
|
794
|
+
if (paisEncontrado) {
|
|
795
|
+
this.endereco.paisEnderecoCodigo = paisEncontrado.codigo;
|
|
796
|
+
}
|
|
797
|
+
else {
|
|
798
|
+
// Se o nome foi fornecido mas não encontrado na lista, assume Brasil
|
|
799
|
+
this.endereco.paisEnderecoCodigo = CODIGO_BRASIL;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
// Lógica 3: Se nem o ID nem o nome existem, assume Brasil por padrão
|
|
803
|
+
else {
|
|
804
|
+
this.endereco.paisEnderecoCodigo = CODIGO_BRASIL;
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
salvar(form) {
|
|
809
|
+
if (form.invalid) {
|
|
810
|
+
this.openSnackBar('Existem erros no formulário, por favor, verificar.');
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
// Se a ordemEndereco não estiver definida (novo item) ou for 0
|
|
814
|
+
if (!this.endereco.ordemEndereco || this.endereco.ordemEndereco === 0) {
|
|
815
|
+
let maxOrdem = 0;
|
|
816
|
+
if (this.enderecosList && this.enderecosList.length > 0) {
|
|
817
|
+
maxOrdem = Math.max(...this.enderecosList.map(e => e.ordemEndereco || 0));
|
|
818
|
+
}
|
|
819
|
+
this.endereco.ordemEndereco = maxOrdem + 1;
|
|
820
|
+
}
|
|
821
|
+
if (this.validar(this.endereco) == false)
|
|
822
|
+
return;
|
|
823
|
+
this.enderecoSalvo = this.endereco;
|
|
824
|
+
this.salvarclose();
|
|
825
|
+
}
|
|
826
|
+
compararTipos(t1, t2) {
|
|
827
|
+
return t1 && t2 && t1.codigo === t2.codigo;
|
|
828
|
+
}
|
|
829
|
+
onTipoSelecionado(codigoSelecionado) {
|
|
830
|
+
const tipoSelecionado = this.listaTipoEndereco.find(t => t.codigo === codigoSelecionado);
|
|
831
|
+
if (tipoSelecionado) {
|
|
832
|
+
this.endereco.tipo = tipoSelecionado.denominacao;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
pesquisarCep() {
|
|
836
|
+
if (this.endereco.cep && this.endereco.cep.trim() !== '') {
|
|
837
|
+
let cepFormatado = this.endereco.cep.replace(/\D/g, ''); // Remove caracteres não numéricos
|
|
838
|
+
this.service.pesquisarCep(cepFormatado).subscribe({
|
|
839
|
+
next: (data) => {
|
|
840
|
+
this.endereco.logradouro = data.logradouro;
|
|
841
|
+
this.endereco.bairro = data.bairro;
|
|
842
|
+
this.endereco.ufEndereco = data.uf;
|
|
843
|
+
this.endereco.uf = data.uf;
|
|
844
|
+
this.endereco.complemento = data.complemento;
|
|
845
|
+
},
|
|
846
|
+
error: (error) => {
|
|
847
|
+
this.openSnackBar('Falha ao encontrar o CEP');
|
|
848
|
+
console.error('Erro ao pesquisar CEP:', error);
|
|
849
|
+
}
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
else {
|
|
853
|
+
this.openSnackBar('Por favor, insira um CEP válido.');
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
getListaEstados() {
|
|
857
|
+
return [
|
|
858
|
+
'AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO', 'MA',
|
|
859
|
+
'MT', 'MS', 'MG', 'PA', 'PB', 'PR', 'PE', 'PI', 'RJ', 'RN',
|
|
860
|
+
'RS', 'RO', 'RR', 'SC', 'SP', 'SE', 'TO'
|
|
861
|
+
];
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Valida o objeto de endereço, replicando as regras do validador do backend.
|
|
865
|
+
* Retorna true se o endereço for válido, false caso contrário.
|
|
866
|
+
*/
|
|
867
|
+
validar(enderecoToValidate) {
|
|
868
|
+
// 1. Validação de tipoEnderecoCodigo (Obrigatório e 0-4)
|
|
869
|
+
// [Java: request.getTipoEnderecoCodigo() == null]
|
|
870
|
+
if (enderecoToValidate.tipoEnderecoCodigo == null) {
|
|
871
|
+
this.openSnackBar("Tipo de Endereço é um campo obrigatório.");
|
|
872
|
+
return false;
|
|
873
|
+
}
|
|
874
|
+
// [Java: request.getTipoEnderecoCodigo() < (byte) 0 || request.getTipoEnderecoCodigo() > (byte) 4]
|
|
875
|
+
if (enderecoToValidate.tipoEnderecoCodigo < 0 || enderecoToValidate.tipoEnderecoCodigo > 4) {
|
|
876
|
+
this.openSnackBar("Tipo de Endereço é inválido (deve ser entre 0 e 4).");
|
|
877
|
+
return false;
|
|
878
|
+
}
|
|
879
|
+
// 3. Validação de CEP (8 dígitos, se preenchido)
|
|
880
|
+
// [Java: request.getCep().trim().length() != 8]
|
|
881
|
+
if (enderecoToValidate.cep && enderecoToValidate.cep.trim() !== '') {
|
|
882
|
+
const cepLimpo = enderecoToValidate.cep.replace(/\D/g, ''); // Remove não-dígitos
|
|
883
|
+
if (cepLimpo.length !== 8) {
|
|
884
|
+
this.openSnackBar("CEP deve conter 8 dígitos.");
|
|
885
|
+
return false;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
// 4. Validação de Logradouro (Max 100, se preenchido)
|
|
889
|
+
// [Java: request.getLogradouro().trim().length() > 100]
|
|
890
|
+
if (enderecoToValidate.logradouro && enderecoToValidate.logradouro.trim().length > 100) {
|
|
891
|
+
this.openSnackBar("Logradouro deve ter no máximo 100 caracteres.");
|
|
892
|
+
return false;
|
|
893
|
+
}
|
|
894
|
+
// 5. Validação de Bairro (Max 100, se preenchido)
|
|
895
|
+
// [Java: request.getBairro().trim().length() > 100]
|
|
896
|
+
if (enderecoToValidate.bairro && enderecoToValidate.bairro.trim().length > 100) {
|
|
897
|
+
this.openSnackBar("Bairro deve ter no máximo 100 caracteres.");
|
|
898
|
+
return false;
|
|
899
|
+
}
|
|
900
|
+
// 6. Validação de Complemento (Max 100, se preenchido)
|
|
901
|
+
// [Java: request.getComplemento().trim().length() > 100]
|
|
902
|
+
if (enderecoToValidate.complemento && enderecoToValidate.complemento.trim().length > 100) {
|
|
903
|
+
this.openSnackBar("Complemento deve ter no máximo 100 caracteres.");
|
|
904
|
+
return false;
|
|
905
|
+
}
|
|
906
|
+
// 7. Validação de Caixa Postal (Max 100, se preenchida)
|
|
907
|
+
// [Java: request.getCaixaPostal().trim().length() > 100]
|
|
908
|
+
if (enderecoToValidate.caixaPostal && enderecoToValidate.caixaPostal.trim().length > 100) {
|
|
909
|
+
this.openSnackBar("Caixa Postal deve ter no máximo 100 caracteres.");
|
|
910
|
+
return false;
|
|
911
|
+
}
|
|
912
|
+
// 8. Validação de UF (2 caracteres, se preenchida)
|
|
913
|
+
// O form usa 'ufEndereco', o java usa 'uf'. O ngOnInit mapeia uf -> ufEndereco.
|
|
914
|
+
// [Java: request.getUf().trim().length() != 2]
|
|
915
|
+
if (enderecoToValidate.ufEndereco && enderecoToValidate.ufEndereco.trim().length !== 2) {
|
|
916
|
+
this.openSnackBar("UF deve ter 2 caracteres.");
|
|
917
|
+
return false;
|
|
918
|
+
}
|
|
919
|
+
// --- Validação de Duplicar ---
|
|
920
|
+
const isDuplicate = this.enderecosList.some(existingEndereco => existingEndereco.logradouro?.toLowerCase() === enderecoToValidate.logradouro?.toLowerCase() &&
|
|
921
|
+
existingEndereco.codigo !== enderecoToValidate.codigo // Ignora o próprio endereço se estiver sendo editado
|
|
922
|
+
);
|
|
923
|
+
if (isDuplicate) {
|
|
924
|
+
this.openSnackBar("Este endereço já existe na lista.");
|
|
925
|
+
return false;
|
|
926
|
+
}
|
|
927
|
+
return true; // Passou em todas as validações
|
|
928
|
+
}
|
|
929
|
+
close() {
|
|
930
|
+
this.dialogRef.close(null);
|
|
931
|
+
}
|
|
932
|
+
salvarclose() {
|
|
933
|
+
this.dialogRef.close(this.enderecoSalvo);
|
|
934
|
+
}
|
|
935
|
+
openSnackBar(message) {
|
|
936
|
+
this.snackBar.open(message, 'x', {
|
|
937
|
+
duration: 5000,
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaEnderecoFormComponent, deps: [{ token: i1$2.MatSnackBar }, { token: UnBPessoaService }, { token: i3$2.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
941
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: UnbPessoaEnderecoFormComponent, selector: "lib-unb-pessoa-endereco-form", ngImport: i0, template: "<h1 mat-dialog-title>Cadastro de E-mail</h1>\r\n<form (ngSubmit)=\"salvar(form)\" #form=\"ngForm\">\r\n <mat-dialog-content>\r\n <div class=\"form-container\">\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>Tipo</mat-label>\r\n <mat-select [(ngModel)]=\"endereco.tipoEnderecoCodigo\" name=\"tipo\" #tipo=\"ngModel\"\r\n (selectionChange)=\"onTipoSelecionado($event.value)\" required>\r\n <mat-option *ngFor=\"let tipo of tipoEndereco | async\" [value]=\"tipo.codigo\">\r\n {{tipo.denominacao}}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-10\" appearance=\"outline\">\r\n <mat-label>Pa\u00EDs</mat-label>\r\n\r\n <mat-select [(ngModel)]=\"endereco.paisEnderecoCodigo\" name=\"paisEnderecoCodigo\" #paisEnderecoCodigo=\"ngModel\">\r\n\r\n <mat-option *ngFor=\"let paises of paises | async\" [value]=\"paises.codigo\">\r\n <span *ngIf=\"paises.denominacao === 'BRASIL'\">\uD83C\uDDE7\uD83C\uDDF7 <b>{{ paises.denominacao }}</b></span>\r\n <span *ngIf=\"paises.denominacao !== 'BRASIL'\">{{ paises.denominacao }}</span>\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>CEP</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"endereco.cep\" name=\"cep\" #cep=\"ngModel\" />\r\n <button matSuffix mat-icon-button type=\"button\" aria-label=\"Pesquisar\" (click)=\"pesquisarCep()\">\r\n <mat-icon style=\"margin-right: 2px;\">search</mat-icon>\r\n </button>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Endere\u00E7o</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"endereco.logradouro\" name=\"logradouro\" #logradouro=\"ngModel\" />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>Bairro</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"endereco.bairro\" name=\"bairro\" #bairro=\"ngModel\" />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>Complemento</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"endereco.complemento\" name=\"complemento\" #complemento=\"ngModel\" />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>UF</mat-label>\r\n <mat-select [(ngModel)]=\"endereco.uf\" name=\"uf\" #uf=\"ngModel\">\r\n <mat-option *ngFor=\"let uf of getListaEstados()\" [value]=\"uf\">\r\n {{ uf }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n </mat-dialog-content>\r\n\r\n <mat-dialog-actions align=\"end\">\r\n <button mat-stroked-button type=\"button\" color=\"warn\" (click)=\"close()\">Fechar</button>\r\n <button mat-flat-button type=\"submit\" color=\"primary\">Salvar</button>\r\n </mat-dialog-actions>\r\n</form>", styles: [".card-actions-buttons{display:flex;gap:5px;flex-wrap:wrap}.form-container{display:flex;flex-wrap:wrap;column-gap:10px;margin:10px}@media (max-width: 1000px){.form-container{flex-direction:column;gap:5px}}.break{flex-basis:100%;height:0}.form-5{flex:1 1 5%}.inline-table-container{display:flex;align-items:center;justify-content:space-between;padding:5px}@media (max-width: 600px){.form-5,.form-10,.form-15{flex:1 1 100%}}.form-10{flex:1 1 10%}.form-15{flex:1 1 15%}.form-20{flex:1 1 20%}.form-25{flex:1 1 25%}.form-30{flex:1 1 30%}.form-35{flex:1 1 35%}.form-40{flex:1 1 40%}.form-45{flex:1 1 45%}.form-50{flex:1 1 50%}.form-100{flex:1 1 100%;min-width:250px}.botoes-container{display:flex;gap:5px}@media (max-width: 600px){.botoes-container{margin-bottom:10px}.botoes-container button{flex:1;max-width:50%}}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i5$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i5$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i5$2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i5$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i5$2.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i7.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: i7.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: i7$2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i7$2.MatLabel, selector: "mat-label" }, { kind: "directive", type: i7$2.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i8$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "directive", type: i3$2.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i3$2.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i3$2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "component", type: i9.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i10.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }] }); }
|
|
942
|
+
}
|
|
943
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaEnderecoFormComponent, decorators: [{
|
|
944
|
+
type: Component,
|
|
945
|
+
args: [{ standalone: false, selector: 'lib-unb-pessoa-endereco-form', template: "<h1 mat-dialog-title>Cadastro de E-mail</h1>\r\n<form (ngSubmit)=\"salvar(form)\" #form=\"ngForm\">\r\n <mat-dialog-content>\r\n <div class=\"form-container\">\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>Tipo</mat-label>\r\n <mat-select [(ngModel)]=\"endereco.tipoEnderecoCodigo\" name=\"tipo\" #tipo=\"ngModel\"\r\n (selectionChange)=\"onTipoSelecionado($event.value)\" required>\r\n <mat-option *ngFor=\"let tipo of tipoEndereco | async\" [value]=\"tipo.codigo\">\r\n {{tipo.denominacao}}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-10\" appearance=\"outline\">\r\n <mat-label>Pa\u00EDs</mat-label>\r\n\r\n <mat-select [(ngModel)]=\"endereco.paisEnderecoCodigo\" name=\"paisEnderecoCodigo\" #paisEnderecoCodigo=\"ngModel\">\r\n\r\n <mat-option *ngFor=\"let paises of paises | async\" [value]=\"paises.codigo\">\r\n <span *ngIf=\"paises.denominacao === 'BRASIL'\">\uD83C\uDDE7\uD83C\uDDF7 <b>{{ paises.denominacao }}</b></span>\r\n <span *ngIf=\"paises.denominacao !== 'BRASIL'\">{{ paises.denominacao }}</span>\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>CEP</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"endereco.cep\" name=\"cep\" #cep=\"ngModel\" />\r\n <button matSuffix mat-icon-button type=\"button\" aria-label=\"Pesquisar\" (click)=\"pesquisarCep()\">\r\n <mat-icon style=\"margin-right: 2px;\">search</mat-icon>\r\n </button>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Endere\u00E7o</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"endereco.logradouro\" name=\"logradouro\" #logradouro=\"ngModel\" />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>Bairro</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"endereco.bairro\" name=\"bairro\" #bairro=\"ngModel\" />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>Complemento</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"endereco.complemento\" name=\"complemento\" #complemento=\"ngModel\" />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>UF</mat-label>\r\n <mat-select [(ngModel)]=\"endereco.uf\" name=\"uf\" #uf=\"ngModel\">\r\n <mat-option *ngFor=\"let uf of getListaEstados()\" [value]=\"uf\">\r\n {{ uf }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n </mat-dialog-content>\r\n\r\n <mat-dialog-actions align=\"end\">\r\n <button mat-stroked-button type=\"button\" color=\"warn\" (click)=\"close()\">Fechar</button>\r\n <button mat-flat-button type=\"submit\" color=\"primary\">Salvar</button>\r\n </mat-dialog-actions>\r\n</form>", styles: [".card-actions-buttons{display:flex;gap:5px;flex-wrap:wrap}.form-container{display:flex;flex-wrap:wrap;column-gap:10px;margin:10px}@media (max-width: 1000px){.form-container{flex-direction:column;gap:5px}}.break{flex-basis:100%;height:0}.form-5{flex:1 1 5%}.inline-table-container{display:flex;align-items:center;justify-content:space-between;padding:5px}@media (max-width: 600px){.form-5,.form-10,.form-15{flex:1 1 100%}}.form-10{flex:1 1 10%}.form-15{flex:1 1 15%}.form-20{flex:1 1 20%}.form-25{flex:1 1 25%}.form-30{flex:1 1 30%}.form-35{flex:1 1 35%}.form-40{flex:1 1 40%}.form-45{flex:1 1 45%}.form-50{flex:1 1 50%}.form-100{flex:1 1 100%;min-width:250px}.botoes-container{display:flex;gap:5px}@media (max-width: 600px){.botoes-container{margin-bottom:10px}.botoes-container button{flex:1;max-width:50%}}\n"] }]
|
|
946
|
+
}], ctorParameters: () => [{ type: i1$2.MatSnackBar }, { type: UnBPessoaService }, { type: i3$2.MatDialogRef }, { type: undefined, decorators: [{
|
|
947
|
+
type: Inject,
|
|
948
|
+
args: [MAT_DIALOG_DATA]
|
|
949
|
+
}] }] });
|
|
950
|
+
|
|
951
|
+
const listaEstados = [
|
|
952
|
+
{ codigo: 1, identificador: 'AC', descricao: "Acre" },
|
|
953
|
+
{ codigo: 2, identificador: 'AL', descricao: "Alagoas" },
|
|
954
|
+
{ codigo: 3, identificador: 'AM', descricao: "Amazonas" },
|
|
955
|
+
{ codigo: 4, identificador: 'AP', descricao: "Amapá" },
|
|
956
|
+
{ codigo: 5, identificador: 'BA', descricao: "Bahia" },
|
|
957
|
+
{ codigo: 6, identificador: 'CE', descricao: "Ceará" },
|
|
958
|
+
{ codigo: 7, identificador: 'DF', descricao: "Distrito Federal" },
|
|
959
|
+
{ codigo: 8, identificador: 'ES', descricao: "Espírito Santo" },
|
|
960
|
+
{ codigo: 9, identificador: 'GO', descricao: "Goiás" },
|
|
961
|
+
{ codigo: 10, identificador: 'MA', descricao: "Maranhão" },
|
|
962
|
+
{ codigo: 11, identificador: 'MG', descricao: "Minas Gerais" },
|
|
963
|
+
{ codigo: 12, identificador: 'MS', descricao: "Mato Grosso do Sul" },
|
|
964
|
+
{ codigo: 13, identificador: 'MT', descricao: "Mato Grosso" },
|
|
965
|
+
{ codigo: 14, identificador: 'PA', descricao: "Pará" },
|
|
966
|
+
{ codigo: 15, identificador: 'PB', descricao: "Paraíba" },
|
|
967
|
+
{ codigo: 16, identificador: 'PE', descricao: "Pernambuco" },
|
|
968
|
+
{ codigo: 17, identificador: 'PI', descricao: "Piauí" },
|
|
969
|
+
{ codigo: 18, identificador: 'PR', descricao: "Paraná" },
|
|
970
|
+
{ codigo: 19, identificador: 'RJ', descricao: "Rio de Janeiro" },
|
|
971
|
+
{ codigo: 20, identificador: 'RN', descricao: "Rio Grande do Norte" },
|
|
972
|
+
{ codigo: 21, identificador: 'RO', descricao: "Rondônia" },
|
|
973
|
+
{ codigo: 22, identificador: 'RR', descricao: "Roraima" },
|
|
974
|
+
{ codigo: 23, identificador: 'RS', descricao: "Rio Grande do Sul" },
|
|
975
|
+
{ codigo: 24, identificador: 'SC', descricao: "Santa Catarina" },
|
|
976
|
+
{ codigo: 25, identificador: 'SE', descricao: "Sergipe" },
|
|
977
|
+
{ codigo: 26, identificador: 'SP', descricao: "São Paulo" },
|
|
978
|
+
{ codigo: 27, identificador: 'TO', descricao: "Tocantins" }
|
|
979
|
+
];
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* Essa eh uma classe base, com propriedades comum a todas as outras pessoas.
|
|
983
|
+
* */
|
|
984
|
+
class UnbPessoaModel {
|
|
985
|
+
;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
class UnbUtils {
|
|
989
|
+
removeNull(key, value) {
|
|
990
|
+
// Filtering out properties
|
|
991
|
+
if (value === null) {
|
|
992
|
+
return undefined;
|
|
993
|
+
}
|
|
994
|
+
return value;
|
|
995
|
+
}
|
|
996
|
+
// forma cpf
|
|
997
|
+
static formataCpf(valor) {
|
|
998
|
+
return valor.replace(/(\d{3})(\d{3})(\d{3})(\d{2})/g, "\$1.\$2.\$3\-\$4");
|
|
999
|
+
}
|
|
1000
|
+
// forma cpf ou cnpj
|
|
1001
|
+
static formataCnpj(valor) {
|
|
1002
|
+
return valor.replace(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/, "$1.$2.$3/$4-$5");
|
|
1003
|
+
}
|
|
1004
|
+
static validarCPF(cpf) {
|
|
1005
|
+
if (!cpf)
|
|
1006
|
+
return false; // Se CPF for null, undefined ou vazio, retorna falso
|
|
1007
|
+
cpf = cpf.replace(/\D/g, ''); // Remove todos os caracteres não numéricos
|
|
1008
|
+
if (cpf == '')
|
|
1009
|
+
return false;
|
|
1010
|
+
if (cpf.length !== 11 || /^(\d)\1+$/.test(cpf)) {
|
|
1011
|
+
return false; // Verifica se tem 11 dígitos e não é uma sequência repetida (ex: 11111111111)
|
|
1012
|
+
}
|
|
1013
|
+
let soma = 0, resto;
|
|
1014
|
+
// Validação do primeiro dígito verificador
|
|
1015
|
+
for (let i = 0; i < 9; i++) {
|
|
1016
|
+
soma += Number(cpf[i]) * (10 - i);
|
|
1017
|
+
}
|
|
1018
|
+
resto = (soma * 10) % 11;
|
|
1019
|
+
if (resto === 10 || resto === 11)
|
|
1020
|
+
resto = 0;
|
|
1021
|
+
if (resto !== Number(cpf[9]))
|
|
1022
|
+
return false;
|
|
1023
|
+
soma = 0;
|
|
1024
|
+
// Validação do segundo dígito verificador
|
|
1025
|
+
for (let i = 0; i < 10; i++) {
|
|
1026
|
+
soma += Number(cpf[i]) * (11 - i);
|
|
1027
|
+
}
|
|
1028
|
+
resto = (soma * 10) % 11;
|
|
1029
|
+
if (resto === 10 || resto === 11)
|
|
1030
|
+
resto = 0;
|
|
1031
|
+
return resto === Number(cpf[10]);
|
|
1032
|
+
}
|
|
1033
|
+
static validarCNPJ(cnpj) {
|
|
1034
|
+
cnpj = cnpj.replace(/[^\d]+/g, ''); // Remove caracteres não numéricos
|
|
1035
|
+
if (cnpj.length !== 14 || /^(\d)\1+$/.test(cnpj)) {
|
|
1036
|
+
return false; // Verifica se tem 14 dígitos e não é uma sequência repetida
|
|
1037
|
+
}
|
|
1038
|
+
let tamanho = cnpj.length - 2;
|
|
1039
|
+
let numeros = cnpj.substring(0, tamanho);
|
|
1040
|
+
let digitos = cnpj.substring(tamanho);
|
|
1041
|
+
let soma = 0, pos = tamanho - 7;
|
|
1042
|
+
for (let i = tamanho; i >= 1; i--) {
|
|
1043
|
+
soma += parseInt(numeros.charAt(tamanho - i)) * pos--;
|
|
1044
|
+
if (pos < 2)
|
|
1045
|
+
pos = 9;
|
|
1046
|
+
}
|
|
1047
|
+
let resultado = soma % 11 < 2 ? 0 : 11 - (soma % 11);
|
|
1048
|
+
if (resultado !== parseInt(digitos.charAt(0)))
|
|
1049
|
+
return false;
|
|
1050
|
+
tamanho = tamanho + 1;
|
|
1051
|
+
numeros = cnpj.substring(0, tamanho);
|
|
1052
|
+
soma = 0;
|
|
1053
|
+
pos = tamanho - 7;
|
|
1054
|
+
for (let i = tamanho; i >= 1; i--) {
|
|
1055
|
+
soma += parseInt(numeros.charAt(tamanho - i)) * pos--;
|
|
1056
|
+
if (pos < 2)
|
|
1057
|
+
pos = 9;
|
|
1058
|
+
}
|
|
1059
|
+
resultado = soma % 11 < 2 ? 0 : 11 - (soma % 11);
|
|
1060
|
+
return resultado === parseInt(digitos.charAt(1));
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
class UnbPessoaPesquisarComponent {
|
|
1065
|
+
constructor(pessoaService, snackBar) {
|
|
1066
|
+
this.pessoaService = pessoaService;
|
|
1067
|
+
this.snackBar = snackBar;
|
|
1068
|
+
this.isLoading = false;
|
|
1069
|
+
this.apiPessoaConfig = { url: '', token: '' };
|
|
1070
|
+
this.pesquisarPorCPF = true;
|
|
1071
|
+
this.pesquisarPorCNPJ = true;
|
|
1072
|
+
this.pesquisarPorEstrangeiro = true;
|
|
1073
|
+
this.campoPesquisaMaxWidth = '400px';
|
|
1074
|
+
this.pessoaEmitted = new EventEmitter();
|
|
1075
|
+
this.pessoa = new UnbPessoaModel();
|
|
1076
|
+
this.mostrarPesquisa = true;
|
|
1077
|
+
this.limparAposPesquisa = false; // indica se deve limpar o cpf apos pesquisar
|
|
1078
|
+
this.label = "Digite o CPF/CNPJ ou Passaporte"; // eh o que mostra no topo do componente
|
|
1079
|
+
this.placeholder = ""; // eh o que mostra como placeholder topo do componente
|
|
1080
|
+
this.hint = ""; // dica que aparece debaixo do campo
|
|
1081
|
+
// usado pra saber se mostra ou nao o botao de incluir pessoa
|
|
1082
|
+
this.pessoaEncontrado = false;
|
|
1083
|
+
this.listaTipoEndereco = [];
|
|
1084
|
+
this.listaTipoTelefone = [];
|
|
1085
|
+
this.listaTipoEmail = [];
|
|
1086
|
+
}
|
|
1087
|
+
ngOnInit() {
|
|
1088
|
+
if (this.apiPessoaConfig.url.endsWith('/')) {
|
|
1089
|
+
this.apiPessoaConfig.url = this.apiPessoaConfig.url.slice(0, -1);
|
|
1090
|
+
}
|
|
1091
|
+
if (this.apiPessoaConfig.url == "") {
|
|
1092
|
+
this.handleErrorPrintConsole("[UnbPessoaPesquisarComponent] ERROR: apiPessoaConfig.url está null. Insira o parâmetro (apiPessoaConfig) com o valor válido!");
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
if (this.apiPessoaConfig.token == "") {
|
|
1096
|
+
this.handleErrorPrintConsole("[UnbPessoaPesquisarComponent] ERROR: apiPessoaConfig.token está null. Insira o parâmetro (apiPessoaConfig) com o valor do token da sua aplicação");
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
// se chegar com barra no final, eu retiro. Pra ficar no padrao
|
|
1100
|
+
if (this.apiPessoaConfig.url.endsWith('/')) {
|
|
1101
|
+
this.apiPessoaConfig.url = this.apiPessoaConfig.url.slice(0, -1);
|
|
1102
|
+
}
|
|
1103
|
+
// inicializa o serviço com a configuração da API
|
|
1104
|
+
this.pessoaService.setApiConfig(this.apiPessoaConfig);
|
|
1105
|
+
forkJoin({
|
|
1106
|
+
tiposEnd: this.pessoaService.getTipoEndereco(),
|
|
1107
|
+
tiposTel: this.pessoaService.getTipoTelefone(),
|
|
1108
|
+
tiposEmail: this.pessoaService.getTipoEmail()
|
|
1109
|
+
}).subscribe({
|
|
1110
|
+
next: ({ tiposEnd, tiposTel, tiposEmail }) => {
|
|
1111
|
+
this.listaTipoEndereco = tiposEnd;
|
|
1112
|
+
this.listaTipoTelefone = tiposTel;
|
|
1113
|
+
this.listaTipoEmail = tiposEmail;
|
|
1114
|
+
},
|
|
1115
|
+
error: (err) => {
|
|
1116
|
+
this.handleError("Falha ao carregar dados de apoio. Recarregue a página.");
|
|
1117
|
+
console.error("Erro no forkJoin do pesquisar:", err);
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1120
|
+
// Conta quantos dos inputs estão como true
|
|
1121
|
+
const opcoesAtivas = [this.pesquisarPorCPF, this.pesquisarPorCNPJ, this.pesquisarPorEstrangeiro].filter(op => op).length;
|
|
1122
|
+
// Exibe a opcao do tipo de pessoa, somente se mais de um estiver selecionado
|
|
1123
|
+
if (opcoesAtivas > 1) {
|
|
1124
|
+
this.mostrarTipoPessoa = opcoesAtivas > 1;
|
|
1125
|
+
}
|
|
1126
|
+
else {
|
|
1127
|
+
// entao tenho que marcar qual foi selecionada
|
|
1128
|
+
if (this.pesquisarPorCPF) {
|
|
1129
|
+
this.pessoa.tipoPessoa = TipoPessoaEnum.FISICA;
|
|
1130
|
+
}
|
|
1131
|
+
else if (this.pesquisarPorCNPJ) {
|
|
1132
|
+
this.pessoa.tipoPessoa = TipoPessoaEnum.JURIDICA;
|
|
1133
|
+
}
|
|
1134
|
+
else if (this.pesquisarPorEstrangeiro) {
|
|
1135
|
+
this.pessoa.tipoPessoa = TipoPessoaEnum.ESTRANGEIRA;
|
|
1136
|
+
}
|
|
1137
|
+
else {
|
|
1138
|
+
this.handleErrorPrintConsole("[UnbPessoaPesquisarComponent] ERROR: pesquisarPorCPF, pesquisarPorCNPJ e pesquisarPorEstrangeiro está falso. Marque pelo menos um como true");
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
// seleciona o radio button padrao
|
|
1143
|
+
if (this.defaultTipoPessoa == TipoPessoaEnum.FISICA && this.pesquisarPorCPF) {
|
|
1144
|
+
this.pessoa.tipoPessoa = this.defaultTipoPessoa;
|
|
1145
|
+
}
|
|
1146
|
+
else if (this.defaultTipoPessoa == TipoPessoaEnum.JURIDICA && this.pesquisarPorCNPJ) {
|
|
1147
|
+
this.pessoa.tipoPessoa = this.defaultTipoPessoa;
|
|
1148
|
+
}
|
|
1149
|
+
else if (this.defaultTipoPessoa == TipoPessoaEnum.ESTRANGEIRA && this.pesquisarPorEstrangeiro) {
|
|
1150
|
+
this.pessoa.tipoPessoa = this.defaultTipoPessoa;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
pesquisar() {
|
|
1154
|
+
if (this.validar() == false)
|
|
1155
|
+
return;
|
|
1156
|
+
this.isLoading = true;
|
|
1157
|
+
let result;
|
|
1158
|
+
if (this.pessoa.tipoPessoa == TipoPessoaEnum.FISICA) {
|
|
1159
|
+
let cpf = this.pessoa.cpf.match(/\d/g)?.join(""); // remove caracteres
|
|
1160
|
+
result = this.pessoaService.findByCpf(cpf);
|
|
1161
|
+
}
|
|
1162
|
+
else if (this.pessoa.tipoPessoa == TipoPessoaEnum.JURIDICA) {
|
|
1163
|
+
let cnpj = this.pessoa.cnpj.match(/\d/g)?.join(""); // remove caracteres
|
|
1164
|
+
result = this.pessoaService.findByCnpj(cnpj);
|
|
1165
|
+
}
|
|
1166
|
+
else if (this.pessoa.tipoPessoa == TipoPessoaEnum.ESTRANGEIRA) {
|
|
1167
|
+
result = this.pessoaService.findByPassaporte(this.pessoa.passaporte);
|
|
1168
|
+
}
|
|
1169
|
+
if (result) {
|
|
1170
|
+
result.subscribe({
|
|
1171
|
+
next: this.hadleResult.bind(this),
|
|
1172
|
+
error: this.handleError.bind(this)
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
validar() {
|
|
1177
|
+
if (this.apiPessoaConfig.url == "") {
|
|
1178
|
+
this.handleErrorPrintConsole("[UnbPessoaPesquisarComponent] ERROR: apiPessoaConfig.url está null. Insira o parâmetro (apiPessoaConfig) com o valor válido!");
|
|
1179
|
+
return false;
|
|
1180
|
+
}
|
|
1181
|
+
if (this.apiPessoaConfig.token == "") {
|
|
1182
|
+
this.handleErrorPrintConsole("[UnbPessoaPesquisarComponent] ERROR: apiPessoaConfig.token está null. Insira o parâmetro (apiPessoaConfig) com o valor do token da sua aplicação");
|
|
1183
|
+
return false;
|
|
1184
|
+
}
|
|
1185
|
+
if (this.pessoa.tipoPessoa == TipoPessoaEnum.FISICA) {
|
|
1186
|
+
if (this.pessoa.cpf == null || (this.pessoa.cpf != null && this.pessoa.cpf == "")) {
|
|
1187
|
+
this.handleError("CPF é um campo obrigatório.");
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
else if (!UnbUtils.validarCPF(this.pessoa.cpf)) {
|
|
1191
|
+
this.handleError("Digite um valor válido para o CPF");
|
|
1192
|
+
return false;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
else if (this.pessoa.tipoPessoa == TipoPessoaEnum.JURIDICA) {
|
|
1196
|
+
if (this.pessoa.cnpj == null || (this.pessoa.cnpj != null && this.pessoa.cnpj == "")) {
|
|
1197
|
+
this.handleError("CNPJ é um campo obrigatório");
|
|
1198
|
+
return false;
|
|
1199
|
+
}
|
|
1200
|
+
else if (!UnbUtils.validarCNPJ(this.pessoa.cnpj)) {
|
|
1201
|
+
this.handleError("Digite um valor válido para o CNPJ!");
|
|
1202
|
+
return false;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
else if (this.pessoa.tipoPessoa == TipoPessoaEnum.ESTRANGEIRA) {
|
|
1206
|
+
if (this.pessoa.passaporte == null || (this.pessoa.passaporte != null && this.pessoa.passaporte == "")) {
|
|
1207
|
+
this.handleError("Passaporte é um campo obrigatório");
|
|
1208
|
+
return false;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
else {
|
|
1212
|
+
this.handleError("Selecione um tipo de pessoa!");
|
|
1213
|
+
return false;
|
|
1214
|
+
}
|
|
1215
|
+
return true;
|
|
1216
|
+
}
|
|
1217
|
+
// Em unb-pessoa-pesquisar.component.ts
|
|
1218
|
+
hadleResult(resultado) {
|
|
1219
|
+
this.isLoading = false;
|
|
1220
|
+
if (resultado) {
|
|
1221
|
+
resultado.tipoPessoa = this.pessoa.tipoPessoa; // o backend nao retorna o tipo pessoa. entao tenho que atribuir antes
|
|
1222
|
+
this.pessoa = resultado;
|
|
1223
|
+
// --- SEÇÃO DE LIMPEZA DE DADOS PRINCIPAIS (VOCÊ JÁ TINHA) ---
|
|
1224
|
+
if (this.pessoa.sexo) {
|
|
1225
|
+
if (this.pessoa.sexo.toUpperCase().trim() === 'FEMININO') {
|
|
1226
|
+
this.pessoa.codigoSexo = 2;
|
|
1227
|
+
}
|
|
1228
|
+
else if (this.pessoa.sexo.toUpperCase().trim() === 'MASCULINO') {
|
|
1229
|
+
this.pessoa.codigoSexo = 1;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
if (this.pessoa.dataNascimento) {
|
|
1233
|
+
this.pessoa.dataNascimento = this.parseData(this.pessoa.dataNascimento);
|
|
1234
|
+
}
|
|
1235
|
+
if (this.pessoa.estadoCivil) {
|
|
1236
|
+
this.pessoa.codigoEstadoCivil = this.parseCodigo(this.pessoa.estadoCivil);
|
|
1237
|
+
}
|
|
1238
|
+
if (this.pessoa.paisNascimento) {
|
|
1239
|
+
this.pessoa.codigoPaisNascimento = this.parseCodigo(this.pessoa.paisNascimento);
|
|
1240
|
+
}
|
|
1241
|
+
if (this.pessoa.escolaridade) {
|
|
1242
|
+
this.pessoa.escolaridade = this.parseCodigo(this.pessoa.escolaridade);
|
|
1243
|
+
}
|
|
1244
|
+
// 1. Processa Endereços
|
|
1245
|
+
// O payload 'salvar' espera: ordemEndereco, tipoEnderecoCodigo, paisEnderecoCodigo, ufEndereco
|
|
1246
|
+
// 1. Processa Endereços
|
|
1247
|
+
if (this.pessoa.enderecos && this.listaTipoEndereco.length > 0) {
|
|
1248
|
+
// --- CORREÇÃO: Adicionado 'i' ao forEach ---
|
|
1249
|
+
this.pessoa.enderecos.forEach((end, i) => {
|
|
1250
|
+
// Traduz o 'tipo' (string) para 'tipoEnderecoCodigo' (number)
|
|
1251
|
+
if (!end.tipoEnderecoCodigo && end.tipo) {
|
|
1252
|
+
const tipoEncontrado = this.listaTipoEndereco.find(t => t.denominacao?.toLowerCase() === end.tipo?.toLowerCase());
|
|
1253
|
+
if (tipoEncontrado)
|
|
1254
|
+
end.tipoEnderecoCodigo = tipoEncontrado.codigo;
|
|
1255
|
+
}
|
|
1256
|
+
// Traduz 'pais' (string '22 - BRASIL') para 'paisEnderecoCodigo' (number)
|
|
1257
|
+
if (!end.paisEnderecoCodigo && end.pais) {
|
|
1258
|
+
end.paisEnderecoCodigo = this.parseCodigo(end.pais);
|
|
1259
|
+
}
|
|
1260
|
+
// Mapeia 'ordem' -> 'ordemEndereco' ou usa o índice (i + 1)
|
|
1261
|
+
// O payload de salvar (no form) espera 'ordemEndereco'
|
|
1262
|
+
end.ordemEndereco = end.ordemEndereco || end.ordem || (i + 1);
|
|
1263
|
+
// Mapeia 'uf' -> 'ufEndereco'
|
|
1264
|
+
if (!end.ufEndereco && end.uf) {
|
|
1265
|
+
end.ufEndereco = end.uf;
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
// 2. Processa Telefones
|
|
1270
|
+
if (this.pessoa.telefones && this.listaTipoTelefone.length > 0) {
|
|
1271
|
+
// --- CORREÇÃO: Adicionado 'i' ao forEach ---
|
|
1272
|
+
this.pessoa.telefones.forEach((tel, i) => {
|
|
1273
|
+
if (!tel.tipoTelefoneCodigo && tel.tipo) {
|
|
1274
|
+
const tipoEncontrado = this.listaTipoTelefone.find(t => t.denominacao?.toLowerCase() === tel.tipo?.toLowerCase());
|
|
1275
|
+
if (tipoEncontrado)
|
|
1276
|
+
tel.tipoTelefoneCodigo = tipoEncontrado.codigo;
|
|
1277
|
+
}
|
|
1278
|
+
// --- CORREÇÃO: Lógica da Ordem ---
|
|
1279
|
+
// O payload de salvar (no form) lê 'tel.ordem'
|
|
1280
|
+
tel.ordem = tel.ordem || (i + 1);
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
// 3. Processa Emails
|
|
1284
|
+
if (this.pessoa.emails && this.listaTipoEmail.length > 0) {
|
|
1285
|
+
// --- CORREÇÃO: Adicionado 'i' ao forEach ---
|
|
1286
|
+
this.pessoa.emails.forEach((email, i) => {
|
|
1287
|
+
if (!email.tipoEmailCodigo && email.tipo) {
|
|
1288
|
+
const tipoEncontrado = this.listaTipoEmail.find(t => t.denominacao?.toLowerCase() === email.tipo?.toLowerCase());
|
|
1289
|
+
if (tipoEncontrado)
|
|
1290
|
+
email.tipoEmailCodigo = tipoEncontrado.codigo;
|
|
1291
|
+
}
|
|
1292
|
+
// --- CORREÇÃO: Lógica da Ordem ---
|
|
1293
|
+
// O payload de salvar (no form) lê 'email.ordem'
|
|
1294
|
+
email.ordem = email.ordem || (i + 1);
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
if (this.pessoa.tipoPessoa == TipoPessoaEnum.FISICA) {
|
|
1298
|
+
this.pessoa.cpf = UnbUtils.formataCpf(resultado.cpf);
|
|
1299
|
+
}
|
|
1300
|
+
else if (this.pessoa.tipoPessoa == TipoPessoaEnum.JURIDICA) {
|
|
1301
|
+
this.pessoa.cnpj = UnbUtils.formataCnpj(resultado.cnpj);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
else {
|
|
1305
|
+
// se chegar aki eh pq nao encontrou... (lógica que já existe)
|
|
1306
|
+
let novaPessoa = new UnbPessoaModel();
|
|
1307
|
+
novaPessoa.tipoPessoa = this.pessoa.tipoPessoa;
|
|
1308
|
+
if (this.pessoa.tipoPessoa == TipoPessoaEnum.FISICA) {
|
|
1309
|
+
novaPessoa.cpf = this.pessoa.cpf;
|
|
1310
|
+
}
|
|
1311
|
+
else if (this.pessoa.tipoPessoa == TipoPessoaEnum.JURIDICA) {
|
|
1312
|
+
novaPessoa.cnpj = this.pessoa.cnpj;
|
|
1313
|
+
}
|
|
1314
|
+
else {
|
|
1315
|
+
novaPessoa.passaporte = this.pessoa.passaporte;
|
|
1316
|
+
}
|
|
1317
|
+
this.pessoa = novaPessoa;
|
|
1318
|
+
}
|
|
1319
|
+
this.pessoaEmitted.emit(this.pessoa);
|
|
1320
|
+
}
|
|
1321
|
+
parseCodigo(valorString) {
|
|
1322
|
+
if (typeof valorString === 'number') {
|
|
1323
|
+
return valorString; // Já é um número
|
|
1324
|
+
}
|
|
1325
|
+
if (typeof valorString !== 'string' || !valorString.includes(' - ')) {
|
|
1326
|
+
// Tenta converter direto, caso o backend mande só o número como string
|
|
1327
|
+
const num = parseInt(valorString, 10);
|
|
1328
|
+
return isNaN(num) ? null : num;
|
|
1329
|
+
}
|
|
1330
|
+
const partes = valorString.split(' - ');
|
|
1331
|
+
const codigo = parseInt(partes[0].trim(), 10);
|
|
1332
|
+
return isNaN(codigo) ? null : codigo;
|
|
1333
|
+
}
|
|
1334
|
+
/**
|
|
1335
|
+
* Converte uma string no formato 'dd/MM/yyyy' para um objeto Date.
|
|
1336
|
+
* Retorna null se o formato for inválido.
|
|
1337
|
+
*/
|
|
1338
|
+
parseData(dataString) {
|
|
1339
|
+
if (dataString instanceof Date) {
|
|
1340
|
+
return dataString; // Já é um objeto Date
|
|
1341
|
+
}
|
|
1342
|
+
if (typeof dataString !== 'string' || !dataString.includes('/')) {
|
|
1343
|
+
return null;
|
|
1344
|
+
}
|
|
1345
|
+
const partes = dataString.split('/'); // [dd, MM, yyyy]
|
|
1346
|
+
if (partes.length === 3) {
|
|
1347
|
+
const dia = parseInt(partes[0], 10);
|
|
1348
|
+
const mes = parseInt(partes[1], 10) - 1; // Mês no JS é 0-indexado
|
|
1349
|
+
const ano = parseInt(partes[2], 10);
|
|
1350
|
+
// Verifica se a data é válida
|
|
1351
|
+
const dataObj = new Date(ano, mes, dia);
|
|
1352
|
+
if (dataObj.getFullYear() === ano && dataObj.getMonth() === mes && dataObj.getDate() === dia) {
|
|
1353
|
+
return dataObj;
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
return null; // Formato inválido
|
|
1357
|
+
}
|
|
1358
|
+
handleError(erro) {
|
|
1359
|
+
this.openSnackBar(erro);
|
|
1360
|
+
this.isLoading = false;
|
|
1361
|
+
// se chegar aki, entao nao encontrou a pessoa. Mas damos a chance de incluir pessoa
|
|
1362
|
+
this.pessoaEncontrado = false;
|
|
1363
|
+
}
|
|
1364
|
+
handleErrorPrintConsole(erro) {
|
|
1365
|
+
console.log(erro);
|
|
1366
|
+
this.handleError(erro);
|
|
1367
|
+
}
|
|
1368
|
+
openSnackBar(message) {
|
|
1369
|
+
this.snackBar.open(message, 'x', {
|
|
1370
|
+
duration: 5000,
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
tipoPessoaEnum() {
|
|
1374
|
+
return TipoPessoaEnum;
|
|
1375
|
+
}
|
|
1376
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaPesquisarComponent, deps: [{ token: UnBPessoaService }, { token: i1$2.MatSnackBar }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1377
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: UnbPessoaPesquisarComponent, selector: "lib-unb-pessoa-pesquisar", inputs: { apiPessoaConfig: "apiPessoaConfig", pesquisarPorCPF: "pesquisarPorCPF", pesquisarPorCNPJ: "pesquisarPorCNPJ", pesquisarPorEstrangeiro: "pesquisarPorEstrangeiro", defaultTipoPessoa: "defaultTipoPessoa", campoPesquisaMaxWidth: "campoPesquisaMaxWidth", pessoa: "pessoa", mostrarPesquisa: "mostrarPesquisa", limparAposPesquisa: "limparAposPesquisa", label: "label", placeholder: "placeholder", hint: "hint" }, outputs: { pessoaEmitted: "pessoaEmitted" }, ngImport: i0, template: "<form #pessoaForm=\"ngForm\" class=\"pesquisa-container\" [ngStyle]=\"{'--tamanho-maximo': campoPesquisaMaxWidth}\" (ngSubmit)=\"pesquisar()\">\r\n <div class=\"form-wrapper\">\r\n <div *ngIf=\"mostrarTipoPessoa\" class=\"radio-container\">\r\n <mat-radio-group aria-label=\"Tipo de Pessoa\" [(ngModel)]=\"pessoa.tipoPessoa\" #tipoPessoa=\"ngModel\" name=\"tipoPessoa\">\r\n <mat-radio-button *ngIf=\"pesquisarPorCPF\" value=\"{{ tipoPessoaEnum().FISICA}}\">Pessoa F\u00EDsica</mat-radio-button>\r\n <mat-radio-button *ngIf=\"pesquisarPorCNPJ\" value=\"{{tipoPessoaEnum().JURIDICA}}\"> Pessoa Jur\u00EDdica</mat-radio-button>\r\n <mat-radio-button *ngIf=\"pesquisarPorEstrangeiro\" value=\"{{tipoPessoaEnum().ESTRANGEIRA}}\">Estrangeiro</mat-radio-button>\r\n </mat-radio-group>\r\n </div>\r\n\r\n <div class=\"break\"></div>\r\n \r\n <ng-container *ngIf=\"pessoa.tipoPessoa === tipoPessoaEnum().FISICA\">\r\n <mat-form-field appearance=\"outline\">\r\n <mat-label>CPF</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.cpf\" name=\"cpf\" #cpf=\"ngModel\" required={{true}}/> \r\n <button matSuffix mat-icon-button type=\"button\" aria-label=\"Pesquisar\" [disabled]=\"isLoading\" (click)=\"pesquisar()\">\r\n <ng-container *ngIf=\"!isLoading; else loadingIcon\">\r\n <mat-icon>search</mat-icon>\r\n </ng-container>\r\n <ng-template #loadingIcon>\r\n <mat-progress-spinner\r\n [diameter]=\"20\"\r\n mode=\"indeterminate\"\r\n color=\"primary\"\r\n class=\"spinner-button\">\r\n </mat-progress-spinner>\r\n </ng-template>\r\n </button>\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"pessoa.tipoPessoa === tipoPessoaEnum().ESTRANGEIRA\">\r\n <mat-form-field appearance=\"outline\">\r\n <mat-label>Passaporte</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.passaporte\" name=\"passaporte\" required=\"true\" />\r\n <button matSuffix mat-icon-button type=\"button\" aria-label=\"Pesquisar\" (click)=\"pesquisar()\">\r\n <ng-container *ngIf=\"!isLoading; else loadingIcon\">\r\n <mat-icon>search</mat-icon>\r\n </ng-container>\r\n <ng-template #loadingIcon>\r\n <mat-progress-spinner\r\n [diameter]=\"20\"\r\n mode=\"indeterminate\"\r\n color=\"primary\"\r\n class=\"spinner-button\">\r\n </mat-progress-spinner>\r\n </ng-template>\r\n </button>\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"pessoa.tipoPessoa === tipoPessoaEnum().JURIDICA\">\r\n <mat-form-field appearance=\"outline\">\r\n <mat-label>CNPJ</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.cnpj\" name=\"cnpj\" required=\"true\" />\r\n <button matSuffix mat-icon-button type=\"button\" aria-label=\"Pesquisar\" (click)=\"pesquisar()\">\r\n <ng-container *ngIf=\"!isLoading; else loadingIcon\">\r\n <mat-icon>search</mat-icon>\r\n </ng-container>\r\n <ng-template #loadingIcon>\r\n <mat-progress-spinner\r\n [diameter]=\"20\"\r\n mode=\"indeterminate\"\r\n color=\"primary\"\r\n class=\"spinner-button\">\r\n </mat-progress-spinner>\r\n </ng-template>\r\n </button>\r\n </mat-form-field>\r\n </ng-container>\r\n </div>\r\n</form>", styles: [".pesquisa-container{display:flex;justify-content:left}.form-wrapper{display:flex;flex-direction:column;width:100%;max-width:var(--tamanho-maximo);gap:5px}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i5$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i5$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i5$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i5$2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i5$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i5$2.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i7.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: i7$2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i7$2.MatLabel, selector: "mat-label" }, { kind: "directive", type: i7$2.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i8$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i9$1.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "directive", type: i10$1.MatRadioGroup, selector: "mat-radio-group", inputs: ["color", "name", "labelPosition", "value", "selected", "disabled", "required"], outputs: ["change"], exportAs: ["matRadioGroup"] }, { kind: "component", type: i10$1.MatRadioButton, selector: "mat-radio-button", inputs: ["id", "name", "aria-label", "aria-labelledby", "aria-describedby", "disableRipple", "tabIndex", "checked", "value", "labelPosition", "disabled", "required", "color"], outputs: ["change"], exportAs: ["matRadioButton"] }] }); }
|
|
1378
|
+
}
|
|
1379
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaPesquisarComponent, decorators: [{
|
|
1380
|
+
type: Component,
|
|
1381
|
+
args: [{ selector: 'lib-unb-pessoa-pesquisar', standalone: false, template: "<form #pessoaForm=\"ngForm\" class=\"pesquisa-container\" [ngStyle]=\"{'--tamanho-maximo': campoPesquisaMaxWidth}\" (ngSubmit)=\"pesquisar()\">\r\n <div class=\"form-wrapper\">\r\n <div *ngIf=\"mostrarTipoPessoa\" class=\"radio-container\">\r\n <mat-radio-group aria-label=\"Tipo de Pessoa\" [(ngModel)]=\"pessoa.tipoPessoa\" #tipoPessoa=\"ngModel\" name=\"tipoPessoa\">\r\n <mat-radio-button *ngIf=\"pesquisarPorCPF\" value=\"{{ tipoPessoaEnum().FISICA}}\">Pessoa F\u00EDsica</mat-radio-button>\r\n <mat-radio-button *ngIf=\"pesquisarPorCNPJ\" value=\"{{tipoPessoaEnum().JURIDICA}}\"> Pessoa Jur\u00EDdica</mat-radio-button>\r\n <mat-radio-button *ngIf=\"pesquisarPorEstrangeiro\" value=\"{{tipoPessoaEnum().ESTRANGEIRA}}\">Estrangeiro</mat-radio-button>\r\n </mat-radio-group>\r\n </div>\r\n\r\n <div class=\"break\"></div>\r\n \r\n <ng-container *ngIf=\"pessoa.tipoPessoa === tipoPessoaEnum().FISICA\">\r\n <mat-form-field appearance=\"outline\">\r\n <mat-label>CPF</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.cpf\" name=\"cpf\" #cpf=\"ngModel\" required={{true}}/> \r\n <button matSuffix mat-icon-button type=\"button\" aria-label=\"Pesquisar\" [disabled]=\"isLoading\" (click)=\"pesquisar()\">\r\n <ng-container *ngIf=\"!isLoading; else loadingIcon\">\r\n <mat-icon>search</mat-icon>\r\n </ng-container>\r\n <ng-template #loadingIcon>\r\n <mat-progress-spinner\r\n [diameter]=\"20\"\r\n mode=\"indeterminate\"\r\n color=\"primary\"\r\n class=\"spinner-button\">\r\n </mat-progress-spinner>\r\n </ng-template>\r\n </button>\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"pessoa.tipoPessoa === tipoPessoaEnum().ESTRANGEIRA\">\r\n <mat-form-field appearance=\"outline\">\r\n <mat-label>Passaporte</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.passaporte\" name=\"passaporte\" required=\"true\" />\r\n <button matSuffix mat-icon-button type=\"button\" aria-label=\"Pesquisar\" (click)=\"pesquisar()\">\r\n <ng-container *ngIf=\"!isLoading; else loadingIcon\">\r\n <mat-icon>search</mat-icon>\r\n </ng-container>\r\n <ng-template #loadingIcon>\r\n <mat-progress-spinner\r\n [diameter]=\"20\"\r\n mode=\"indeterminate\"\r\n color=\"primary\"\r\n class=\"spinner-button\">\r\n </mat-progress-spinner>\r\n </ng-template>\r\n </button>\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"pessoa.tipoPessoa === tipoPessoaEnum().JURIDICA\">\r\n <mat-form-field appearance=\"outline\">\r\n <mat-label>CNPJ</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.cnpj\" name=\"cnpj\" required=\"true\" />\r\n <button matSuffix mat-icon-button type=\"button\" aria-label=\"Pesquisar\" (click)=\"pesquisar()\">\r\n <ng-container *ngIf=\"!isLoading; else loadingIcon\">\r\n <mat-icon>search</mat-icon>\r\n </ng-container>\r\n <ng-template #loadingIcon>\r\n <mat-progress-spinner\r\n [diameter]=\"20\"\r\n mode=\"indeterminate\"\r\n color=\"primary\"\r\n class=\"spinner-button\">\r\n </mat-progress-spinner>\r\n </ng-template>\r\n </button>\r\n </mat-form-field>\r\n </ng-container>\r\n </div>\r\n</form>", styles: [".pesquisa-container{display:flex;justify-content:left}.form-wrapper{display:flex;flex-direction:column;width:100%;max-width:var(--tamanho-maximo);gap:5px}\n"] }]
|
|
1382
|
+
}], ctorParameters: () => [{ type: UnBPessoaService }, { type: i1$2.MatSnackBar }], propDecorators: { apiPessoaConfig: [{
|
|
1383
|
+
type: Input
|
|
1384
|
+
}], pesquisarPorCPF: [{
|
|
1385
|
+
type: Input
|
|
1386
|
+
}], pesquisarPorCNPJ: [{
|
|
1387
|
+
type: Input
|
|
1388
|
+
}], pesquisarPorEstrangeiro: [{
|
|
1389
|
+
type: Input
|
|
1390
|
+
}], defaultTipoPessoa: [{
|
|
1391
|
+
type: Input
|
|
1392
|
+
}], campoPesquisaMaxWidth: [{
|
|
1393
|
+
type: Input
|
|
1394
|
+
}], pessoaEmitted: [{
|
|
1395
|
+
type: Output
|
|
1396
|
+
}], pessoa: [{
|
|
1397
|
+
type: Input
|
|
1398
|
+
}], mostrarPesquisa: [{
|
|
1399
|
+
type: Input
|
|
1400
|
+
}], limparAposPesquisa: [{
|
|
1401
|
+
type: Input
|
|
1402
|
+
}], label: [{
|
|
1403
|
+
type: Input
|
|
1404
|
+
}], placeholder: [{
|
|
1405
|
+
type: Input
|
|
1406
|
+
}], hint: [{
|
|
1407
|
+
type: Input
|
|
1408
|
+
}] } });
|
|
1409
|
+
|
|
1410
|
+
class UnbPessoaTelefone {
|
|
1411
|
+
constructor() {
|
|
1412
|
+
// usado pelo componente unb-pesoa-form, pra indicar que o usuario estah editando
|
|
1413
|
+
this.modoEdicao = false;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
class UnbPessoaTelefoneTipo {
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
class UnbPessoaTelefoneFormComponent {
|
|
1420
|
+
constructor(snackBar, service, dialogRef, data) {
|
|
1421
|
+
this.snackBar = snackBar;
|
|
1422
|
+
this.service = service;
|
|
1423
|
+
this.dialogRef = dialogRef;
|
|
1424
|
+
this.data = data;
|
|
1425
|
+
this.telefone = new UnbPessoaTelefone();
|
|
1426
|
+
this.listaTipoTelefone = [];
|
|
1427
|
+
this.telefone = JSON.parse(JSON.stringify(data.telefone)); // O e-mail específico para edição
|
|
1428
|
+
// Verifique se a lista de e-mails foi passada e atribua-a
|
|
1429
|
+
if (data.telefonesList) {
|
|
1430
|
+
this.telefonesList = JSON.parse(JSON.stringify(data.telefonesList)); // Faça uma cópia profunda se for manipular
|
|
1431
|
+
}
|
|
1432
|
+
else {
|
|
1433
|
+
this.telefonesList = []; // Inicialize como vazio se não for passada
|
|
1434
|
+
}
|
|
1435
|
+
if (!this.telefone) {
|
|
1436
|
+
this.telefone = new UnbPessoaTelefone();
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
ngOnInit() {
|
|
1440
|
+
this.tipoTelefone = this.service.getTipoTelefone();
|
|
1441
|
+
// Inscreve para guardar a lista em uma variável comum
|
|
1442
|
+
this.tipoTelefone.subscribe(lista => {
|
|
1443
|
+
this.listaTipoTelefone = lista;
|
|
1444
|
+
// Se já tiver tipoTelefoneCodigo, preenche o nome correspondente
|
|
1445
|
+
if (this.telefone.tipoTelefoneCodigo != null) {
|
|
1446
|
+
const tipoEncontrado = lista.find(t => t.codigo === this.telefone.tipoTelefoneCodigo);
|
|
1447
|
+
if (tipoEncontrado) {
|
|
1448
|
+
this.telefone.tipo = tipoEncontrado.denominacao;
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
else if (this.telefone.tipo) {
|
|
1452
|
+
const tipoEncontrado = lista.find(t => t.denominacao?.toLowerCase() === this.telefone.tipo?.toLowerCase());
|
|
1453
|
+
if (tipoEncontrado) {
|
|
1454
|
+
this.telefone.tipoTelefoneCodigo = tipoEncontrado.codigo;
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
salvar(form) {
|
|
1460
|
+
if (form.invalid) {
|
|
1461
|
+
this.openSnackBar('Existem erros no formulário, por favor, verificar.');
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1464
|
+
// 1. Define o 'tipo' padrão (1) se não for preenchido (Conforme sua solicitação)
|
|
1465
|
+
if (!this.telefone.tipoTelefoneCodigo) {
|
|
1466
|
+
this.telefone.tipoTelefoneCodigo = 1; // 1 é geralmente 'Residencial' ou 'Principal'
|
|
1467
|
+
}
|
|
1468
|
+
// 2. Define a 'ordem' (que o back-end chama de 'ordemTelefone')
|
|
1469
|
+
if (!this.telefone.ordem || this.telefone.ordem === 0) {
|
|
1470
|
+
let maxOrdem = 0;
|
|
1471
|
+
// Verifica se a lista de telefones já existe e tem itens
|
|
1472
|
+
if (this.telefonesList && this.telefonesList.length > 0) {
|
|
1473
|
+
maxOrdem = Math.max(...this.telefonesList.map(t => t.ordem || 0));
|
|
1474
|
+
}
|
|
1475
|
+
// Define a ordem do novo telefone como a maior ordem + 1
|
|
1476
|
+
this.telefone.ordem = maxOrdem + 1;
|
|
1477
|
+
}
|
|
1478
|
+
if (this.validar(this.telefone) == false)
|
|
1479
|
+
return;
|
|
1480
|
+
this.telefoneSalvo = this.telefone;
|
|
1481
|
+
this.salvarclose();
|
|
1482
|
+
}
|
|
1483
|
+
compararTipos(t1, t2) {
|
|
1484
|
+
return t1 && t2 && t1 === t2;
|
|
1485
|
+
}
|
|
1486
|
+
onTipoSelecionado(codigoSelecionado) {
|
|
1487
|
+
const tipoSelecionado = this.listaTipoTelefone.find(t => t.codigo === codigoSelecionado); // <--- Renomeado de listaTipoEndereco
|
|
1488
|
+
if (tipoSelecionado) {
|
|
1489
|
+
this.telefone.tipo = tipoSelecionado.denominacao;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Valida o objeto de telefone com base nas regras do backend.
|
|
1494
|
+
* Retorna true se o telefone for válido, false caso contrário.
|
|
1495
|
+
*/
|
|
1496
|
+
validar(telefoneToValidate) {
|
|
1497
|
+
// 1. Validação de Número (Obrigatório)
|
|
1498
|
+
if (!telefoneToValidate.numero || telefoneToValidate.numero.trim() === '') {
|
|
1499
|
+
this.openSnackBar("Número do telefone é um campo obrigatório.");
|
|
1500
|
+
return false;
|
|
1501
|
+
}
|
|
1502
|
+
// 2. Validação de Número (Formato)
|
|
1503
|
+
// que ele espera 8 ou 9 dígitos numéricos (padrão Brasil).
|
|
1504
|
+
const numeroLimpo = telefoneToValidate.numero.replace(/\D/g, ''); // Remove não-dígitos
|
|
1505
|
+
if (numeroLimpo.length !== 9) {
|
|
1506
|
+
this.openSnackBar("Número do telefone deve conter exatamente 9 dígitos.");
|
|
1507
|
+
return false;
|
|
1508
|
+
}
|
|
1509
|
+
// 3. Validação de DDD (Obrigatório - Boa prática, embora o Java não exija)
|
|
1510
|
+
if (!telefoneToValidate.ddd || telefoneToValidate.ddd.trim() === '') {
|
|
1511
|
+
this.openSnackBar("DDD é um campo obrigatório.");
|
|
1512
|
+
return false;
|
|
1513
|
+
}
|
|
1514
|
+
// 4. Validação de DDD (Tamanho Máximo)
|
|
1515
|
+
if (telefoneToValidate.ddd.trim().length > 3) {
|
|
1516
|
+
this.openSnackBar("DDD deve ter no máximo 3 caracteres.");
|
|
1517
|
+
return false;
|
|
1518
|
+
}
|
|
1519
|
+
// 5. Validação de DDI (Tamanho Máximo)
|
|
1520
|
+
//
|
|
1521
|
+
if (telefoneToValidate.ddi && telefoneToValidate.ddi.trim().length > 5) {
|
|
1522
|
+
this.openSnackBar("DDI deve ter no máximo 5 caracteres.");
|
|
1523
|
+
return false;
|
|
1524
|
+
}
|
|
1525
|
+
// 6. Validação de Ramal (Tamanho Máximo)
|
|
1526
|
+
//
|
|
1527
|
+
if (telefoneToValidate.ramal && telefoneToValidate.ramal.trim().length > 6) {
|
|
1528
|
+
this.openSnackBar("Ramal deve ter no máximo 6 caracteres.");
|
|
1529
|
+
return false;
|
|
1530
|
+
}
|
|
1531
|
+
// 7. Validação de NomeResponsavel (Tamanho Máximo)
|
|
1532
|
+
//
|
|
1533
|
+
if (telefoneToValidate.nomeResponsavel && telefoneToValidate.nomeResponsavel.trim().length > 100) {
|
|
1534
|
+
this.openSnackBar("Nome do Responsável deve ter no máximo 100 caracteres.");
|
|
1535
|
+
return false;
|
|
1536
|
+
}
|
|
1537
|
+
return true; // Passou em todas as validações!
|
|
1538
|
+
}
|
|
1539
|
+
close() {
|
|
1540
|
+
this.dialogRef.close(null);
|
|
1541
|
+
}
|
|
1542
|
+
salvarclose() {
|
|
1543
|
+
this.dialogRef.close(this.telefoneSalvo);
|
|
1544
|
+
}
|
|
1545
|
+
openSnackBar(message) {
|
|
1546
|
+
this.snackBar.open(message, 'x', {
|
|
1547
|
+
duration: 5000,
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaTelefoneFormComponent, deps: [{ token: i1$2.MatSnackBar }, { token: UnBPessoaService }, { token: i3$2.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1551
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: UnbPessoaTelefoneFormComponent, selector: "lib-unb-pessoa-telefone-form", ngImport: i0, template: "<h1 mat-dialog-title>Cadastro de Telefone</h1>\r\n<form (ngSubmit)=\"salvar(form)\" #form=\"ngForm\">\r\n <mat-dialog-content>\r\n <div class=\"form-container\">\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>Tipo</mat-label>\r\n <mat-select [(ngModel)]=\"telefone.tipoTelefoneCodigo\" [compareWith]=\"compararTipos\" name=\"tipoTelefoneCodigo\" (selectionChange)=\"onTipoSelecionado($event.value)\" required>\r\n <mat-option *ngFor=\"let tipo of tipoTelefone | async\" [value]=\"tipo.codigo\">\r\n {{tipo.denominacao}}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>DDD</mat-label>\r\n <input type=\"text\" maxlength=\"3\" required matInput [(ngModel)]=\"telefone.ddd\" name=\"dddValue\" #dddValue=\"ngModel\" />\r\n </mat-form-field> \r\n \r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>N\u00FAmero</mat-label>\r\n <input type=\"text\" required maxlength=\"9\" matInput [(ngModel)]=\"telefone.numero\" name=\"telefoneValue\" #telefoneValue=\"ngModel\" />\r\n </mat-form-field>\r\n </div>\r\n </mat-dialog-content>\r\n\r\n <mat-dialog-actions align=\"end\">\r\n <button mat-stroked-button type=\"button\" color=\"warn\" (click)=\"close()\">Fechar</button>\r\n <button mat-flat-button type=\"submit\" color=\"primary\">Salvar</button>\r\n </mat-dialog-actions>\r\n</form>", styles: [".card-actions-buttons{display:flex;gap:5px;flex-wrap:wrap}.form-container{display:flex;flex-wrap:wrap;column-gap:10px;margin:10px}@media (max-width: 1000px){.form-container{flex-direction:column;gap:5px}}.break{flex-basis:100%;height:0}.form-5{flex:1 1 5%}.inline-table-container{display:flex;align-items:center;justify-content:space-between;padding:5px}@media (max-width: 600px){.form-5,.form-10,.form-15{flex:1 1 100%}}.form-10{flex:1 1 10%}.form-15{flex:1 1 15%}.form-20{flex:1 1 20%}.form-25{flex:1 1 25%}.form-30{flex:1 1 30%}.form-35{flex:1 1 35%}.form-40{flex:1 1 40%}.form-45{flex:1 1 45%}.form-50{flex:1 1 50%}.form-100{flex:1 1 100%;min-width:250px}.botoes-container{display:flex;gap:5px}@media (max-width: 600px){.botoes-container{margin-bottom:10px}.botoes-container button{flex:1;max-width:50%}}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i5$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i5$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i5$2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i5$2.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i5$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i5$2.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i7.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: i7$2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i7$2.MatLabel, selector: "mat-label" }, { kind: "directive", type: i8$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "directive", type: i3$2.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i3$2.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i3$2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "component", type: i9.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i10.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }] }); }
|
|
1552
|
+
}
|
|
1553
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaTelefoneFormComponent, decorators: [{
|
|
1554
|
+
type: Component,
|
|
1555
|
+
args: [{ standalone: false, selector: 'lib-unb-pessoa-telefone-form', template: "<h1 mat-dialog-title>Cadastro de Telefone</h1>\r\n<form (ngSubmit)=\"salvar(form)\" #form=\"ngForm\">\r\n <mat-dialog-content>\r\n <div class=\"form-container\">\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>Tipo</mat-label>\r\n <mat-select [(ngModel)]=\"telefone.tipoTelefoneCodigo\" [compareWith]=\"compararTipos\" name=\"tipoTelefoneCodigo\" (selectionChange)=\"onTipoSelecionado($event.value)\" required>\r\n <mat-option *ngFor=\"let tipo of tipoTelefone | async\" [value]=\"tipo.codigo\">\r\n {{tipo.denominacao}}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>DDD</mat-label>\r\n <input type=\"text\" maxlength=\"3\" required matInput [(ngModel)]=\"telefone.ddd\" name=\"dddValue\" #dddValue=\"ngModel\" />\r\n </mat-form-field> \r\n \r\n <mat-form-field class=\"form-100\" appearance=\"outline\">\r\n <mat-label>N\u00FAmero</mat-label>\r\n <input type=\"text\" required maxlength=\"9\" matInput [(ngModel)]=\"telefone.numero\" name=\"telefoneValue\" #telefoneValue=\"ngModel\" />\r\n </mat-form-field>\r\n </div>\r\n </mat-dialog-content>\r\n\r\n <mat-dialog-actions align=\"end\">\r\n <button mat-stroked-button type=\"button\" color=\"warn\" (click)=\"close()\">Fechar</button>\r\n <button mat-flat-button type=\"submit\" color=\"primary\">Salvar</button>\r\n </mat-dialog-actions>\r\n</form>", styles: [".card-actions-buttons{display:flex;gap:5px;flex-wrap:wrap}.form-container{display:flex;flex-wrap:wrap;column-gap:10px;margin:10px}@media (max-width: 1000px){.form-container{flex-direction:column;gap:5px}}.break{flex-basis:100%;height:0}.form-5{flex:1 1 5%}.inline-table-container{display:flex;align-items:center;justify-content:space-between;padding:5px}@media (max-width: 600px){.form-5,.form-10,.form-15{flex:1 1 100%}}.form-10{flex:1 1 10%}.form-15{flex:1 1 15%}.form-20{flex:1 1 20%}.form-25{flex:1 1 25%}.form-30{flex:1 1 30%}.form-35{flex:1 1 35%}.form-40{flex:1 1 40%}.form-45{flex:1 1 45%}.form-50{flex:1 1 50%}.form-100{flex:1 1 100%;min-width:250px}.botoes-container{display:flex;gap:5px}@media (max-width: 600px){.botoes-container{margin-bottom:10px}.botoes-container button{flex:1;max-width:50%}}\n"] }]
|
|
1556
|
+
}], ctorParameters: () => [{ type: i1$2.MatSnackBar }, { type: UnBPessoaService }, { type: i3$2.MatDialogRef }, { type: undefined, decorators: [{
|
|
1557
|
+
type: Inject,
|
|
1558
|
+
args: [MAT_DIALOG_DATA]
|
|
1559
|
+
}] }] });
|
|
1560
|
+
|
|
1561
|
+
class UnbPessoaTelefoneListComponent {
|
|
1562
|
+
constructor(snackBar, service, dialog) {
|
|
1563
|
+
this.snackBar = snackBar;
|
|
1564
|
+
this.service = service;
|
|
1565
|
+
this.dialog = dialog;
|
|
1566
|
+
this.podeEditar = true;
|
|
1567
|
+
this.telefones = [];
|
|
1568
|
+
this.apiPessoaConfig = { url: '', token: '' };
|
|
1569
|
+
this.telefonesEmitted = new EventEmitter();
|
|
1570
|
+
}
|
|
1571
|
+
ngOnInit() {
|
|
1572
|
+
this.tipoTelefone = this.service.getTipoTelefone();
|
|
1573
|
+
}
|
|
1574
|
+
// tem que fazer isso pq no on init eu ainda nao tenho a lista de telefones
|
|
1575
|
+
ngOnChanges(changes) {
|
|
1576
|
+
// Verifica se a propriedade 'telefones' mudou
|
|
1577
|
+
if (changes['telefones'] && this.telefones) {
|
|
1578
|
+
// chamada quando os dados realmente chegarem
|
|
1579
|
+
this.sortAndAssignOrder();
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
excluir(telefoneParaExcluir) {
|
|
1583
|
+
if (telefoneParaExcluir.codigo) {
|
|
1584
|
+
// Se tem código, remove por ele (mais seguro)
|
|
1585
|
+
this.telefones = this.telefones.filter(t => t.codigo !== telefoneParaExcluir.codigo);
|
|
1586
|
+
}
|
|
1587
|
+
else {
|
|
1588
|
+
// Se não tem código (novo item), remove pela ordem
|
|
1589
|
+
this.telefones = this.telefones.filter(t => t.ordem !== telefoneParaExcluir.ordem);
|
|
1590
|
+
}
|
|
1591
|
+
// Chama função existente que re-calcula as ordens e emite a lista atualizada
|
|
1592
|
+
this.atualizarOrdem();
|
|
1593
|
+
this.telefonesEmitted.emit(this.telefones);
|
|
1594
|
+
}
|
|
1595
|
+
editar(telefone) {
|
|
1596
|
+
this.openFormDialog(telefone);
|
|
1597
|
+
}
|
|
1598
|
+
atualizarOrdem() {
|
|
1599
|
+
this.telefones.forEach((telefone, idx) => {
|
|
1600
|
+
telefone.ordem = idx + 1;
|
|
1601
|
+
});
|
|
1602
|
+
// reemite a lista atualizada, igual antes
|
|
1603
|
+
this.telefonesEmitted.emit(this.telefones);
|
|
1604
|
+
}
|
|
1605
|
+
openFormDialog(toEdit) {
|
|
1606
|
+
const dialogRef = this.dialog.open(UnbPessoaTelefoneFormComponent, {
|
|
1607
|
+
width: '900px',
|
|
1608
|
+
data: {
|
|
1609
|
+
telefone: toEdit, // E-mail a ser editado ou vazio para novo
|
|
1610
|
+
telefonesList: this.telefones // A sua lista COMPLETA de e-mails
|
|
1611
|
+
},
|
|
1612
|
+
});
|
|
1613
|
+
dialogRef.afterClosed().subscribe(result => {
|
|
1614
|
+
if (!result) {
|
|
1615
|
+
return; // Usuário clicou em 'Fechar' ou 'Cancelar'
|
|
1616
|
+
}
|
|
1617
|
+
// 'result' é o objeto retornado pelo dialog (editado ou novo)
|
|
1618
|
+
let index = -1;
|
|
1619
|
+
// 1. Tenta encontrar pelo 'codigo' (para itens que já vieram do banco)
|
|
1620
|
+
if (result.codigo) {
|
|
1621
|
+
index = this.telefones.findIndex(t => t.codigo === result.codigo);
|
|
1622
|
+
}
|
|
1623
|
+
// 2. Se não achou pelo 'codigo', tenta pela 'ordem'.
|
|
1624
|
+
// A 'ordem' é o nosso identificador único para itens que
|
|
1625
|
+
// ainda não foram salvos no banco (criados/editados localmente).
|
|
1626
|
+
if (index === -1 && result.ordem) {
|
|
1627
|
+
index = this.telefones.findIndex(t => t.ordem === result.ordem);
|
|
1628
|
+
}
|
|
1629
|
+
if (index > -1) {
|
|
1630
|
+
// ENCONTROU (pelo 'codigo' ou pela 'ordem'): Atualiza o item existente
|
|
1631
|
+
this.telefones[index] = result;
|
|
1632
|
+
}
|
|
1633
|
+
else {
|
|
1634
|
+
// NÃO ENCONTROU: É um item 100% novo (não uma edição)
|
|
1635
|
+
// O form (unb-pessoa-telefone-form) já cuidou de
|
|
1636
|
+
// atribuir a 'ordem' correta (maxOrdem + 1)
|
|
1637
|
+
this.telefones.push(result);
|
|
1638
|
+
}
|
|
1639
|
+
// vamos apenas re-ordenar a lista pela 'ordem' que já temos
|
|
1640
|
+
// e depois emitir.
|
|
1641
|
+
this.telefones.sort((a, b) => (a.ordem ?? 0) - (b.ordem ?? 0));
|
|
1642
|
+
this.telefonesEmitted.emit(this.telefones);
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
moverTelefone(event) {
|
|
1646
|
+
// troca a posição dentro do array
|
|
1647
|
+
moveItemInArray(this.telefones, event.previousIndex, event.currentIndex);
|
|
1648
|
+
// atualiza o campo 'ordem' em cada item
|
|
1649
|
+
this.atualizarOrdem();
|
|
1650
|
+
}
|
|
1651
|
+
sortAndAssignOrder() {
|
|
1652
|
+
// 1. Crie uma cópia da lista para não modificar a original durante a iteração inicial
|
|
1653
|
+
const tempEmails = [...this.telefones];
|
|
1654
|
+
// 2. Mapeie as ordens existentes para identificar duplicatas e ausentes
|
|
1655
|
+
const orderMap = new Map();
|
|
1656
|
+
const emailsWithoutOrder = [];
|
|
1657
|
+
tempEmails.forEach(telefone => {
|
|
1658
|
+
if (telefone.ordem !== undefined && telefone.ordem !== null) {
|
|
1659
|
+
if (!orderMap.has(telefone.ordem)) {
|
|
1660
|
+
orderMap.set(telefone.ordem, []);
|
|
1661
|
+
}
|
|
1662
|
+
orderMap.get(telefone.ordem)?.push(telefone);
|
|
1663
|
+
}
|
|
1664
|
+
else {
|
|
1665
|
+
emailsWithoutOrder.push(telefone);
|
|
1666
|
+
}
|
|
1667
|
+
});
|
|
1668
|
+
// 3. Inicialize um Set para rastrear todas as ordens que serão usadas no final
|
|
1669
|
+
const finalUsedOrders = new Set();
|
|
1670
|
+
// Inicialize o próximo valor de ordem disponível
|
|
1671
|
+
let nextAvailableOrder = 0;
|
|
1672
|
+
// Função auxiliar para encontrar a próxima ordem disponível
|
|
1673
|
+
const getNextAvailableOrder = () => {
|
|
1674
|
+
while (finalUsedOrders.has(nextAvailableOrder)) {
|
|
1675
|
+
nextAvailableOrder++;
|
|
1676
|
+
}
|
|
1677
|
+
return nextAvailableOrder++;
|
|
1678
|
+
};
|
|
1679
|
+
// 4. Processe telefones com ordem definida:
|
|
1680
|
+
// - A primeira ocorrência de uma ordem a mantém.
|
|
1681
|
+
// - Duplicatas recebem uma nova ordem.
|
|
1682
|
+
// - Adicione as ordens válidas ao finalUsedOrders.
|
|
1683
|
+
this.telefones.forEach(telefone => {
|
|
1684
|
+
if (telefone.ordem !== undefined && telefone.ordem !== null) {
|
|
1685
|
+
if (!finalUsedOrders.has(telefone.ordem)) {
|
|
1686
|
+
// Se a ordem ainda não foi usada, use-a e adicione ao set
|
|
1687
|
+
finalUsedOrders.add(telefone.ordem);
|
|
1688
|
+
}
|
|
1689
|
+
else {
|
|
1690
|
+
// Se a ordem já foi usada (é uma duplicata), atribua uma nova
|
|
1691
|
+
telefone.ordem = getNextAvailableOrder();
|
|
1692
|
+
finalUsedOrders.add(telefone.ordem); // Adiciona a nova ordem ao set
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
});
|
|
1696
|
+
// 5. Atribua ordens para telefones que não tinham ordem definida
|
|
1697
|
+
emailsWithoutOrder.forEach(telefone => {
|
|
1698
|
+
telefone.ordem = getNextAvailableOrder();
|
|
1699
|
+
finalUsedOrders.add(telefone.ordem); // Adiciona a nova ordem ao set
|
|
1700
|
+
});
|
|
1701
|
+
// 6. Finalmente, ordene a lista completa com as ordens agora únicas
|
|
1702
|
+
this.telefones.sort((a, b) => (a.ordem ?? 0) - (b.ordem ?? 0));
|
|
1703
|
+
}
|
|
1704
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaTelefoneListComponent, deps: [{ token: i1$2.MatSnackBar }, { token: UnBPessoaService }, { token: i3$2.MatDialog }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1705
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: UnbPessoaTelefoneListComponent, selector: "lib-unb-pessoa-telefone-list", inputs: { podeEditar: "podeEditar", telefones: "telefones", apiPessoaConfig: "apiPessoaConfig" }, outputs: { telefonesEmitted: "telefonesEmitted" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"mes-container\">\r\n <div class=\"header-container\">\r\n <div class=\"mes-header\">\r\n <span class=\"titulo\">\r\n {{ telefones?.length === 1 ? 'Telefone Cadastrado' : 'Telefones Cadastrados' }}\r\n </span>\r\n <span class=\"titulo\">({{ telefones?.length || 0 }})</span>\r\n </div>\r\n\r\n <button type=\"button\" matTooltip=\"Novo Telefone\" mat-flat-button color=\"primary\" (click)=\"openFormDialog(null)\">\r\n Cadastrar Novo Telefone\r\n </button>\r\n </div>\r\n\r\n\r\n <!-- Exibe a tabela de despesas somente se houver despesas -->\r\n <table class=\"my-table\" *ngIf=\"telefones && telefones.length > 0\" cdkDropList (cdkDropListDropped)=\"moverTelefone($event)\">\r\n <tr style=\"background-color: #e4e3e3cc;\">\r\n <th style=\"width: 5%; text-align: center;\">Ordem</th>\r\n <th style=\"width: 20%;\">DDD</th>\r\n <th>N\u00FAmero</th> \r\n <th>Tipo</th>\r\n <th style=\"width: 1%; text-align: center;\">A\u00E7\u00F5es</th>\r\n </tr>\r\n\r\n <tr *ngFor=\"let valor of telefones; let i = index\" class=\"my-tr\" cdkDrag>\r\n <td style=\"text-align: center;\"> \r\n <div class=\"drag-cell\" cdkDragHandle>\r\n <mat-icon>drag_indicator</mat-icon>\r\n <span>{{ i + 1 }}</span>\r\n </div>\r\n </td>\r\n <td>{{ valor.ddd }}</td> \r\n <td>{{ valor.numero }}</td> \r\n <td>{{ valor.tipo?.toUpperCase() }}</td>\r\n <td>\r\n <div class=\"actions-container\">\r\n <button type=\"button\" mat-icon-button color=\"primary\" (click)=\"editar(valor)\">\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button type=\"button\" mat-icon-button color=\"warn\" (click)=\"excluir(valor)\">\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n </div>\r\n </td>\r\n </tr>\r\n</table>\r\n</div>", styles: [".mes-container{padding:12px;margin-bottom:2px;border-radius:8px;box-shadow:0 2px 6px #0000001a;transition:background-color .3s ease,box-shadow .3s ease}.mes-container:nth-child(2n){background-color:#f9f9fc}.mes-container:nth-child(odd){background-color:#fff}.mes-container:hover{background-color:#f0f0f5;box-shadow:0 4px 8px #00000026}.header-container{display:flex;align-items:center;margin-bottom:2px}.header-container button{margin-left:auto}.mes-header{display:flex;align-items:center;gap:6px;font-size:1.2rem;font-weight:700;color:#333}.my-table{width:100%;border-collapse:collapse;border-radius:8px;overflow:hidden;box-shadow:0 4px 8px #0000001a;font-family:Arial,sans-serif}.my-table th,.my-table td{padding:5px;text-align:left;border-bottom:1px solid #ddd}.my-table th{background-color:#005dbb7b;color:#fff;font-weight:700}.my-table tr{transition:background-color .3s ease}.my-table tr:hover{background-color:#f1f1f1}.my-table td{background-color:#fff}.my-table td button{transition:transform .2s ease}.my-table td button:hover{transform:scale(1.1)}.my-table td:last-child{text-align:center}.order-input{width:40px;text-align:center;border:1px solid #ccc;border-radius:4px;padding:2px}.order-input:focus{border-color:#1976d2;outline:none}.drag-cell{display:inline-flex;align-items:center;justify-content:center;gap:4px;cursor:grab;-webkit-user-select:none;user-select:none}.drag-cell mat-icon{font-size:18px;line-height:1;vertical-align:middle}.cdk-drag-preview{background:#fff;border-radius:6px;box-shadow:0 4px 12px #0003;display:table;border-collapse:collapse}.cdk-drag-placeholder{opacity:0;display:table-row}.cdk-drag-animating{transition:transform .2s cubic-bezier(0,0,.2,1)}table[cdkDropList] tr{border-bottom:1px solid #e0e0e0}table[cdkDropList] td{padding:8px}.actions-container{display:flex;justify-content:flex-end;gap:4px}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i6.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i6.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: i6.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { kind: "component", type: i7.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: i7.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }] }); }
|
|
1706
|
+
}
|
|
1707
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaTelefoneListComponent, decorators: [{
|
|
1708
|
+
type: Component,
|
|
1709
|
+
args: [{ standalone: false, selector: 'lib-unb-pessoa-telefone-list', template: "<div class=\"mes-container\">\r\n <div class=\"header-container\">\r\n <div class=\"mes-header\">\r\n <span class=\"titulo\">\r\n {{ telefones?.length === 1 ? 'Telefone Cadastrado' : 'Telefones Cadastrados' }}\r\n </span>\r\n <span class=\"titulo\">({{ telefones?.length || 0 }})</span>\r\n </div>\r\n\r\n <button type=\"button\" matTooltip=\"Novo Telefone\" mat-flat-button color=\"primary\" (click)=\"openFormDialog(null)\">\r\n Cadastrar Novo Telefone\r\n </button>\r\n </div>\r\n\r\n\r\n <!-- Exibe a tabela de despesas somente se houver despesas -->\r\n <table class=\"my-table\" *ngIf=\"telefones && telefones.length > 0\" cdkDropList (cdkDropListDropped)=\"moverTelefone($event)\">\r\n <tr style=\"background-color: #e4e3e3cc;\">\r\n <th style=\"width: 5%; text-align: center;\">Ordem</th>\r\n <th style=\"width: 20%;\">DDD</th>\r\n <th>N\u00FAmero</th> \r\n <th>Tipo</th>\r\n <th style=\"width: 1%; text-align: center;\">A\u00E7\u00F5es</th>\r\n </tr>\r\n\r\n <tr *ngFor=\"let valor of telefones; let i = index\" class=\"my-tr\" cdkDrag>\r\n <td style=\"text-align: center;\"> \r\n <div class=\"drag-cell\" cdkDragHandle>\r\n <mat-icon>drag_indicator</mat-icon>\r\n <span>{{ i + 1 }}</span>\r\n </div>\r\n </td>\r\n <td>{{ valor.ddd }}</td> \r\n <td>{{ valor.numero }}</td> \r\n <td>{{ valor.tipo?.toUpperCase() }}</td>\r\n <td>\r\n <div class=\"actions-container\">\r\n <button type=\"button\" mat-icon-button color=\"primary\" (click)=\"editar(valor)\">\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button type=\"button\" mat-icon-button color=\"warn\" (click)=\"excluir(valor)\">\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n </div>\r\n </td>\r\n </tr>\r\n</table>\r\n</div>", styles: [".mes-container{padding:12px;margin-bottom:2px;border-radius:8px;box-shadow:0 2px 6px #0000001a;transition:background-color .3s ease,box-shadow .3s ease}.mes-container:nth-child(2n){background-color:#f9f9fc}.mes-container:nth-child(odd){background-color:#fff}.mes-container:hover{background-color:#f0f0f5;box-shadow:0 4px 8px #00000026}.header-container{display:flex;align-items:center;margin-bottom:2px}.header-container button{margin-left:auto}.mes-header{display:flex;align-items:center;gap:6px;font-size:1.2rem;font-weight:700;color:#333}.my-table{width:100%;border-collapse:collapse;border-radius:8px;overflow:hidden;box-shadow:0 4px 8px #0000001a;font-family:Arial,sans-serif}.my-table th,.my-table td{padding:5px;text-align:left;border-bottom:1px solid #ddd}.my-table th{background-color:#005dbb7b;color:#fff;font-weight:700}.my-table tr{transition:background-color .3s ease}.my-table tr:hover{background-color:#f1f1f1}.my-table td{background-color:#fff}.my-table td button{transition:transform .2s ease}.my-table td button:hover{transform:scale(1.1)}.my-table td:last-child{text-align:center}.order-input{width:40px;text-align:center;border:1px solid #ccc;border-radius:4px;padding:2px}.order-input:focus{border-color:#1976d2;outline:none}.drag-cell{display:inline-flex;align-items:center;justify-content:center;gap:4px;cursor:grab;-webkit-user-select:none;user-select:none}.drag-cell mat-icon{font-size:18px;line-height:1;vertical-align:middle}.cdk-drag-preview{background:#fff;border-radius:6px;box-shadow:0 4px 12px #0003;display:table;border-collapse:collapse}.cdk-drag-placeholder{opacity:0;display:table-row}.cdk-drag-animating{transition:transform .2s cubic-bezier(0,0,.2,1)}table[cdkDropList] tr{border-bottom:1px solid #e0e0e0}table[cdkDropList] td{padding:8px}.actions-container{display:flex;justify-content:flex-end;gap:4px}\n"] }]
|
|
1710
|
+
}], ctorParameters: () => [{ type: i1$2.MatSnackBar }, { type: UnBPessoaService }, { type: i3$2.MatDialog }], propDecorators: { podeEditar: [{
|
|
1711
|
+
type: Input
|
|
1712
|
+
}], telefones: [{
|
|
1713
|
+
type: Input
|
|
1714
|
+
}], apiPessoaConfig: [{
|
|
1715
|
+
type: Input
|
|
1716
|
+
}], telefonesEmitted: [{
|
|
1717
|
+
type: Output
|
|
1718
|
+
}] } });
|
|
1719
|
+
|
|
1720
|
+
class UnbPessoaenderecoListComponent {
|
|
1721
|
+
constructor(snackBar, service, dialog) {
|
|
1722
|
+
this.snackBar = snackBar;
|
|
1723
|
+
this.service = service;
|
|
1724
|
+
this.dialog = dialog;
|
|
1725
|
+
this.podeEditar = true;
|
|
1726
|
+
this.enderecos = [];
|
|
1727
|
+
this.apiPessoaConfig = { url: '', token: '' };
|
|
1728
|
+
this.enderecosEmitted = new EventEmitter();
|
|
1729
|
+
}
|
|
1730
|
+
ngOnInit() {
|
|
1731
|
+
this.sortAndAssignOrder(); // organiza a lista de enderecos. As vezes tem ordem duplicada ou faltando.
|
|
1732
|
+
}
|
|
1733
|
+
// tem que fazer isso pq no on init eu ainda nao tenho a lista
|
|
1734
|
+
ngOnChanges(changes) {
|
|
1735
|
+
// Verifica se a propriedade 'enderecos' mudou
|
|
1736
|
+
if (changes['enderecos'] && this.enderecos) {
|
|
1737
|
+
// chamada quando os dados realmente chegarem
|
|
1738
|
+
this.sortAndAssignOrder();
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
excluir(enderecoParaExcluir) {
|
|
1742
|
+
if (enderecoParaExcluir.codigo) {
|
|
1743
|
+
// Se tem código, remove por ele (mais seguro)
|
|
1744
|
+
this.enderecos = this.enderecos.filter(t => t.codigo !== enderecoParaExcluir.codigo);
|
|
1745
|
+
}
|
|
1746
|
+
else {
|
|
1747
|
+
// Se não tem código (novo item), remove pela ordem
|
|
1748
|
+
this.enderecos = this.enderecos.filter(t => t.ordemEndereco !== enderecoParaExcluir.ordemEndereco);
|
|
1749
|
+
}
|
|
1750
|
+
// Chama função existente que re-calcula as ordens e emite a lista atualizada
|
|
1751
|
+
this.atualizarOrdem();
|
|
1752
|
+
}
|
|
1753
|
+
editar(endereco) {
|
|
1754
|
+
this.openFormDialog(endereco);
|
|
1755
|
+
}
|
|
1756
|
+
atualizarOrdem() {
|
|
1757
|
+
this.enderecos.forEach((endereco, idx) => {
|
|
1758
|
+
endereco.ordemEndereco = idx + 1;
|
|
1759
|
+
});
|
|
1760
|
+
this.enderecosEmitted.emit(this.enderecos);
|
|
1761
|
+
}
|
|
1762
|
+
openFormDialog(enderecoToEdit) {
|
|
1763
|
+
const dialogRef = this.dialog.open(UnbPessoaEnderecoFormComponent, {
|
|
1764
|
+
width: '900px',
|
|
1765
|
+
data: {
|
|
1766
|
+
endereco: enderecoToEdit, // E-mail a ser editado ou vazio para novo
|
|
1767
|
+
enderecosList: this.enderecos // A sua lista COMPLETA de e-mails
|
|
1768
|
+
},
|
|
1769
|
+
});
|
|
1770
|
+
dialogRef.afterClosed().subscribe(result => {
|
|
1771
|
+
if (!result) {
|
|
1772
|
+
return; // Usuário clicou em 'Fechar' ou 'Cancelar'
|
|
1773
|
+
}
|
|
1774
|
+
let index = -1;
|
|
1775
|
+
// 1. Tenta encontrar pelo 'codigo' (para itens que já vieram do banco)
|
|
1776
|
+
if (result.codigo) {
|
|
1777
|
+
index = this.enderecos.findIndex(t => t.codigo === result.codigo);
|
|
1778
|
+
}
|
|
1779
|
+
// 2. Se não achou pelo 'codigo', tenta pela 'ordem'.
|
|
1780
|
+
if (index === -1 && result.ordemEndereco) {
|
|
1781
|
+
index = this.enderecos.findIndex(t => t.ordemEndereco === result.ordemEndereco);
|
|
1782
|
+
}
|
|
1783
|
+
if (index > -1) {
|
|
1784
|
+
// ENCONTROU (pelo 'codigo' ou pela 'ordem'): Atualiza o item existente
|
|
1785
|
+
this.enderecos[index] = result;
|
|
1786
|
+
}
|
|
1787
|
+
else {
|
|
1788
|
+
// NÃO ENCONTROU: É um item 100% novo (não uma edição) adiciona no fim
|
|
1789
|
+
this.enderecos.push(result);
|
|
1790
|
+
}
|
|
1791
|
+
this.enderecos.sort((a, b) => (a.ordemEndereco ?? 0) - (b.ordemEndereco ?? 0)); //
|
|
1792
|
+
this.enderecosEmitted.emit([...this.enderecos]);
|
|
1793
|
+
});
|
|
1794
|
+
}
|
|
1795
|
+
moverLinha(event) {
|
|
1796
|
+
moveItemInArray(this.enderecos, event.previousIndex, event.currentIndex);
|
|
1797
|
+
this.atualizarOrdem();
|
|
1798
|
+
}
|
|
1799
|
+
sortAndAssignOrder() {
|
|
1800
|
+
// 1. Crie uma cópia da lista
|
|
1801
|
+
const tempenderecos = [...this.enderecos];
|
|
1802
|
+
// 2. Mapeie as ordens existentes
|
|
1803
|
+
const orderMap = new Map();
|
|
1804
|
+
const enderecosWithoutOrder = [];
|
|
1805
|
+
tempenderecos.forEach(endereco => {
|
|
1806
|
+
// CORREÇÃO AQUI:
|
|
1807
|
+
if (endereco.ordemEndereco !== undefined && endereco.ordemEndereco !== null) {
|
|
1808
|
+
if (!orderMap.has(endereco.ordemEndereco)) {
|
|
1809
|
+
orderMap.set(endereco.ordemEndereco, []);
|
|
1810
|
+
}
|
|
1811
|
+
orderMap.get(endereco.ordemEndereco)?.push(endereco);
|
|
1812
|
+
}
|
|
1813
|
+
else {
|
|
1814
|
+
enderecosWithoutOrder.push(endereco);
|
|
1815
|
+
}
|
|
1816
|
+
});
|
|
1817
|
+
// 3. ... (Funções 'finalUsedOrders', 'nextAvailableOrder' continuam iguais) ...
|
|
1818
|
+
const finalUsedOrders = new Set();
|
|
1819
|
+
let nextAvailableOrder = 0;
|
|
1820
|
+
const getNextAvailableOrder = () => {
|
|
1821
|
+
while (finalUsedOrders.has(nextAvailableOrder)) {
|
|
1822
|
+
nextAvailableOrder++;
|
|
1823
|
+
}
|
|
1824
|
+
return nextAvailableOrder++;
|
|
1825
|
+
};
|
|
1826
|
+
// 4. Processe enderecos com ordem definida:
|
|
1827
|
+
this.enderecos.forEach(endereco => {
|
|
1828
|
+
// CORREÇÃO AQUI:
|
|
1829
|
+
if (endereco.ordemEndereco !== undefined && endereco.ordemEndereco !== null) {
|
|
1830
|
+
if (!finalUsedOrders.has(endereco.ordemEndereco)) {
|
|
1831
|
+
finalUsedOrders.add(endereco.ordemEndereco);
|
|
1832
|
+
}
|
|
1833
|
+
else {
|
|
1834
|
+
// Duplicata, atribua uma nova
|
|
1835
|
+
endereco.ordemEndereco = getNextAvailableOrder();
|
|
1836
|
+
finalUsedOrders.add(endereco.ordemEndereco);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
});
|
|
1840
|
+
// 5. Atribua ordens para enderecos que não tinham ordem
|
|
1841
|
+
enderecosWithoutOrder.forEach(endereco => {
|
|
1842
|
+
endereco.ordemEndereco = getNextAvailableOrder(); //
|
|
1843
|
+
finalUsedOrders.add(endereco.ordemEndereco); //
|
|
1844
|
+
});
|
|
1845
|
+
// 6. Finalmente, ordene a lista
|
|
1846
|
+
this.enderecos.sort((a, b) => (a.ordemEndereco ?? 0) - (b.ordemEndereco ?? 0)); //
|
|
1847
|
+
}
|
|
1848
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaenderecoListComponent, deps: [{ token: i1$2.MatSnackBar }, { token: UnBPessoaService }, { token: i3$2.MatDialog }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1849
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: UnbPessoaenderecoListComponent, selector: "lib-unb-pessoa-endereco-list", inputs: { podeEditar: "podeEditar", enderecos: "enderecos", apiPessoaConfig: "apiPessoaConfig" }, outputs: { enderecosEmitted: "enderecosEmitted" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"mes-container\">\r\n <div class=\"header-container\">\r\n <div class=\"mes-header\">\r\n <span class=\"titulo\">\r\n {{ enderecos?.length === 1 ? 'Endere\u00E7o Cadastrado' : 'Endere\u00E7os Cadastrados' }}\r\n </span>\r\n <span class=\"titulo\">({{ enderecos?.length || 0 }})</span>\r\n </div>\r\n\r\n <button type=\"button\" matTooltip=\"Novo Endere\u00E7o\" mat-flat-button color=\"primary\" (click)=\"openFormDialog(null)\">\r\n Cadastrar Novo Endere\u00E7o\r\n </button>\r\n </div>\r\n\r\n <!-- Exibe a tabela de despesas somente se houver despesas -->\r\n <table class=\"my-table\" *ngIf=\"enderecos && enderecos.length > 0\" cdkDropList\r\n (cdkDropListDropped)=\"moverLinha($event)\">\r\n <tr style=\"background-color: #e4e3e3cc;\">\r\n <th style=\"width: 5%; text-align: center;\">Ordem</th>\r\n <th>Logradouro</th>\r\n <th>Bairro</th>\r\n <th>CEP</th>\r\n <th>Tipo</th>\r\n <th style=\"width: 1%; text-align: center;\">A\u00E7\u00F5es</th>\r\n </tr>\r\n\r\n <tr *ngFor=\"let valor of enderecos; let i = index\" class=\"my-tr\" cdkDrag>\r\n <td style=\"width: 5%; text-align: center;\">\r\n <div class=\"drag-cell\" cdkDragHandle>\r\n <mat-icon>drag_indicator</mat-icon>\r\n <span>{{ i + 1 }}</span>\r\n </div>\r\n </td>\r\n <td>{{ valor.logradouro }}</td>\r\n <td>{{ valor.bairro }}</td>\r\n <td>{{ valor.cep }}</td>\r\n <td>{{ valor.tipo?.toUpperCase() }}</td>\r\n <td>\r\n <div class=\"actions-container\">\r\n <button type=\"button\" mat-icon-button aria-label=\"Salvar\" color=\"primary\" (click)=\"editar(valor)\">\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button type=\"button\" mat-icon-button aria-label=\"Deletar\" color=\"warn\" (click)=\"excluir(valor)\">\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n </div>\r\n </td>\r\n </tr>\r\n </table>\r\n</div>", styles: [".mes-container{padding:12px;margin-bottom:2px;border-radius:8px;box-shadow:0 2px 6px #0000001a;transition:background-color .3s ease,box-shadow .3s ease}.mes-container:nth-child(2n){background-color:#f9f9fc}.mes-container:nth-child(odd){background-color:#fff}.mes-container:hover{background-color:#f0f0f5;box-shadow:0 4px 8px #00000026}.header-container{display:flex;align-items:center;margin-bottom:2px}.header-container button{margin-left:auto}.mes-header{display:flex;align-items:center;gap:6px;font-size:1.2rem;font-weight:700;color:#333}.actions-container{display:flex;justify-content:flex-end;gap:4px}.my-table{width:100%;border-collapse:collapse;border-radius:8px;overflow:hidden;box-shadow:0 4px 8px #0000001a;font-family:Arial,sans-serif}.my-table th,.my-table td{padding:5px;text-align:left;border-bottom:1px solid #ddd}.my-table th{background-color:#005dbb7b;color:#fff;font-weight:700}.my-table tr{transition:background-color .3s ease}.my-table tr:hover{background-color:#f1f1f1}.my-table td{background-color:#fff}.my-table td button{transition:transform .2s ease}.my-table td button:hover{transform:scale(1.1)}.my-table td:last-child{text-align:center}.order-input{width:40px;text-align:center;border:1px solid #ccc;border-radius:4px;padding:2px}.order-input:focus{border-color:#1976d2;outline:none}.drag-cell{display:inline-flex;align-items:center;justify-content:center;gap:4px;cursor:grab;-webkit-user-select:none;user-select:none}.drag-cell mat-icon{font-size:18px;line-height:1;vertical-align:middle}.cdk-drag-preview{background:#fff;border-radius:6px;box-shadow:0 4px 12px #0003;display:table;border-collapse:collapse}.cdk-drag-placeholder{opacity:0;display:table-row}.cdk-drag-animating{transition:transform .2s cubic-bezier(0,0,.2,1)}table[cdkDropList] tr{border-bottom:1px solid #e0e0e0}table[cdkDropList] td{padding:8px}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i6.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i6.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: i6.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { kind: "component", type: i7.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: i7.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }] }); }
|
|
1850
|
+
}
|
|
1851
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaenderecoListComponent, decorators: [{
|
|
1852
|
+
type: Component,
|
|
1853
|
+
args: [{ standalone: false, selector: 'lib-unb-pessoa-endereco-list', template: "<div class=\"mes-container\">\r\n <div class=\"header-container\">\r\n <div class=\"mes-header\">\r\n <span class=\"titulo\">\r\n {{ enderecos?.length === 1 ? 'Endere\u00E7o Cadastrado' : 'Endere\u00E7os Cadastrados' }}\r\n </span>\r\n <span class=\"titulo\">({{ enderecos?.length || 0 }})</span>\r\n </div>\r\n\r\n <button type=\"button\" matTooltip=\"Novo Endere\u00E7o\" mat-flat-button color=\"primary\" (click)=\"openFormDialog(null)\">\r\n Cadastrar Novo Endere\u00E7o\r\n </button>\r\n </div>\r\n\r\n <!-- Exibe a tabela de despesas somente se houver despesas -->\r\n <table class=\"my-table\" *ngIf=\"enderecos && enderecos.length > 0\" cdkDropList\r\n (cdkDropListDropped)=\"moverLinha($event)\">\r\n <tr style=\"background-color: #e4e3e3cc;\">\r\n <th style=\"width: 5%; text-align: center;\">Ordem</th>\r\n <th>Logradouro</th>\r\n <th>Bairro</th>\r\n <th>CEP</th>\r\n <th>Tipo</th>\r\n <th style=\"width: 1%; text-align: center;\">A\u00E7\u00F5es</th>\r\n </tr>\r\n\r\n <tr *ngFor=\"let valor of enderecos; let i = index\" class=\"my-tr\" cdkDrag>\r\n <td style=\"width: 5%; text-align: center;\">\r\n <div class=\"drag-cell\" cdkDragHandle>\r\n <mat-icon>drag_indicator</mat-icon>\r\n <span>{{ i + 1 }}</span>\r\n </div>\r\n </td>\r\n <td>{{ valor.logradouro }}</td>\r\n <td>{{ valor.bairro }}</td>\r\n <td>{{ valor.cep }}</td>\r\n <td>{{ valor.tipo?.toUpperCase() }}</td>\r\n <td>\r\n <div class=\"actions-container\">\r\n <button type=\"button\" mat-icon-button aria-label=\"Salvar\" color=\"primary\" (click)=\"editar(valor)\">\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button type=\"button\" mat-icon-button aria-label=\"Deletar\" color=\"warn\" (click)=\"excluir(valor)\">\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n </div>\r\n </td>\r\n </tr>\r\n </table>\r\n</div>", styles: [".mes-container{padding:12px;margin-bottom:2px;border-radius:8px;box-shadow:0 2px 6px #0000001a;transition:background-color .3s ease,box-shadow .3s ease}.mes-container:nth-child(2n){background-color:#f9f9fc}.mes-container:nth-child(odd){background-color:#fff}.mes-container:hover{background-color:#f0f0f5;box-shadow:0 4px 8px #00000026}.header-container{display:flex;align-items:center;margin-bottom:2px}.header-container button{margin-left:auto}.mes-header{display:flex;align-items:center;gap:6px;font-size:1.2rem;font-weight:700;color:#333}.actions-container{display:flex;justify-content:flex-end;gap:4px}.my-table{width:100%;border-collapse:collapse;border-radius:8px;overflow:hidden;box-shadow:0 4px 8px #0000001a;font-family:Arial,sans-serif}.my-table th,.my-table td{padding:5px;text-align:left;border-bottom:1px solid #ddd}.my-table th{background-color:#005dbb7b;color:#fff;font-weight:700}.my-table tr{transition:background-color .3s ease}.my-table tr:hover{background-color:#f1f1f1}.my-table td{background-color:#fff}.my-table td button{transition:transform .2s ease}.my-table td button:hover{transform:scale(1.1)}.my-table td:last-child{text-align:center}.order-input{width:40px;text-align:center;border:1px solid #ccc;border-radius:4px;padding:2px}.order-input:focus{border-color:#1976d2;outline:none}.drag-cell{display:inline-flex;align-items:center;justify-content:center;gap:4px;cursor:grab;-webkit-user-select:none;user-select:none}.drag-cell mat-icon{font-size:18px;line-height:1;vertical-align:middle}.cdk-drag-preview{background:#fff;border-radius:6px;box-shadow:0 4px 12px #0003;display:table;border-collapse:collapse}.cdk-drag-placeholder{opacity:0;display:table-row}.cdk-drag-animating{transition:transform .2s cubic-bezier(0,0,.2,1)}table[cdkDropList] tr{border-bottom:1px solid #e0e0e0}table[cdkDropList] td{padding:8px}\n"] }]
|
|
1854
|
+
}], ctorParameters: () => [{ type: i1$2.MatSnackBar }, { type: UnBPessoaService }, { type: i3$2.MatDialog }], propDecorators: { podeEditar: [{
|
|
1855
|
+
type: Input
|
|
1856
|
+
}], enderecos: [{
|
|
1857
|
+
type: Input
|
|
1858
|
+
}], apiPessoaConfig: [{
|
|
1859
|
+
type: Input
|
|
1860
|
+
}], enderecosEmitted: [{
|
|
1861
|
+
type: Output
|
|
1862
|
+
}] } });
|
|
1863
|
+
|
|
1864
|
+
class UnbPessoaEmailListComponent {
|
|
1865
|
+
constructor(snackBar, service, dialog) {
|
|
1866
|
+
this.snackBar = snackBar;
|
|
1867
|
+
this.service = service;
|
|
1868
|
+
this.dialog = dialog;
|
|
1869
|
+
this.podeEditar = true;
|
|
1870
|
+
this.emails = [];
|
|
1871
|
+
this.apiPessoaConfig = { url: '', token: '' };
|
|
1872
|
+
this.emailsEmitted = new EventEmitter();
|
|
1873
|
+
}
|
|
1874
|
+
ngOnInit() {
|
|
1875
|
+
this.tipoEmail = this.service.getTipoEmail();
|
|
1876
|
+
this.sortAndAssignOrder(); // organiza a lista de emails. As vezes tem ordem duplicada ou faltando.
|
|
1877
|
+
}
|
|
1878
|
+
// tem que fazer isso pq no on init eu ainda nao tenho a lista
|
|
1879
|
+
ngOnChanges(changes) {
|
|
1880
|
+
// Verifica se a propriedade 'emails' mudou
|
|
1881
|
+
if (changes['emails'] && this.emails) {
|
|
1882
|
+
// chamada quando os dados realmente chegarem
|
|
1883
|
+
this.sortAndAssignOrder();
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
excluir(emailParaExcluir) {
|
|
1887
|
+
if (emailParaExcluir.codigo) {
|
|
1888
|
+
// Se tem código, remove por ele
|
|
1889
|
+
this.emails = this.emails.filter(e => e.codigo !== emailParaExcluir.codigo);
|
|
1890
|
+
}
|
|
1891
|
+
else {
|
|
1892
|
+
// Se não tem código (novo item), remove pela ordem
|
|
1893
|
+
this.emails = this.emails.filter(e => e.ordem !== emailParaExcluir.ordem);
|
|
1894
|
+
}
|
|
1895
|
+
// Chama sua função existente que re-calcula as ordens e emite a lista
|
|
1896
|
+
this.atualizarOrdem();
|
|
1897
|
+
}
|
|
1898
|
+
editar(email) {
|
|
1899
|
+
this.openFormDialog(email);
|
|
1900
|
+
}
|
|
1901
|
+
atualizarOrdem() {
|
|
1902
|
+
this.emails.forEach((email, idx) => {
|
|
1903
|
+
email.ordem = idx + 1;
|
|
1904
|
+
});
|
|
1905
|
+
this.emailsEmitted.emit([...this.emails]);
|
|
1906
|
+
}
|
|
1907
|
+
openFormDialog(emailToEdit) {
|
|
1908
|
+
const dialogRef = this.dialog.open(UnbPessoaEmailFormComponent, {
|
|
1909
|
+
width: '900px',
|
|
1910
|
+
data: {
|
|
1911
|
+
email: emailToEdit, // E-mail a ser editado ou vazio para novo
|
|
1912
|
+
emailsList: this.emails // A sua lista COMPLETA de e-mails
|
|
1913
|
+
},
|
|
1914
|
+
});
|
|
1915
|
+
dialogRef.afterClosed().subscribe(result => {
|
|
1916
|
+
if (!result) {
|
|
1917
|
+
return; // Usuário clicou em 'Fechar' ou 'Cancelar'
|
|
1918
|
+
}
|
|
1919
|
+
// 'result' é o objeto retornado pelo dialog (editado ou novo)
|
|
1920
|
+
let index = -1;
|
|
1921
|
+
// 1. Tenta encontrar pelo 'codigo' (para itens que já vieram do banco)
|
|
1922
|
+
if (result.codigo) {
|
|
1923
|
+
index = this.emails.findIndex(e => e.codigo === result.codigo);
|
|
1924
|
+
}
|
|
1925
|
+
// 2. Se não achou pelo 'codigo', tenta pela 'ordem'.
|
|
1926
|
+
if (index === -1 && result.ordem) {
|
|
1927
|
+
index = this.emails.findIndex(e => e.ordem === result.ordem);
|
|
1928
|
+
}
|
|
1929
|
+
if (index > -1) {
|
|
1930
|
+
// ENCONTROU (pelo 'codigo' ou pela 'ordem'): Atualiza o item existente
|
|
1931
|
+
this.emails[index] = result;
|
|
1932
|
+
}
|
|
1933
|
+
else {
|
|
1934
|
+
// NÃO ENCONTROU: É um item 100% novo (não uma edição)
|
|
1935
|
+
this.emails.push(result);
|
|
1936
|
+
}
|
|
1937
|
+
// Re-ordena a lista pela 'ordem' e emite uma *nova cópia*
|
|
1938
|
+
this.emails.sort((a, b) => (a.ordem ?? 0) - (b.ordem ?? 0));
|
|
1939
|
+
this.emailsEmitted.emit([...this.emails]); // <-- Emite nova cópia
|
|
1940
|
+
});
|
|
1941
|
+
}
|
|
1942
|
+
moverLinha(event) {
|
|
1943
|
+
moveItemInArray(this.emails, event.previousIndex, event.currentIndex);
|
|
1944
|
+
this.atualizarOrdem();
|
|
1945
|
+
}
|
|
1946
|
+
sortAndAssignOrder() {
|
|
1947
|
+
// 1. Crie uma cópia da lista
|
|
1948
|
+
const tempEmails = [...this.emails]; // <-- NOME CORRIGIDO
|
|
1949
|
+
// 2. Mapeie as ordens existentes
|
|
1950
|
+
const orderMap = new Map();
|
|
1951
|
+
const emailsWithoutOrder = [];
|
|
1952
|
+
tempEmails.forEach(email => {
|
|
1953
|
+
// CORREÇÃO AQUI: 'ordem' em vez de 'ordemEmail'
|
|
1954
|
+
if (email.ordem !== undefined && email.ordem !== null) {
|
|
1955
|
+
if (!orderMap.has(email.ordem)) {
|
|
1956
|
+
orderMap.set(email.ordem, []);
|
|
1957
|
+
}
|
|
1958
|
+
orderMap.get(email.ordem)?.push(email);
|
|
1959
|
+
}
|
|
1960
|
+
else {
|
|
1961
|
+
emailsWithoutOrder.push(email);
|
|
1962
|
+
}
|
|
1963
|
+
});
|
|
1964
|
+
// 3. ... (Funções 'finalUsedOrders', 'nextAvailableOrder' continuam iguais) ...
|
|
1965
|
+
const finalUsedOrders = new Set();
|
|
1966
|
+
let nextAvailableOrder = 0;
|
|
1967
|
+
const getNextAvailableOrder = () => {
|
|
1968
|
+
while (finalUsedOrders.has(nextAvailableOrder)) {
|
|
1969
|
+
nextAvailableOrder++;
|
|
1970
|
+
}
|
|
1971
|
+
return nextAvailableOrder++;
|
|
1972
|
+
};
|
|
1973
|
+
// 4. Processe emails com ordem definida:
|
|
1974
|
+
this.emails.forEach(email => {
|
|
1975
|
+
// CORREÇÃO AQUI: 'ordem' em vez de 'ordemEmail'
|
|
1976
|
+
if (email.ordem !== undefined && email.ordem !== null) {
|
|
1977
|
+
if (!finalUsedOrders.has(email.ordem)) {
|
|
1978
|
+
finalUsedOrders.add(email.ordem);
|
|
1979
|
+
}
|
|
1980
|
+
else {
|
|
1981
|
+
// Duplicata, atribua uma nova
|
|
1982
|
+
email.ordem = getNextAvailableOrder();
|
|
1983
|
+
finalUsedOrders.add(email.ordem);
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
// 5. Atribua ordens para emails que não tinham ordem
|
|
1988
|
+
emailsWithoutOrder.forEach(email => {
|
|
1989
|
+
email.ordem = getNextAvailableOrder();
|
|
1990
|
+
finalUsedOrders.add(email.ordem);
|
|
1991
|
+
});
|
|
1992
|
+
// 6. Finalmente, ordene a lista
|
|
1993
|
+
this.emails.sort((a, b) => (a.ordem ?? 0) - (b.ordem ?? 0)); // <-- 'ordem'
|
|
1994
|
+
}
|
|
1995
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaEmailListComponent, deps: [{ token: i1$2.MatSnackBar }, { token: UnBPessoaService }, { token: i3$2.MatDialog }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1996
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: UnbPessoaEmailListComponent, selector: "lib-unb-pessoa-email-list", inputs: { podeEditar: "podeEditar", emails: "emails", apiPessoaConfig: "apiPessoaConfig" }, outputs: { emailsEmitted: "emailsEmitted" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"mes-container\">\r\n <div class=\"header-container\">\r\n <div class=\"mes-header\">\r\n <span class=\"titulo\">\r\n {{ emails?.length === 1 ? 'Email Cadastrado' : 'E-mails Cadastrados' }}\r\n </span>\r\n <span class=\"titulo\">({{ emails?.length || 0 }})</span>\r\n </div>\r\n\r\n <button type=\"button\" matTooltip=\"Novo Email\" mat-flat-button color=\"primary\" (click)=\"openFormDialog(null)\">\r\n Cadastrar Novo Email\r\n </button>\r\n </div>\r\n\r\n <!-- Exibe a tabela de despesas somente se houver despesas -->\r\n <table class=\"my-table\" *ngIf=\"emails && emails.length > 0\" cdkDropList (cdkDropListDropped)=\"moverLinha($event)\">\r\n\r\n <tr style=\"background-color: #e4e3e3cc;\">\r\n <th style=\"width: 5%; text-align: center;\">Ordem</th>\r\n <th>E-mail</th>\r\n <th>Tipo</th>\r\n <th style=\"width: 1%; text-align: center;\">A\u00E7\u00F5es</th>\r\n </tr>\r\n\r\n <tr *ngFor=\"let valor of emails; let i = index\" class=\"my-tr\" cdkDrag>\r\n\r\n <td style=\"text-align: center;\">\r\n <div class=\"drag-cell\" cdkDragHandle>\r\n <mat-icon>drag_indicator</mat-icon>\r\n <span>{{ i + 1 }}</span>\r\n </div>\r\n </td>\r\n\r\n <td>{{ valor.email }}</td>\r\n\r\n <td>{{ valor.tipo?.toUpperCase() }}</td>\r\n\r\n <td>\r\n <div class=\"actions-container\">\r\n <button type=\"button\" mat-icon-button aria-label=\"Salvar\" color=\"primary\" (click)=\"editar(valor)\">\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button type=\"button\" mat-icon-button aria-label=\"Deletar\" color=\"warn\" (click)=\"excluir(valor)\">\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n </div>\r\n </td>\r\n </tr>\r\n </table>\r\n</div>", styles: [".mes-container{padding:12px;margin-bottom:2px;border-radius:8px;box-shadow:0 2px 6px #0000001a;transition:background-color .3s ease,box-shadow .3s ease}.mes-container:nth-child(2n){background-color:#f9f9fc}.mes-container:nth-child(odd){background-color:#fff}.mes-container:hover{background-color:#f0f0f5;box-shadow:0 4px 8px #00000026}.header-container{display:flex;align-items:center;margin-bottom:2px}.header-container button{margin-left:auto}.mes-header{display:flex;align-items:center;gap:6px;font-size:1.2rem;font-weight:700;color:#333}.my-table{width:100%;border-collapse:collapse;border-radius:8px;overflow:hidden;box-shadow:0 4px 8px #0000001a;font-family:Arial,sans-serif}.my-table th,.my-table td{padding:5px;text-align:left;border-bottom:1px solid #ddd}.my-table th{background-color:#005dbb7b;color:#fff;font-weight:700}.my-table tr{transition:background-color .3s ease}.my-table tr:hover{background-color:#f1f1f1}.my-table td{background-color:#fff}.my-table td button{transition:transform .2s ease}.my-table td button:hover{transform:scale(1.1)}.my-table td:last-child{text-align:center}.order-input{width:40px;text-align:center;border:1px solid #ccc;border-radius:4px;padding:2px}.order-input:focus{border-color:#1976d2;outline:none}.drag-cell{display:inline-flex;align-items:center;justify-content:center;gap:4px;cursor:grab;-webkit-user-select:none;user-select:none}.drag-cell mat-icon{font-size:18px;line-height:1;vertical-align:middle}.cdk-drag-preview{background:#fff;border-radius:6px;box-shadow:0 4px 12px #0003;display:table;border-collapse:collapse}.cdk-drag-placeholder{opacity:0;display:table-row}.cdk-drag-animating{transition:transform .2s cubic-bezier(0,0,.2,1)}table[cdkDropList] tr{border-bottom:1px solid #e0e0e0}table[cdkDropList] td{padding:8px}.actions-container{display:flex;justify-content:flex-end;gap:4px}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i6.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i6.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: i6.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { kind: "component", type: i7.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: i7.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }] }); }
|
|
1997
|
+
}
|
|
1998
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaEmailListComponent, decorators: [{
|
|
1999
|
+
type: Component,
|
|
2000
|
+
args: [{ standalone: false, selector: 'lib-unb-pessoa-email-list', template: "<div class=\"mes-container\">\r\n <div class=\"header-container\">\r\n <div class=\"mes-header\">\r\n <span class=\"titulo\">\r\n {{ emails?.length === 1 ? 'Email Cadastrado' : 'E-mails Cadastrados' }}\r\n </span>\r\n <span class=\"titulo\">({{ emails?.length || 0 }})</span>\r\n </div>\r\n\r\n <button type=\"button\" matTooltip=\"Novo Email\" mat-flat-button color=\"primary\" (click)=\"openFormDialog(null)\">\r\n Cadastrar Novo Email\r\n </button>\r\n </div>\r\n\r\n <!-- Exibe a tabela de despesas somente se houver despesas -->\r\n <table class=\"my-table\" *ngIf=\"emails && emails.length > 0\" cdkDropList (cdkDropListDropped)=\"moverLinha($event)\">\r\n\r\n <tr style=\"background-color: #e4e3e3cc;\">\r\n <th style=\"width: 5%; text-align: center;\">Ordem</th>\r\n <th>E-mail</th>\r\n <th>Tipo</th>\r\n <th style=\"width: 1%; text-align: center;\">A\u00E7\u00F5es</th>\r\n </tr>\r\n\r\n <tr *ngFor=\"let valor of emails; let i = index\" class=\"my-tr\" cdkDrag>\r\n\r\n <td style=\"text-align: center;\">\r\n <div class=\"drag-cell\" cdkDragHandle>\r\n <mat-icon>drag_indicator</mat-icon>\r\n <span>{{ i + 1 }}</span>\r\n </div>\r\n </td>\r\n\r\n <td>{{ valor.email }}</td>\r\n\r\n <td>{{ valor.tipo?.toUpperCase() }}</td>\r\n\r\n <td>\r\n <div class=\"actions-container\">\r\n <button type=\"button\" mat-icon-button aria-label=\"Salvar\" color=\"primary\" (click)=\"editar(valor)\">\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button type=\"button\" mat-icon-button aria-label=\"Deletar\" color=\"warn\" (click)=\"excluir(valor)\">\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n </div>\r\n </td>\r\n </tr>\r\n </table>\r\n</div>", styles: [".mes-container{padding:12px;margin-bottom:2px;border-radius:8px;box-shadow:0 2px 6px #0000001a;transition:background-color .3s ease,box-shadow .3s ease}.mes-container:nth-child(2n){background-color:#f9f9fc}.mes-container:nth-child(odd){background-color:#fff}.mes-container:hover{background-color:#f0f0f5;box-shadow:0 4px 8px #00000026}.header-container{display:flex;align-items:center;margin-bottom:2px}.header-container button{margin-left:auto}.mes-header{display:flex;align-items:center;gap:6px;font-size:1.2rem;font-weight:700;color:#333}.my-table{width:100%;border-collapse:collapse;border-radius:8px;overflow:hidden;box-shadow:0 4px 8px #0000001a;font-family:Arial,sans-serif}.my-table th,.my-table td{padding:5px;text-align:left;border-bottom:1px solid #ddd}.my-table th{background-color:#005dbb7b;color:#fff;font-weight:700}.my-table tr{transition:background-color .3s ease}.my-table tr:hover{background-color:#f1f1f1}.my-table td{background-color:#fff}.my-table td button{transition:transform .2s ease}.my-table td button:hover{transform:scale(1.1)}.my-table td:last-child{text-align:center}.order-input{width:40px;text-align:center;border:1px solid #ccc;border-radius:4px;padding:2px}.order-input:focus{border-color:#1976d2;outline:none}.drag-cell{display:inline-flex;align-items:center;justify-content:center;gap:4px;cursor:grab;-webkit-user-select:none;user-select:none}.drag-cell mat-icon{font-size:18px;line-height:1;vertical-align:middle}.cdk-drag-preview{background:#fff;border-radius:6px;box-shadow:0 4px 12px #0003;display:table;border-collapse:collapse}.cdk-drag-placeholder{opacity:0;display:table-row}.cdk-drag-animating{transition:transform .2s cubic-bezier(0,0,.2,1)}table[cdkDropList] tr{border-bottom:1px solid #e0e0e0}table[cdkDropList] td{padding:8px}.actions-container{display:flex;justify-content:flex-end;gap:4px}\n"] }]
|
|
2001
|
+
}], ctorParameters: () => [{ type: i1$2.MatSnackBar }, { type: UnBPessoaService }, { type: i3$2.MatDialog }], propDecorators: { podeEditar: [{
|
|
2002
|
+
type: Input
|
|
2003
|
+
}], emails: [{
|
|
2004
|
+
type: Input
|
|
2005
|
+
}], apiPessoaConfig: [{
|
|
2006
|
+
type: Input
|
|
2007
|
+
}], emailsEmitted: [{
|
|
2008
|
+
type: Output
|
|
2009
|
+
}] } });
|
|
2010
|
+
|
|
2011
|
+
class UnbPessoaFormComponent {
|
|
2012
|
+
constructor(service, snackBar, alertService) {
|
|
2013
|
+
this.service = service;
|
|
2014
|
+
this.snackBar = snackBar;
|
|
2015
|
+
this.alertService = alertService;
|
|
2016
|
+
this.isLoading = false;
|
|
2017
|
+
this.buscaRealizada = false;
|
|
2018
|
+
this.endereco = new UnbPessoaEndereco();
|
|
2019
|
+
this.email = new UnbPessoaEmail();
|
|
2020
|
+
this.tiposPessoa = TipoPessoaEnum;
|
|
2021
|
+
this.pessoa = new UnbPessoaModel(); // inicializa com pessoa
|
|
2022
|
+
this.dadosSalvos = {}; // Armazena os dados ao trocar de tipo
|
|
2023
|
+
// Quando verdadeiro, o formulário e ações ficam desabilitados porque os dados
|
|
2024
|
+
// devem ser alterados apenas pelo app SouGov (matricula SIAPE presente)
|
|
2025
|
+
this.isReadonlyFromSiape = false;
|
|
2026
|
+
this.apiPessoaConfig = { url: '', token: '' };
|
|
2027
|
+
this.pesquisarPorCPF = true;
|
|
2028
|
+
this.pesquisarPorCNPJ = true;
|
|
2029
|
+
this.pesquisarPorEstrangeiro = true;
|
|
2030
|
+
this.campoPesquisaMaxWidth = '400px';
|
|
2031
|
+
}
|
|
2032
|
+
ngOnInit() {
|
|
2033
|
+
if (this.apiPessoaConfig.url.endsWith('/')) {
|
|
2034
|
+
this.apiPessoaConfig.url = this.apiPessoaConfig.url.slice(0, -1);
|
|
2035
|
+
}
|
|
2036
|
+
this.alertService.hideMessage();
|
|
2037
|
+
this.service.setApiConfig(this.apiPessoaConfig);
|
|
2038
|
+
// atencao, o pessoaRecebida que inicializa esse componente
|
|
2039
|
+
this.escolaridade = this.service.getEscolaridade();
|
|
2040
|
+
this.paises = this.service.getPaises();
|
|
2041
|
+
this.estadosCivil = this.service.getEstadoCivil();
|
|
2042
|
+
}
|
|
2043
|
+
pessoaRecebida(pessoaRecebida) {
|
|
2044
|
+
this.buscaRealizada = true;
|
|
2045
|
+
this.pessoa = pessoaRecebida;
|
|
2046
|
+
this.alertService.hideMessage();
|
|
2047
|
+
// inicializa pra nao quebrar
|
|
2048
|
+
if (!this.pessoa.enderecos)
|
|
2049
|
+
this.pessoa.enderecos = [];
|
|
2050
|
+
if (!this.pessoa.emails)
|
|
2051
|
+
this.pessoa.emails = [];
|
|
2052
|
+
if (!this.pessoa.telefones)
|
|
2053
|
+
this.pessoa.telefones = [];
|
|
2054
|
+
// Se a pessoa vier com matriculaSiape preenchido, colocamos o formulário em modo somente-leitura
|
|
2055
|
+
// e mostraremos uma mensagem informativa na UI. Também desabilita ações de salvar.
|
|
2056
|
+
if (this.pessoa && this.pessoa.matriculaSiape !== undefined && this.pessoa.matriculaSiape !== null && this.pessoa.matriculaSiape !== 0) {
|
|
2057
|
+
this.isReadonlyFromSiape = true;
|
|
2058
|
+
// opcional: informar via snackBar também
|
|
2059
|
+
this.openSnackBar('Servidor com matriculla SIAPE deve ter seus dados autalizados pelo aplicativo do sougov.');
|
|
2060
|
+
}
|
|
2061
|
+
else {
|
|
2062
|
+
this.isReadonlyFromSiape = false;
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
salvar(form) {
|
|
2066
|
+
this.alertService.hideMessage();
|
|
2067
|
+
if (!this.validar(form))
|
|
2068
|
+
return;
|
|
2069
|
+
if (!this.service)
|
|
2070
|
+
return;
|
|
2071
|
+
this.isLoading = true;
|
|
2072
|
+
const payload = this.convertPessoaToPayload(this.pessoa);
|
|
2073
|
+
let result = this.service.salvar(payload, this.pessoa.tipoPessoa);
|
|
2074
|
+
if (result && typeof result.subscribe === 'function') {
|
|
2075
|
+
// Use o formato 'next/error' para clareza
|
|
2076
|
+
result.subscribe({
|
|
2077
|
+
next: (resposta) => {
|
|
2078
|
+
this.isLoading = false;
|
|
2079
|
+
this.alertService.showMessage("<strong>Registro salvo com sucesso!</strong>", UnbTipoMensagemEnum.SUCCESS);
|
|
2080
|
+
if (resposta) {
|
|
2081
|
+
this.pessoa.codigoPessoa = resposta.codigoPessoa || this.pessoa.codigoPessoa;
|
|
2082
|
+
this.pessoa.idPessoa = resposta.idPessoa || this.pessoa.idPessoa;
|
|
2083
|
+
}
|
|
2084
|
+
},
|
|
2085
|
+
error: (err) => {
|
|
2086
|
+
this.erro(err);
|
|
2087
|
+
}
|
|
2088
|
+
});
|
|
2089
|
+
}
|
|
2090
|
+
else {
|
|
2091
|
+
console.error("Erro: O método salvar() não retornou um Observable.");
|
|
2092
|
+
this.isLoading = false; // Garante que o loading pare
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
validar(form) {
|
|
2096
|
+
if (!this.pessoa) {
|
|
2097
|
+
this.openSnackBar("Erro ao carregar objeto pessoa");
|
|
2098
|
+
return false;
|
|
2099
|
+
}
|
|
2100
|
+
if (form.invalid) {
|
|
2101
|
+
// para que os erros apareçam na tela para o usuário.
|
|
2102
|
+
form.control.markAllAsTouched();
|
|
2103
|
+
this.openSnackBar("Por favor, preencha os campos obrigatórios.");
|
|
2104
|
+
return false;
|
|
2105
|
+
}
|
|
2106
|
+
if (this.pessoa.telefones == null || (this.pessoa.telefones != null && this.pessoa.telefones.length == 0)) {
|
|
2107
|
+
this.openSnackBar("Cadastre pelo menos um telefone no botão Cadastrar Novo Telefone");
|
|
2108
|
+
return false;
|
|
2109
|
+
}
|
|
2110
|
+
if (this.pessoa.enderecos == null || (this.pessoa.enderecos != null && this.pessoa.enderecos.length == 0)) {
|
|
2111
|
+
this.openSnackBar("Cadastre pelo menos um endereço no botão Cadastrar Novo Endereço");
|
|
2112
|
+
return false;
|
|
2113
|
+
}
|
|
2114
|
+
if (this.pessoa.emails == null || (this.pessoa.emails != null && this.pessoa.emails.length == 0)) {
|
|
2115
|
+
this.openSnackBar("Cadastre pelo menos um e-mail no botão Cadastrar Novo Email");
|
|
2116
|
+
return false;
|
|
2117
|
+
}
|
|
2118
|
+
if (this.pessoa.tipoPessoa == TipoPessoaEnum.FISICA) {
|
|
2119
|
+
if (!this.pessoa.nome || (this.pessoa && this.pessoa.nome == "")) {
|
|
2120
|
+
this.openSnackBar("Nome é um campo obrigatório");
|
|
2121
|
+
return false;
|
|
2122
|
+
}
|
|
2123
|
+
if (!this.pessoa.dataNascimento) {
|
|
2124
|
+
this.openSnackBar("Data de Nascimento é um campo obrigatório");
|
|
2125
|
+
return false;
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
if (this.pessoa.tipoPessoa == TipoPessoaEnum.ESTRANGEIRA) {
|
|
2129
|
+
if (!this.pessoa.nome || (this.pessoa && this.pessoa.nome == "")) {
|
|
2130
|
+
this.openSnackBar("Nome é um campo obrigatório");
|
|
2131
|
+
return false;
|
|
2132
|
+
}
|
|
2133
|
+
if (this.pessoa.passaporte == null || (this.pessoa.passaporte != null && this.pessoa.passaporte == "")) {
|
|
2134
|
+
this.openSnackBar("Passaporte é um campo obrigatório");
|
|
2135
|
+
return false;
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
if (this.pessoa.tipoPessoa == TipoPessoaEnum.JURIDICA) {
|
|
2139
|
+
if (this.pessoa.cnpj == null || (this.pessoa.cnpj != null && this.pessoa.cnpj == "")) {
|
|
2140
|
+
this.openSnackBar("CNPJ é um campo obrigatório");
|
|
2141
|
+
return false;
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
return true;
|
|
2145
|
+
}
|
|
2146
|
+
telefonesEmitted(telefones) {
|
|
2147
|
+
this.pessoa.telefones = telefones;
|
|
2148
|
+
}
|
|
2149
|
+
enderecosEmitted(enderecos) {
|
|
2150
|
+
this.pessoa.enderecos = enderecos;
|
|
2151
|
+
}
|
|
2152
|
+
emailsEmitted(emails) {
|
|
2153
|
+
this.pessoa.emails = emails;
|
|
2154
|
+
}
|
|
2155
|
+
erro(erro) {
|
|
2156
|
+
this.isLoading = false;
|
|
2157
|
+
const errorResponse = erro.error;
|
|
2158
|
+
// 1. Tratamento para Erros de Validação (que contêm o array 'detalhes')
|
|
2159
|
+
if (errorResponse && errorResponse.detalhes && Array.isArray(errorResponse.detalhes) && errorResponse.detalhes.length > 0) {
|
|
2160
|
+
// Mensagem genérica para o SnackBar
|
|
2161
|
+
this.openSnackBar("O formulário possui erro(s). Por favor, verificar.");
|
|
2162
|
+
// Constrói a mensagem HTML detalhada para o AlertService
|
|
2163
|
+
const criticasHtml = errorResponse.detalhes.map((det) => {
|
|
2164
|
+
// Formata cada erro como um item de lista
|
|
2165
|
+
return `<li><strong>${det.nomeCampo}:</strong> ${det.critica}</li>`;
|
|
2166
|
+
}).join('');
|
|
2167
|
+
// Cria a mensagem final, envolvendo os erros em uma tag <ul>
|
|
2168
|
+
const detailedHtmlMessage = `<strong>Erros de Validação:</strong> <ul>${criticasHtml}</ul>`;
|
|
2169
|
+
// Mostra os detalhes formatados no AlertService
|
|
2170
|
+
this.alertService.showMessage(detailedHtmlMessage, UnbTipoMensagemEnum.DANGER);
|
|
2171
|
+
}
|
|
2172
|
+
// 2. Tratamento para Outros Tipos de Erro (sem o array 'detalhes')
|
|
2173
|
+
else {
|
|
2174
|
+
let errorMessage = 'Ocorreu um erro desconhecido.'; // Mensagem padrão
|
|
2175
|
+
// Tenta extrair a mensagem de erro específica
|
|
2176
|
+
if (errorResponse) {
|
|
2177
|
+
if (errorResponse.mensagem) {
|
|
2178
|
+
errorMessage = errorResponse.mensagem;
|
|
2179
|
+
}
|
|
2180
|
+
else if (errorResponse.detail) {
|
|
2181
|
+
errorMessage = errorResponse.detail;
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
else if (erro.message) {
|
|
2185
|
+
errorMessage = erro.message;
|
|
2186
|
+
}
|
|
2187
|
+
// Mostra uma mensagem genérica no SnackBar
|
|
2188
|
+
this.openSnackBar('Ocorreu um erro ao processar sua solicitação.');
|
|
2189
|
+
// Mostra o erro específico no AlertService, como você sugeriu
|
|
2190
|
+
let erroStrong = "<strong>" + errorMessage + "</strong>";
|
|
2191
|
+
this.alertService.showMessage(erroStrong, UnbTipoMensagemEnum.DANGER);
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
openSnackBar(message) {
|
|
2195
|
+
this.snackBar.open(message, 'x', {
|
|
2196
|
+
duration: 5000,
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
tipoPessoaEnum() {
|
|
2200
|
+
return TipoPessoaEnum;
|
|
2201
|
+
}
|
|
2202
|
+
getListaEstados() {
|
|
2203
|
+
return listaEstados;
|
|
2204
|
+
}
|
|
2205
|
+
/**
|
|
2206
|
+
* Converte uma instância (ou objeto) de UnbPessoaModel para o payload esperado pelo backend.
|
|
2207
|
+
*/
|
|
2208
|
+
convertPessoaToPayload(pessoa) {
|
|
2209
|
+
if (!pessoa)
|
|
2210
|
+
return null;
|
|
2211
|
+
// --- Mapeia os arrays ---
|
|
2212
|
+
const enderecosPayload = (pessoa.enderecos || []).map((end) => ({
|
|
2213
|
+
ordemEndereco: end.ordemEndereco,
|
|
2214
|
+
tipoEnderecoCodigo: end.tipoEnderecoCodigo,
|
|
2215
|
+
municipioCodigo: end.municipioCodigo,
|
|
2216
|
+
paisEnderecoCodigo: end.paisEnderecoCodigo,
|
|
2217
|
+
logradouro: end.logradouro,
|
|
2218
|
+
complemento: end.complemento,
|
|
2219
|
+
cep: end.cep,
|
|
2220
|
+
bairro: end.bairro,
|
|
2221
|
+
ufEndereco: end.ufEndereco,
|
|
2222
|
+
caixaPostal: end.caixaPostal,
|
|
2223
|
+
correspondencia: end.correspondencia
|
|
2224
|
+
}));
|
|
2225
|
+
const telefonesPayload = (pessoa.telefones || []).map((tel) => ({
|
|
2226
|
+
ordemTelefone: tel.ordem,
|
|
2227
|
+
tipoTelefoneCodigo: tel.tipoTelefoneCodigo,
|
|
2228
|
+
ddi: tel.ddi,
|
|
2229
|
+
ddd: tel.ddd,
|
|
2230
|
+
numeroTelefone: tel.numero,
|
|
2231
|
+
ramal: tel.ramal,
|
|
2232
|
+
autorizaSMS: tel.autorizaSMS
|
|
2233
|
+
}));
|
|
2234
|
+
const emailsPayload = (pessoa.emails || []).map((email) => ({
|
|
2235
|
+
tipoEmailCodigo: email.tipoEmailCodigo,
|
|
2236
|
+
ordemEmail: email.ordem,
|
|
2237
|
+
email: email.email,
|
|
2238
|
+
autorizacao: email.autorizacao
|
|
2239
|
+
}));
|
|
2240
|
+
// --- Monta o objeto principal ---
|
|
2241
|
+
return {
|
|
2242
|
+
idPessoa: pessoa.idPessoa,
|
|
2243
|
+
codigoPessoa: pessoa.codigoPessoa,
|
|
2244
|
+
nome: pessoa.nome,
|
|
2245
|
+
nomeSocial: pessoa.nomeSocial,
|
|
2246
|
+
// Adiciona a chave 'cpf' ao objeto SOMENTE SE pessoa.cpf for truthy
|
|
2247
|
+
...(pessoa.cpf && { cpf: pessoa.cpf.replace(/\D/g, '') }),
|
|
2248
|
+
codigoSexo: pessoa.codigoSexo,
|
|
2249
|
+
codigoEstadoCivil: pessoa.codigoEstadoCivil,
|
|
2250
|
+
codigoEscolaridade: pessoa.escolaridade,
|
|
2251
|
+
// codigoTipoSanguineo: pessoa.tipoSanguineo,
|
|
2252
|
+
nomePai: pessoa.nomePai,
|
|
2253
|
+
nomeMae: pessoa.nomeMae,
|
|
2254
|
+
dataNascimento: this.formatarDataParaBackend(pessoa.dataNascimento),
|
|
2255
|
+
codigoPaisNascimento: pessoa.codigoPaisNascimento,
|
|
2256
|
+
ufNascimento: pessoa.ufNascimento,
|
|
2257
|
+
naturalidade: pessoa.naturalidade,
|
|
2258
|
+
rg: pessoa.rg,
|
|
2259
|
+
rgOrgao: pessoa.rgOrgao,
|
|
2260
|
+
rgUf: pessoa.rgUf,
|
|
2261
|
+
rgDataEmissao: this.formatarDataParaBackend(pessoa.rgDataEmissao),
|
|
2262
|
+
numeroTituloEleitor: pessoa.numeroTituloEleitor,
|
|
2263
|
+
dataEmissaoTituloEleitor: this.formatarDataParaBackend(pessoa.dataEmissaoTituloEleitor),
|
|
2264
|
+
zonaTituloEleitor: pessoa.zonaTituloEleitor,
|
|
2265
|
+
secaoTituloEleitor: pessoa.secaoTituloEleitor,
|
|
2266
|
+
ufTituloEleitor: pessoa.ufTituloEleitor,
|
|
2267
|
+
numeroReservista: pessoa.numeroReservista,
|
|
2268
|
+
serieReservista: pessoa.serieReservista,
|
|
2269
|
+
orgaoReservista: pessoa.orgaoReservista,
|
|
2270
|
+
numeroCarteiraTrabalho: pessoa.numeroCarteiraTrabalho,
|
|
2271
|
+
serieCarteiraTrabalho: pessoa.serieCarteiraTrabalho,
|
|
2272
|
+
ufCarteiraTrabalho: pessoa.ufCarteiraTrabalho,
|
|
2273
|
+
pisPasep: pessoa.pisPasep,
|
|
2274
|
+
numeroHabilitacao: pessoa.numeroHabilitacao,
|
|
2275
|
+
registroHabilitacao: pessoa.registroHabilitacao,
|
|
2276
|
+
dataEmissaoHabilitacao: this.formatarDataParaBackend(pessoa.dataEmissaoHabilitacao),
|
|
2277
|
+
dataValidadeHabilitacao: this.formatarDataParaBackend(pessoa.dataValidadeHabilitacao),
|
|
2278
|
+
categoriaHabilitacao: pessoa.categoriaHabilitacao,
|
|
2279
|
+
deficienciaFisicaHabilitacao: pessoa.deficienciaFisicaHabilitacao,
|
|
2280
|
+
primeiraHabilitacao: this.formatarDataParaBackend(pessoa.primeiraHabilitacao),
|
|
2281
|
+
passaporte: pessoa.passaporte,
|
|
2282
|
+
codigoPaisPassaporte: pessoa.codigoPaisPassaporte,
|
|
2283
|
+
// Adiciona a chave 'cnpj' ao objeto SOMENTE SE pessoa.cnpj for truthy
|
|
2284
|
+
...(pessoa.cnpj && { cnpj: pessoa.cnpj.replace(/\D/g, '') }),
|
|
2285
|
+
razaoSocial: pessoa.razaoSocial,
|
|
2286
|
+
nomeFantasia: pessoa.nomeFantasia,
|
|
2287
|
+
sigla: pessoa.sigla,
|
|
2288
|
+
paginaWeb: pessoa.paginaWeb,
|
|
2289
|
+
autoCadastro: pessoa.autoCadastro,
|
|
2290
|
+
enderecos: enderecosPayload,
|
|
2291
|
+
telefones: telefonesPayload,
|
|
2292
|
+
emails: emailsPayload
|
|
2293
|
+
};
|
|
2294
|
+
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Formata a data no padrão DD/MM/YYYY para o backend.
|
|
2297
|
+
*/
|
|
2298
|
+
formatarDataParaBackend(data) {
|
|
2299
|
+
if (!data)
|
|
2300
|
+
return null;
|
|
2301
|
+
if (typeof data === 'string' && data.includes('/'))
|
|
2302
|
+
return data;
|
|
2303
|
+
try {
|
|
2304
|
+
const d = new Date(data);
|
|
2305
|
+
if (isNaN(d.getTime()))
|
|
2306
|
+
return null;
|
|
2307
|
+
const dia = String(d.getDate()).padStart(2, '0');
|
|
2308
|
+
const mes = String(d.getMonth() + 1).padStart(2, '0');
|
|
2309
|
+
const ano = d.getFullYear();
|
|
2310
|
+
return `${dia}/${mes}/${ano}`;
|
|
2311
|
+
}
|
|
2312
|
+
catch {
|
|
2313
|
+
return null;
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaFormComponent, deps: [{ token: UnBPessoaService }, { token: i1$2.MatSnackBar }, { token: UnbMensagemService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2317
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: UnbPessoaFormComponent, selector: "lib-unb-pessoa-form", inputs: { apiPessoaConfig: "apiPessoaConfig", defaultTipoPessoa: "defaultTipoPessoa", pesquisarPorCPF: "pesquisarPorCPF", pesquisarPorCNPJ: "pesquisarPorCNPJ", pesquisarPorEstrangeiro: "pesquisarPorEstrangeiro", campoPesquisaMaxWidth: "campoPesquisaMaxWidth" }, ngImport: i0, template: "<mat-progress-bar *ngIf=\"isLoading\" mode=\"indeterminate\"></mat-progress-bar>\r\n\r\n<div class=\"form-container\">\r\n <lib-unb-pessoa-pesquisar [apiPessoaConfig]=\"apiPessoaConfig\" [defaultTipoPessoa]=\"defaultTipoPessoa\"\r\n [campoPesquisaMaxWidth]=\"campoPesquisaMaxWidth\" (pessoaEmitted)=\"pessoaRecebida($event)\">\r\n </lib-unb-pessoa-pesquisar>\r\n</div>\r\n\r\n<unb-mensagem></unb-mensagem>\r\n\r\n<form #pessoaForm=\"ngForm\" [class.readonly]=\"isReadonlyFromSiape || isLoading\" class=\"form-container mt-2\"\r\n *ngIf=\"buscaRealizada && apiPessoaConfig.url\" (ngSubmit)=\"salvar(pessoaForm)\">\r\n\r\n <!-- Campos Pessoa F\u00EDsica e Estrangeira -->\r\n <ng-container\r\n *ngIf=\"pessoa.tipoPessoa == tipoPessoaEnum().FISICA || pessoa.tipoPessoa == tipoPessoaEnum().ESTRANGEIRA\">\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Nome</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.nome\" name=\"nome\" #nome=\"ngModel\" required />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-10\" appearance=\"outline\">\r\n <mat-label>Sexo</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.codigoSexo\" name=\"codigoSexo\" #codigoSexo=\"ngModel\" required>\r\n <mat-option [value]=\"1\">Masculino</mat-option>\r\n <mat-option [value]=\"2\">Feminino</mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-15\" appearance=\"outline\">\r\n <mat-label>Data Nascimento</mat-label>\r\n <input matInput [matDatepicker]=\"dataNascimentoPicker\" [(ngModel)]=\"pessoa.dataNascimento\" name=\"dataNascimento\"\r\n #dataNascimento=\"ngModel\" required>\r\n <mat-datepicker-toggle matSuffix [for]=\"dataNascimentoPicker\"></mat-datepicker-toggle>\r\n <mat-datepicker #dataNascimentoPicker></mat-datepicker>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-10\" appearance=\"outline\">\r\n <mat-label>Estado Civil</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.codigoEstadoCivil\" name=\"codigoEstadoCivil\" #codigoEstadoCivil=\"ngModel\">\r\n <mat-option *ngFor=\"let estado of estadosCivil | async\" [value]=\"estado.codigo\">\r\n {{ estado.denominacao }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <!--\r\n <mat-form-field class=\"form-15\" appearance=\"outline\">\r\n <mat-label>Naturalidade</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.naturalidade\" name=\"naturalidade\" #naturalidade=\"ngModel\" required>\r\n <mat-option *ngFor=\"let cidade of getListaEstados()\" [value]=\"cidade.codigo\">\r\n {{ cidade.descricao }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n -->\r\n <mat-form-field class=\"form-10\" appearance=\"outline\">\r\n <mat-label>Pa\u00EDs Nascimento</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.codigoPaisNascimento\" name=\"codigoPaisNascimento\" #codigoPaisNascimento=\"ngModel\"\r\n required>\r\n <mat-option *ngFor=\"let paisNascimento of paises | async\" [value]=\"paisNascimento.codigo\">\r\n <span *ngIf=\"paisNascimento.denominacao === 'BRASIL'\">\uD83C\uDDE7\uD83C\uDDF7 <b>{{ paisNascimento.denominacao }}</b></span>\r\n <span *ngIf=\"paisNascimento.denominacao !== 'BRASIL'\">{{ paisNascimento.denominacao }}</span>\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-10\" appearance=\"outline\" *ngIf=\"pessoa.codigoPaisNascimento == 22\"> <!-- 22 eh Brasil-->\r\n <mat-label>UF Nascimento</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.ufNascimento\" name=\"ufNascimento\" #ufNascimento=\"ngModel\" required>\r\n <mat-option *ngFor=\"let ufNascimento of getListaEstados()\" [value]=\"ufNascimento.identificador\">\r\n {{ ufNascimento.identificador }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-15\" appearance=\"outline\" *ngIf=\"pessoa.codigoPaisNascimento == 22\">\r\n <mat-label>Naturalidade</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.naturalidade\" name=\"naturalidade\" #naturalidade=\"ngModel\"\r\n required />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-10\" appearance=\"outline\">\r\n <mat-label>Escolaridade</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.escolaridade\" name=\"codigoEscolaridade\" #codigoEscolaridade=\"ngModel\" required>\r\n <mat-option *ngFor=\"let escolaridade of escolaridade | async\" [value]=\"escolaridade.codigo\">\r\n {{ escolaridade.denominacao }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Nome Social</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.nomeSocial\" name=\"nomeSocial\" #nomeSocial=\"ngModel\" />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Nome da M\u00E3e</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.nomeMae\" name=\"nomeMae\" #nomeMae=\"ngModel\" required />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Nome do Pai</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.nomePai\" name=\"nomePai\" #nomePai=\"ngModel\" required />\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <!-- Campos Pessoa Jur\u00EDdica -->\r\n <ng-container *ngIf=\"pessoa.tipoPessoa === tipoPessoaEnum().JURIDICA\">\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Raz\u00E3o Social</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.razaoSocial\" name=\"razaoSocial\" />\r\n </mat-form-field>\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Nome Fantasia</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.nomeFantasia\" name=\"nomeFantasia\" />\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"pessoa.tipoPessoa == tipoPessoaEnum().FISICA\">\r\n <b style=\"flex: 1 1 100%; margin-bottom: 10px;\">Documenta\u00E7\u00E3o</b>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Identidade</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.rg\" name=\"rg\" #rg=\"ngModel\" required />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>\u00D3rg\u00E3o Emissor</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.rgOrgao\" name=\"rgOrgao\" #rgOrgao=\"ngModel\" required />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Unidade Federativa</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.rgUf\" name=\"rgUf\" #rgUf=\"ngModel\" required>\r\n <mat-option *ngFor=\"let cidade of getListaEstados()\" [value]=\"cidade.identificador\">\r\n {{ cidade.identificador }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-20\" appearance=\"outline\">\r\n <mat-label>Data de Emiss\u00E3o</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.rgDataEmissao\" name=\"rgDataEmissao\" #rgDataEmissao=\"ngModel\" />\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"pessoa.tipoPessoa == tipoPessoaEnum().ESTRANGEIRA \">\r\n <mat-form-field appearance=\"outline\">\r\n <mat-label>Data Chegada Brasil</mat-label>\r\n <input matInput [matDatepicker]=\"dataChegadaBrasilPicker\" [(ngModel)]=\"pessoa.dataChegadaBrasil\"\r\n name=\"dataChegadaBrasil\" #dataChegadaBrasil=\"ngModel\" required>\r\n <mat-datepicker-toggle matSuffix [for]=\"dataChegadaBrasilPicker\"></mat-datepicker-toggle>\r\n <mat-datepicker #dataChegadaBrasilPicker></mat-datepicker>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-10\" appearance=\"outline\">\r\n <mat-label>Pa\u00EDs Passaporte</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.codigoPaisPassaporte\" name=\"codigoPaisPassaporte\" #codigoPaisPassaporte=\"ngModel\"\r\n required>\r\n <mat-option *ngFor=\"let paisNascimento of paises | async\" [value]=\"paisNascimento.codigo\">\r\n {{ paisNascimento.denominacao }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field appearance=\"outline\">\r\n <mat-label>N\u00FAmero Passaporte</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.passaporte\" name=\"passaporte\" #passaporte=\"ngModel\" required />\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <lib-unb-pessoa-telefone-list style=\"flex: 1 1 100%;\" [apiPessoaConfig]=\"apiPessoaConfig\"\r\n [telefones]=\"pessoa.telefones\" (telefonesEmitted)=\"telefonesEmitted($event)\"></lib-unb-pessoa-telefone-list>\r\n\r\n <lib-unb-pessoa-endereco-list style=\"flex: 1 1 100%;\" [apiPessoaConfig]=\"apiPessoaConfig\"\r\n [enderecos]=\"pessoa.enderecos\" (enderecosEmitted)=\"enderecosEmitted($event)\"></lib-unb-pessoa-endereco-list>\r\n\r\n <lib-unb-pessoa-email-list style=\"flex: 1 1 100%;\" [apiPessoaConfig]=\"apiPessoaConfig\" [emails]=\"pessoa.emails\"\r\n (emailsEmitted)=\"emailsEmitted($event)\"></lib-unb-pessoa-email-list>\r\n\r\n <div *ngIf=\"isReadonlyFromSiape\" style=\"flex:1 1 100%; margin-bottom:10px;\">\r\n <mat-card>\r\n <mat-card-content>\r\n <strong>Servidor com matr\u00EDcula SIAPE deve ter seus dados autalizados pelo aplicativo do sougov</strong>\r\n </mat-card-content>\r\n </mat-card>\r\n </div>\r\n\r\n <mat-card-actions class=\"card-actions-buttons\" *ngIf=\"buscaRealizada\">\r\n <button mat-flat-button [disabled]=\"isLoading || isReadonlyFromSiape\" type=\"submit\" color=\"primary\">\r\n Salvar\r\n </button>\r\n </mat-card-actions>\r\n\r\n</form>", styles: [".card-actions-buttons{display:flex;gap:5px;flex-wrap:wrap}.form-container{display:flex;flex-wrap:wrap;column-gap:10px}:host{display:block}@media (max-width: 1000px){.form-container{flex-direction:column;gap:5px}}.break{flex-basis:100%;height:0}.form-5{flex:1 1 5%}.inline-table-container{display:flex;align-items:center;justify-content:space-between;padding:5px}@media (max-width: 600px){.form-5,.form-10,.form-15{flex:1 1 100%}}.form-10{flex:1 1 10%}.form-15{flex:1 1 15%}.form-20{flex:1 1 20%}.form-25{flex:1 1 25%}.form-30{flex:1 1 30%}.form-35{flex:1 1 35%}.form-40{flex:1 1 40%}.form-45{flex:1 1 45%}.form-50{flex:1 1 50%}.form-100{flex:1 1 100%;min-width:250px}.readonly{pointer-events:none;opacity:.6}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i5$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i5$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i5$2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i5$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i5$2.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i7.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: UnbMensagemComponent, selector: "unb-mensagem", inputs: ["mensagem", "tipo"] }, { kind: "component", type: i7$1.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i7$1.MatCardActions, selector: "mat-card-actions", inputs: ["align"], exportAs: ["matCardActions"] }, { kind: "directive", type: i7$1.MatCardContent, selector: "mat-card-content" }, { kind: "component", type: i7$2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i7$2.MatLabel, selector: "mat-label" }, { kind: "directive", type: i7$2.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i8$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i9.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i10.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: i13.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: i14.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: i14.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "component", type: i14.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { kind: "component", type: UnbPessoaPesquisarComponent, selector: "lib-unb-pessoa-pesquisar", inputs: ["apiPessoaConfig", "pesquisarPorCPF", "pesquisarPorCNPJ", "pesquisarPorEstrangeiro", "defaultTipoPessoa", "campoPesquisaMaxWidth", "pessoa", "mostrarPesquisa", "limparAposPesquisa", "label", "placeholder", "hint"], outputs: ["pessoaEmitted"] }, { kind: "component", type: UnbPessoaTelefoneListComponent, selector: "lib-unb-pessoa-telefone-list", inputs: ["podeEditar", "telefones", "apiPessoaConfig"], outputs: ["telefonesEmitted"] }, { kind: "component", type: UnbPessoaenderecoListComponent, selector: "lib-unb-pessoa-endereco-list", inputs: ["podeEditar", "enderecos", "apiPessoaConfig"], outputs: ["enderecosEmitted"] }, { kind: "component", type: UnbPessoaEmailListComponent, selector: "lib-unb-pessoa-email-list", inputs: ["podeEditar", "emails", "apiPessoaConfig"], outputs: ["emailsEmitted"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }] }); }
|
|
2318
|
+
}
|
|
2319
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaFormComponent, decorators: [{
|
|
2320
|
+
type: Component,
|
|
2321
|
+
args: [{ selector: 'lib-unb-pessoa-form', standalone: false, template: "<mat-progress-bar *ngIf=\"isLoading\" mode=\"indeterminate\"></mat-progress-bar>\r\n\r\n<div class=\"form-container\">\r\n <lib-unb-pessoa-pesquisar [apiPessoaConfig]=\"apiPessoaConfig\" [defaultTipoPessoa]=\"defaultTipoPessoa\"\r\n [campoPesquisaMaxWidth]=\"campoPesquisaMaxWidth\" (pessoaEmitted)=\"pessoaRecebida($event)\">\r\n </lib-unb-pessoa-pesquisar>\r\n</div>\r\n\r\n<unb-mensagem></unb-mensagem>\r\n\r\n<form #pessoaForm=\"ngForm\" [class.readonly]=\"isReadonlyFromSiape || isLoading\" class=\"form-container mt-2\"\r\n *ngIf=\"buscaRealizada && apiPessoaConfig.url\" (ngSubmit)=\"salvar(pessoaForm)\">\r\n\r\n <!-- Campos Pessoa F\u00EDsica e Estrangeira -->\r\n <ng-container\r\n *ngIf=\"pessoa.tipoPessoa == tipoPessoaEnum().FISICA || pessoa.tipoPessoa == tipoPessoaEnum().ESTRANGEIRA\">\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Nome</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.nome\" name=\"nome\" #nome=\"ngModel\" required />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-10\" appearance=\"outline\">\r\n <mat-label>Sexo</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.codigoSexo\" name=\"codigoSexo\" #codigoSexo=\"ngModel\" required>\r\n <mat-option [value]=\"1\">Masculino</mat-option>\r\n <mat-option [value]=\"2\">Feminino</mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-15\" appearance=\"outline\">\r\n <mat-label>Data Nascimento</mat-label>\r\n <input matInput [matDatepicker]=\"dataNascimentoPicker\" [(ngModel)]=\"pessoa.dataNascimento\" name=\"dataNascimento\"\r\n #dataNascimento=\"ngModel\" required>\r\n <mat-datepicker-toggle matSuffix [for]=\"dataNascimentoPicker\"></mat-datepicker-toggle>\r\n <mat-datepicker #dataNascimentoPicker></mat-datepicker>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-10\" appearance=\"outline\">\r\n <mat-label>Estado Civil</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.codigoEstadoCivil\" name=\"codigoEstadoCivil\" #codigoEstadoCivil=\"ngModel\">\r\n <mat-option *ngFor=\"let estado of estadosCivil | async\" [value]=\"estado.codigo\">\r\n {{ estado.denominacao }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <!--\r\n <mat-form-field class=\"form-15\" appearance=\"outline\">\r\n <mat-label>Naturalidade</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.naturalidade\" name=\"naturalidade\" #naturalidade=\"ngModel\" required>\r\n <mat-option *ngFor=\"let cidade of getListaEstados()\" [value]=\"cidade.codigo\">\r\n {{ cidade.descricao }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n -->\r\n <mat-form-field class=\"form-10\" appearance=\"outline\">\r\n <mat-label>Pa\u00EDs Nascimento</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.codigoPaisNascimento\" name=\"codigoPaisNascimento\" #codigoPaisNascimento=\"ngModel\"\r\n required>\r\n <mat-option *ngFor=\"let paisNascimento of paises | async\" [value]=\"paisNascimento.codigo\">\r\n <span *ngIf=\"paisNascimento.denominacao === 'BRASIL'\">\uD83C\uDDE7\uD83C\uDDF7 <b>{{ paisNascimento.denominacao }}</b></span>\r\n <span *ngIf=\"paisNascimento.denominacao !== 'BRASIL'\">{{ paisNascimento.denominacao }}</span>\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-10\" appearance=\"outline\" *ngIf=\"pessoa.codigoPaisNascimento == 22\"> <!-- 22 eh Brasil-->\r\n <mat-label>UF Nascimento</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.ufNascimento\" name=\"ufNascimento\" #ufNascimento=\"ngModel\" required>\r\n <mat-option *ngFor=\"let ufNascimento of getListaEstados()\" [value]=\"ufNascimento.identificador\">\r\n {{ ufNascimento.identificador }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-15\" appearance=\"outline\" *ngIf=\"pessoa.codigoPaisNascimento == 22\">\r\n <mat-label>Naturalidade</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.naturalidade\" name=\"naturalidade\" #naturalidade=\"ngModel\"\r\n required />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-10\" appearance=\"outline\">\r\n <mat-label>Escolaridade</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.escolaridade\" name=\"codigoEscolaridade\" #codigoEscolaridade=\"ngModel\" required>\r\n <mat-option *ngFor=\"let escolaridade of escolaridade | async\" [value]=\"escolaridade.codigo\">\r\n {{ escolaridade.denominacao }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Nome Social</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.nomeSocial\" name=\"nomeSocial\" #nomeSocial=\"ngModel\" />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Nome da M\u00E3e</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.nomeMae\" name=\"nomeMae\" #nomeMae=\"ngModel\" required />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Nome do Pai</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.nomePai\" name=\"nomePai\" #nomePai=\"ngModel\" required />\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <!-- Campos Pessoa Jur\u00EDdica -->\r\n <ng-container *ngIf=\"pessoa.tipoPessoa === tipoPessoaEnum().JURIDICA\">\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Raz\u00E3o Social</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.razaoSocial\" name=\"razaoSocial\" />\r\n </mat-form-field>\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Nome Fantasia</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.nomeFantasia\" name=\"nomeFantasia\" />\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"pessoa.tipoPessoa == tipoPessoaEnum().FISICA\">\r\n <b style=\"flex: 1 1 100%; margin-bottom: 10px;\">Documenta\u00E7\u00E3o</b>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Identidade</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.rg\" name=\"rg\" #rg=\"ngModel\" required />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>\u00D3rg\u00E3o Emissor</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.rgOrgao\" name=\"rgOrgao\" #rgOrgao=\"ngModel\" required />\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-25\" appearance=\"outline\">\r\n <mat-label>Unidade Federativa</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.rgUf\" name=\"rgUf\" #rgUf=\"ngModel\" required>\r\n <mat-option *ngFor=\"let cidade of getListaEstados()\" [value]=\"cidade.identificador\">\r\n {{ cidade.identificador }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-20\" appearance=\"outline\">\r\n <mat-label>Data de Emiss\u00E3o</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.rgDataEmissao\" name=\"rgDataEmissao\" #rgDataEmissao=\"ngModel\" />\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"pessoa.tipoPessoa == tipoPessoaEnum().ESTRANGEIRA \">\r\n <mat-form-field appearance=\"outline\">\r\n <mat-label>Data Chegada Brasil</mat-label>\r\n <input matInput [matDatepicker]=\"dataChegadaBrasilPicker\" [(ngModel)]=\"pessoa.dataChegadaBrasil\"\r\n name=\"dataChegadaBrasil\" #dataChegadaBrasil=\"ngModel\" required>\r\n <mat-datepicker-toggle matSuffix [for]=\"dataChegadaBrasilPicker\"></mat-datepicker-toggle>\r\n <mat-datepicker #dataChegadaBrasilPicker></mat-datepicker>\r\n </mat-form-field>\r\n\r\n <mat-form-field class=\"form-10\" appearance=\"outline\">\r\n <mat-label>Pa\u00EDs Passaporte</mat-label>\r\n <mat-select [(ngModel)]=\"pessoa.codigoPaisPassaporte\" name=\"codigoPaisPassaporte\" #codigoPaisPassaporte=\"ngModel\"\r\n required>\r\n <mat-option *ngFor=\"let paisNascimento of paises | async\" [value]=\"paisNascimento.codigo\">\r\n {{ paisNascimento.denominacao }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n\r\n <mat-form-field appearance=\"outline\">\r\n <mat-label>N\u00FAmero Passaporte</mat-label>\r\n <input type=\"text\" matInput [(ngModel)]=\"pessoa.passaporte\" name=\"passaporte\" #passaporte=\"ngModel\" required />\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <lib-unb-pessoa-telefone-list style=\"flex: 1 1 100%;\" [apiPessoaConfig]=\"apiPessoaConfig\"\r\n [telefones]=\"pessoa.telefones\" (telefonesEmitted)=\"telefonesEmitted($event)\"></lib-unb-pessoa-telefone-list>\r\n\r\n <lib-unb-pessoa-endereco-list style=\"flex: 1 1 100%;\" [apiPessoaConfig]=\"apiPessoaConfig\"\r\n [enderecos]=\"pessoa.enderecos\" (enderecosEmitted)=\"enderecosEmitted($event)\"></lib-unb-pessoa-endereco-list>\r\n\r\n <lib-unb-pessoa-email-list style=\"flex: 1 1 100%;\" [apiPessoaConfig]=\"apiPessoaConfig\" [emails]=\"pessoa.emails\"\r\n (emailsEmitted)=\"emailsEmitted($event)\"></lib-unb-pessoa-email-list>\r\n\r\n <div *ngIf=\"isReadonlyFromSiape\" style=\"flex:1 1 100%; margin-bottom:10px;\">\r\n <mat-card>\r\n <mat-card-content>\r\n <strong>Servidor com matr\u00EDcula SIAPE deve ter seus dados autalizados pelo aplicativo do sougov</strong>\r\n </mat-card-content>\r\n </mat-card>\r\n </div>\r\n\r\n <mat-card-actions class=\"card-actions-buttons\" *ngIf=\"buscaRealizada\">\r\n <button mat-flat-button [disabled]=\"isLoading || isReadonlyFromSiape\" type=\"submit\" color=\"primary\">\r\n Salvar\r\n </button>\r\n </mat-card-actions>\r\n\r\n</form>", styles: [".card-actions-buttons{display:flex;gap:5px;flex-wrap:wrap}.form-container{display:flex;flex-wrap:wrap;column-gap:10px}:host{display:block}@media (max-width: 1000px){.form-container{flex-direction:column;gap:5px}}.break{flex-basis:100%;height:0}.form-5{flex:1 1 5%}.inline-table-container{display:flex;align-items:center;justify-content:space-between;padding:5px}@media (max-width: 600px){.form-5,.form-10,.form-15{flex:1 1 100%}}.form-10{flex:1 1 10%}.form-15{flex:1 1 15%}.form-20{flex:1 1 20%}.form-25{flex:1 1 25%}.form-30{flex:1 1 30%}.form-35{flex:1 1 35%}.form-40{flex:1 1 40%}.form-45{flex:1 1 45%}.form-50{flex:1 1 50%}.form-100{flex:1 1 100%;min-width:250px}.readonly{pointer-events:none;opacity:.6}\n"] }]
|
|
2322
|
+
}], ctorParameters: () => [{ type: UnBPessoaService }, { type: i1$2.MatSnackBar }, { type: UnbMensagemService }], propDecorators: { apiPessoaConfig: [{
|
|
2323
|
+
type: Input
|
|
2324
|
+
}], defaultTipoPessoa: [{
|
|
2325
|
+
type: Input
|
|
2326
|
+
}], pesquisarPorCPF: [{
|
|
2327
|
+
type: Input
|
|
2328
|
+
}], pesquisarPorCNPJ: [{
|
|
2329
|
+
type: Input
|
|
2330
|
+
}], pesquisarPorEstrangeiro: [{
|
|
2331
|
+
type: Input
|
|
2332
|
+
}], campoPesquisaMaxWidth: [{
|
|
2333
|
+
type: Input
|
|
2334
|
+
}] } });
|
|
2335
|
+
|
|
2336
|
+
class UnbPessoaModule {
|
|
2337
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
2338
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaModule, declarations: [UnbPessoaFormComponent, UnbPessoaPesquisarComponent, UnbPessoaEnderecoFormComponent, UnbPessoaTelefoneListComponent, UnbPessoaenderecoListComponent, UnbPessoaTelefoneFormComponent, UnbPessoaEmailFormComponent, UnbPessoaEmailListComponent], imports: [CommonModule,
|
|
2339
|
+
FormsModule,
|
|
2340
|
+
BrowserModule,
|
|
2341
|
+
MatIconModule,
|
|
2342
|
+
DragDropModule,
|
|
2343
|
+
MatListModule,
|
|
2344
|
+
MatButtonModule,
|
|
2345
|
+
UnbUsuarioModule,
|
|
2346
|
+
UnbMensagemModule,
|
|
2347
|
+
MatCardModule,
|
|
2348
|
+
MatFormFieldModule,
|
|
2349
|
+
MatIconModule,
|
|
2350
|
+
MatInputModule,
|
|
2351
|
+
MatDialogModule,
|
|
2352
|
+
MatSelectModule,
|
|
2353
|
+
MatProgressSpinnerModule,
|
|
2354
|
+
MatButtonModule,
|
|
2355
|
+
MatProgressBarModule,
|
|
2356
|
+
MatNativeDateModule,
|
|
2357
|
+
MatListModule,
|
|
2358
|
+
MatPaginatorModule,
|
|
2359
|
+
MatExpansionModule,
|
|
2360
|
+
MatSnackBarModule,
|
|
2361
|
+
MatDatepickerModule,
|
|
2362
|
+
MatRadioModule,
|
|
2363
|
+
MatCardModule,
|
|
2364
|
+
MatDividerModule], exports: [UnbPessoaFormComponent, UnbPessoaPesquisarComponent, UnbPessoaEnderecoFormComponent, UnbPessoaTelefoneListComponent, UnbPessoaenderecoListComponent, UnbPessoaTelefoneFormComponent, UnbPessoaEmailFormComponent] }); }
|
|
2365
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaModule, providers: [
|
|
2366
|
+
MatDatepickerModule,
|
|
2367
|
+
DatePipe,
|
|
2368
|
+
CurrencyPipe
|
|
2369
|
+
], imports: [CommonModule,
|
|
2370
|
+
FormsModule,
|
|
2371
|
+
BrowserModule,
|
|
2372
|
+
MatIconModule,
|
|
2373
|
+
DragDropModule,
|
|
2374
|
+
MatListModule,
|
|
2375
|
+
MatButtonModule,
|
|
2376
|
+
UnbUsuarioModule,
|
|
2377
|
+
UnbMensagemModule,
|
|
2378
|
+
MatCardModule,
|
|
2379
|
+
MatFormFieldModule,
|
|
2380
|
+
MatIconModule,
|
|
2381
|
+
MatInputModule,
|
|
2382
|
+
MatDialogModule,
|
|
2383
|
+
MatSelectModule,
|
|
2384
|
+
MatProgressSpinnerModule,
|
|
2385
|
+
MatButtonModule,
|
|
2386
|
+
MatProgressBarModule,
|
|
2387
|
+
MatNativeDateModule,
|
|
2388
|
+
MatListModule,
|
|
2389
|
+
MatPaginatorModule,
|
|
2390
|
+
MatExpansionModule,
|
|
2391
|
+
MatSnackBarModule,
|
|
2392
|
+
MatDatepickerModule,
|
|
2393
|
+
MatRadioModule,
|
|
2394
|
+
MatCardModule,
|
|
2395
|
+
MatDividerModule] }); }
|
|
2396
|
+
}
|
|
2397
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: UnbPessoaModule, decorators: [{
|
|
2398
|
+
type: NgModule,
|
|
2399
|
+
args: [{
|
|
2400
|
+
declarations: [UnbPessoaFormComponent, UnbPessoaPesquisarComponent, UnbPessoaEnderecoFormComponent, UnbPessoaTelefoneListComponent, UnbPessoaenderecoListComponent, UnbPessoaTelefoneFormComponent, UnbPessoaEmailFormComponent, UnbPessoaEmailListComponent],
|
|
2401
|
+
imports: [
|
|
2402
|
+
CommonModule,
|
|
2403
|
+
FormsModule,
|
|
2404
|
+
BrowserModule,
|
|
2405
|
+
MatIconModule,
|
|
2406
|
+
DragDropModule,
|
|
2407
|
+
MatListModule,
|
|
2408
|
+
MatButtonModule,
|
|
2409
|
+
UnbUsuarioModule,
|
|
2410
|
+
UnbMensagemModule,
|
|
2411
|
+
MatCardModule,
|
|
2412
|
+
MatFormFieldModule,
|
|
2413
|
+
MatIconModule,
|
|
2414
|
+
MatInputModule,
|
|
2415
|
+
MatDialogModule,
|
|
2416
|
+
MatSelectModule,
|
|
2417
|
+
MatProgressSpinnerModule,
|
|
2418
|
+
MatButtonModule,
|
|
2419
|
+
MatProgressBarModule,
|
|
2420
|
+
MatNativeDateModule,
|
|
2421
|
+
MatListModule,
|
|
2422
|
+
MatPaginatorModule,
|
|
2423
|
+
MatExpansionModule,
|
|
2424
|
+
MatSnackBarModule,
|
|
2425
|
+
MatDatepickerModule,
|
|
2426
|
+
MatRadioModule,
|
|
2427
|
+
MatCardModule,
|
|
2428
|
+
MatDividerModule
|
|
2429
|
+
],
|
|
2430
|
+
exports: [UnbPessoaFormComponent, UnbPessoaPesquisarComponent, UnbPessoaEnderecoFormComponent, UnbPessoaTelefoneListComponent, UnbPessoaenderecoListComponent, UnbPessoaTelefoneFormComponent, UnbPessoaEmailFormComponent],
|
|
2431
|
+
providers: [
|
|
2432
|
+
MatDatepickerModule,
|
|
2433
|
+
DatePipe,
|
|
2434
|
+
CurrencyPipe
|
|
2435
|
+
]
|
|
2436
|
+
}]
|
|
2437
|
+
}] });
|
|
2438
|
+
|
|
2439
|
+
class UnbPessoaEscolaridade {
|
|
2440
|
+
constructor() {
|
|
2441
|
+
this.extinto = false;
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
class UnbPessoaEstadoCivil {
|
|
2446
|
+
constructor() {
|
|
2447
|
+
this.extinto = false;
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
class UnbPessoaMunincipio {
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
class UnbPessoaPais {
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
class UnbPessoaRacaCor {
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
/*
|
|
2461
|
+
* Public API Surface of unb-lib-components
|
|
2462
|
+
*/
|
|
2463
|
+
|
|
2464
|
+
/**
|
|
2465
|
+
* Generated bundle index. Do not edit.
|
|
2466
|
+
*/
|
|
2467
|
+
|
|
2468
|
+
export { TipoPessoaEnum, UnBPessoaService, UnbAuthService, UnbMensagemComponent, UnbMensagemModule, UnbMensagemService, UnbNavBarComponent, UnbNavBarModule, UnbPessoaEmail, UnbPessoaEmailFormComponent, UnbPessoaEmailListComponent, UnbPessoaEmailTipo, UnbPessoaEndereco, UnbPessoaEnderecoFormComponent, UnbPessoaEnderecoTipo, UnbPessoaEscolaridade, UnbPessoaEstadoCivil, UnbPessoaFormComponent, UnbPessoaModel, UnbPessoaModule, UnbPessoaMunincipio, UnbPessoaPais, UnbPessoaPesquisarComponent, UnbPessoaRacaCor, UnbPessoaTelefone, UnbPessoaTelefoneFormComponent, UnbPessoaTelefoneListComponent, UnbPessoaTelefoneTipo, UnbPessoaenderecoListComponent, UnbTipoMensagemEnum, UnbUsuarioModel, listaEstados };
|
|
2469
|
+
//# sourceMappingURL=stiunb-unb-lib-components.mjs.map
|