Skip to content

Commit

Permalink
Implementa update relacionamento laboratorio
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerDelNobre committed Jul 27, 2021
1 parent 82f0d22 commit 2a93196
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ export class LaboratorioCreateComponent implements OnInit {
}

ngOnInit(): void {
this.laboratoryDomainService
.read()
.subscribe((laboratoryDomains) => {
this.laboratoryDomains = laboratoryDomains;
console.table(this.laboratoryDomains);
});
this.laboratoryDomainService.read().subscribe((laboratoryDomains) => {

This comment has been minimized.

Copy link
@wellington1993

wellington1993 Jul 28, 2021

Collaborator

@RogerDelNobre Estudar sobre async e sempre fazer o unsubscribe.

this.laboratoryDomains = laboratoryDomains;
});
}

createLaboratorio(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
matInput
placeholder="Nome"
[(ngModel)]="laboratorio.nome"
name="name"
name="nome"
/>
</mat-form-field>

<mat-form-field appearance="fill">
<input
matInput
Expand All @@ -17,12 +18,28 @@
name="serie"
/>
</mat-form-field>

<mat-form-field appearance="fill">
<mat-label>Laboratório domínio</mat-label>
<mat-select
[(ngModel)]="laboratorio.laboratory_domain_id"

This comment has been minimized.

Copy link
@wellington1993

wellington1993 Jul 28, 2021

Collaborator

@RogerDelNobre Talvez de pra usar lanboratory_domain ao invés de laboratory_domain_Id, temos que experimentar.

name="laboratory_domain_id"
>
<mat-option
*ngFor="let laboratoryDomain of laboratoryDomains"
[value]="laboratoryDomain.id"

This comment has been minimized.

Copy link
@wellington1993

wellington1993 Jul 28, 2021

Collaborator

Temos que ver se compensa usar o id ou usar o objeto estruturado. Temos que analisar a diferença com o value e ngValue também. @RogerDelNobre

>
{{ laboratoryDomain.name }}
</mat-option>
</mat-select>
</mat-form-field>

<mat-form-field appearance="fill">
<input
matInput
[matDatepicker]="criado_em"
placeholder="Criado em"
[(ngModel)]="laboratorio.criado_em" name="criado em"
[(ngModel)]="laboratorio.criado_em" name="criado_em"
required
/>
<mat-datepicker-toggle
Expand All @@ -32,6 +49,7 @@
<mat-datepicker #criado_em></mat-datepicker>
</mat-form-field>
</form>

<button mat-raised-button (click)="updateLaboratorio()" color="primary">
Salvar
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { LaboratoryDomain } from './../../model/laboratory-domain.model';
import { LaboratoryDomainService } from '../../laboratory-domain/laboratory-domain.service';

This comment has been minimized.

Copy link
@wellington1993

wellington1993 Jul 28, 2021

Collaborator

Acho que poderíamos ter uma pasta services na raiz pra evitar esse caminho longo.
Talvez uma pasta shared. @RogerDelNobre

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Laboratorio } from '../../model/laboratorio.model';
Expand All @@ -10,9 +12,11 @@ import { LaboratorioService } from '../laboratorio.service';
})
export class LaboratorioUpdateComponent implements OnInit {
laboratorio!: Laboratorio;
laboratoryDomains: LaboratoryDomain[] = [];

constructor(
private laboratorioService: LaboratorioService,
private laboratoryDomainService: LaboratoryDomainService,
private router: Router,
private route: ActivatedRoute
) { }
Expand All @@ -24,6 +28,12 @@ export class LaboratorioUpdateComponent implements OnInit {
.subscribe((laboratorio) => {
this.laboratorio = laboratorio;
});

this.laboratoryDomainService
.read()
.subscribe((laboratoryDomains) => {

This comment has been minimized.

Copy link
@wellington1993

wellington1993 Jul 28, 2021

Collaborator

Usar async no template HTML ou usar fazer um unsubscribe... @RogerDelNobre

this.laboratoryDomains = laboratoryDomains;
});
}

updateLaboratorio(): void {
Expand Down

1 comment on commit 2a93196

@wellington1993
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: @RogerDelNobre Revisar itens dos comentários, principalmente a questão do Unsubscribe e do async.

Please sign in to comment.