@@ -39,6 +39,7 @@ import { NOTA_RODAPE_CHANGE_EVENT, NOTA_RODAPE_REMOVE_EVENT, NotaRodape } from '
39
39
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js' ;
40
40
import { DestinoComponent } from './destino/destino.component' ;
41
41
import { errorInicializarEdicaoAction } from '../model/lexml/acao/errorInicializarEdicaoAction' ;
42
+ import { isHtmlSemTexto } from '../util/string-util' ;
42
43
import { ConfiguracaoPaginacao } from '../model/paginacao/paginacao' ;
43
44
import { TipoMensagem } from '../model/lexml/util/mensagem' ;
44
45
@@ -54,7 +55,7 @@ type TipoCasaLegislativa = 'SF' | 'CD' | 'CN';
54
55
* Parâmetros de inicialização de edição de documento
55
56
*/
56
57
export class LexmlEmendaParametrosEdicao {
57
- modo = 'Emenda ' ;
58
+ modo = 'emenda ' ;
58
59
59
60
// Identificação da proposição (texto) emendado.
60
61
// Opcional se for informada a emenda ou o projetoNorma
@@ -228,21 +229,6 @@ export class LexmlEmendaComponent extends connect(rootStore)(LitElement) {
228
229
this . getComissoes ( this . casaLegislativa ) . then ( comissoes => ( this . comissoes = comissoes ) ) ;
229
230
}
230
231
231
- private montarColegiadoApreciador ( sigla : string , numero : string , ano : string ) : ColegiadoApreciador {
232
- if ( sigla . toUpperCase ( ) === 'MPV' ) {
233
- return {
234
- siglaCasaLegislativa : 'CN' ,
235
- tipoColegiado : 'Comissão' ,
236
- siglaComissao : `CMMPV ${ numero } /${ ano } ` ,
237
- } ;
238
- }
239
- // Inicialmente registra destino plenário do SF para demais matérias
240
- return {
241
- siglaCasaLegislativa : 'SF' ,
242
- tipoColegiado : 'Plenário' ,
243
- } ;
244
- }
245
-
246
232
private montarLocalFromColegiadoApreciador ( colegiado : ColegiadoApreciador ) : any {
247
233
return colegiado . tipoColegiado === 'Comissão' ? 'Sala da comissão' : 'Sala das sessões' ;
248
234
}
@@ -284,15 +270,15 @@ export class LexmlEmendaComponent extends connect(rootStore)(LitElement) {
284
270
emenda . comandoEmendaTextoLivre . texto = '' ;
285
271
} else if ( this . isEmendaTextoLivre ( ) ) {
286
272
emenda . comandoEmendaTextoLivre . motivo = this . motivo ;
287
- emenda . comandoEmendaTextoLivre . texto = this . _lexmlEmendaTextoRico . texto ; // visualizar ? this.removeRevisaoFormat(this._lexmlEmendaTextoRico.texto) : this._lexmlEmendaTextoRico.texto;
273
+ emenda . comandoEmendaTextoLivre . texto = this . _lexmlEmendaTextoRico . texto ;
288
274
emenda . anexos = this . _lexmlEmendaTextoRico . anexos ;
289
275
emenda . comandoEmendaTextoLivre . textoAntesRevisao = this . _lexmlEmendaTextoRico . textoAntesRevisao ;
290
276
} else {
291
277
emenda . comandoEmendaTextoLivre . texto = '' ;
292
278
emenda . componentes [ 0 ] . dispositivos = this . _lexmlEta ! . getDispositivosEmenda ( ) ! ;
293
279
emenda . comandoEmenda = this . _lexmlEta ! . getComandoEmenda ( ) ;
294
280
}
295
- emenda . justificativa = this . _lexmlJustificativa . texto ; // visualizar ? this.removeRevisaoFormat(this._lexmlJustificativa.texto) : this._lexmlJustificativa.texto;
281
+ emenda . justificativa = this . _lexmlJustificativa . texto ;
296
282
emenda . notasRodape = this . _lexmlJustificativa . notasRodape ;
297
283
emenda . autoria = this . _lexmlAutoria . getAutoriaAtualizada ( ) ;
298
284
emenda . data = this . _lexmlData . data || undefined ;
@@ -320,17 +306,26 @@ export class LexmlEmendaComponent extends connect(rootStore)(LitElement) {
320
306
private getPendenciasPreenchimentoEmenda ( emenda : Emenda ) : string [ ] {
321
307
const pendenciasPreenchimento : Array < string > = [ ] ;
322
308
323
- if ( this . isEmendaSubstituicaoTermo ( ) ) {
309
+ if ( this . isEmendaPadrao ( ) ) {
310
+ if ( emenda . comandoEmenda . comandos . length === 0 ) {
311
+ pendenciasPreenchimento . push ( 'Deve ser feita pelo menos uma modificação no texto da proposição para a geração do comando de emenda.' ) ;
312
+ }
313
+ } else if ( this . isEmendaSubstituicaoTermo ( ) ) {
324
314
if ( emenda . substituicaoTermo ?. termo . replace ( '(termo a ser substituído)' , '' ) . trim ( ) === '' || emenda . substituicaoTermo ?. novoTermo . replace ( '(novo termo)' , '' ) . trim ( ) === '' ) {
325
315
pendenciasPreenchimento . push ( 'Substituição de termo não preenchida.' ) ;
326
316
}
327
- } else {
328
- if ( emenda . comandoEmenda . comandos . length === 0 ) {
329
- pendenciasPreenchimento . push ( 'Deve ser feita pelo menos uma modificação no texto da proposição para a geração do comando de emenda .' ) ;
317
+ } else if ( this . isEmendaTextoLivre ( ) ) {
318
+ if ( isHtmlSemTexto ( emenda . comandoEmendaTextoLivre . texto ) ) {
319
+ pendenciasPreenchimento . push ( 'Emenda de texto livre não preenchida .' ) ;
330
320
}
331
321
}
332
322
333
- const messagesCritical = rootStore . getState ( ) . elementoReducer . mensagensCritical ; //this.removeDuplicatasNodeList(this._lexmlEta!.querySelectorAll('.mensagem--danger'));
323
+ // Verifica preenchimento da justificação
324
+ if ( isHtmlSemTexto ( emenda . justificativa ) ) {
325
+ pendenciasPreenchimento . push ( 'Não foi informado um texto de justificação.' ) ;
326
+ }
327
+
328
+ const messagesCritical = rootStore . getState ( ) . elementoReducer . mensagensCritical ;
334
329
335
330
for ( let index = 0 ; index < messagesCritical . length ; index ++ ) {
336
331
const element = messagesCritical [ index ] ;
@@ -340,52 +335,6 @@ export class LexmlEmendaComponent extends connect(rootStore)(LitElement) {
340
335
return pendenciasPreenchimento ;
341
336
}
342
337
343
- private removeDuplicatasNodeList ( lista : any ) : any {
344
- const novaLista : Array < any > = [ ] ;
345
-
346
- for ( let index = 0 ; index < lista . length ; index ++ ) {
347
- const element = lista [ index ] ;
348
-
349
- if ( element . getAttribute ( 'tipo' ) === TipoMensagem . CRITICAL ) {
350
- if ( novaLista . length === 0 ) {
351
- novaLista . push ( element ) ;
352
- } else {
353
- if ( ! this . existeInNodeList ( novaLista , element . innerText ) ) {
354
- novaLista . push ( element ) ;
355
- }
356
- }
357
- }
358
- }
359
-
360
- return novaLista ;
361
- }
362
-
363
- private existeInNodeList ( lista : any , valor : any ) : boolean {
364
- let existe = false ;
365
-
366
- for ( let index = 0 ; index < lista . length ; index ++ ) {
367
- const element = lista [ index ] ;
368
- if ( element . innerText === valor ) {
369
- existe = true ;
370
- break ;
371
- }
372
- }
373
-
374
- return existe ;
375
- }
376
-
377
- private removeRevisaoFormat ( texto : string ) : string {
378
- let novoTexto = '' ;
379
-
380
- if ( texto !== '' ) {
381
- texto = texto . replace ( / < i n s \b [ ^ > ] * > ( .* ?) < \/ i n s > / s, '' ) ;
382
- texto = texto . replace ( / < d e l \b [ ^ > ] * > ( .* ?) < \/ d e l > / s, '' ) ;
383
- novoTexto = texto ;
384
- }
385
-
386
- return novoTexto ;
387
- }
388
-
389
338
private getRevisoes ( ) : Revisao [ ] {
390
339
const revisoes = ordernarRevisoes ( [ ...rootStore . getState ( ) . elementoReducer . revisoes ] ) ;
391
340
@@ -402,7 +351,6 @@ export class LexmlEmendaComponent extends connect(rootStore)(LitElement) {
402
351
try {
403
352
this . _lexmlEmendaComando . emenda = [ ] ;
404
353
this . modo = params . modo ;
405
- ( '' ) ;
406
354
this . projetoNorma = params . projetoNorma ;
407
355
this . isMateriaOrcamentaria = params . isMateriaOrcamentaria || ( ! ! params . emenda && params . emenda . colegiadoApreciador . siglaComissao === 'CMO' ) ;
408
356
this . _lexmlDestino ! . isMateriaOrcamentaria = this . isMateriaOrcamentaria ;
@@ -909,12 +857,20 @@ export class LexmlEmendaComponent extends connect(rootStore)(LitElement) {
909
857
mostrarDialogDisclaimerRevisao ( ) ;
910
858
}
911
859
860
+ private isEmendaPadrao ( ) : boolean {
861
+ return this . modo === ClassificacaoDocumento . EMENDA ;
862
+ }
863
+
864
+ private isEmendaDispositivoOndeCouber ( ) : boolean {
865
+ return this . modo === ClassificacaoDocumento . EMENDA_ARTIGO_ONDE_COUBER ;
866
+ }
867
+
912
868
private isEmendaTextoLivre ( ) : boolean {
913
- return this . modo && this . modo === 'emendaTextoLivre' ;
869
+ return this . modo === ClassificacaoDocumento . EMENDA_TEXTO_LIVRE ;
914
870
}
915
871
916
872
private isEmendaSubstituicaoTermo ( ) : boolean {
917
- return this . modo === 'emendaSubstituicaoTermo' ;
873
+ return this . modo === ClassificacaoDocumento . EMENDA_SUBSTITUICAO_TERMO ;
918
874
}
919
875
920
876
private updateView ( ) : void {
0 commit comments