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