Add a component to update a gear
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import { Component, Inject, OnInit } from "@angular/core";
|
||||
|
||||
import { MAT_DIALOG_DATA } from "@angular/material/dialog";
|
||||
import { TranslateModule } from "@ngx-translate/core";
|
||||
import { MatCheckboxModule } from "@angular/material/checkbox";
|
||||
import { MatFormFieldModule } from "@angular/material/form-field";
|
||||
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||
import { MatInputModule } from "@angular/material/input";
|
||||
import { MatButtonModule } from "@angular/material/button";
|
||||
|
||||
import { AddAction } from "../../models/add-action.enum";
|
||||
import { GearResp } from "../../models/gear";
|
||||
|
||||
import { GearService } from "../../services/gear.service";
|
||||
import { ServiceComm } from "../../services/service-comm.service";
|
||||
|
||||
@Component({
|
||||
selector: "app-gear-infos",
|
||||
templateUrl: "./gear-infos.component.html",
|
||||
styleUrls: ["./gear-infos.component.css"],
|
||||
imports: [
|
||||
TranslateModule,
|
||||
FormsModule,
|
||||
MatCheckboxModule,
|
||||
MatFormFieldModule,
|
||||
ReactiveFormsModule,
|
||||
MatInputModule,
|
||||
MatButtonModule,
|
||||
],
|
||||
})
|
||||
export class GearInfosComponent implements OnInit {
|
||||
public editMode: boolean;
|
||||
public gear: GearResp;
|
||||
|
||||
constructor(
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private serviceGear: GearService,
|
||||
private serviceComm: ServiceComm,
|
||||
) {
|
||||
this.gear = new GearResp(data.gear);
|
||||
this.editMode = data.editMode;
|
||||
}
|
||||
|
||||
ngOnInit(): void {}
|
||||
|
||||
public updateGear() {
|
||||
this.serviceGear
|
||||
.updateGear(
|
||||
this.gear.id,
|
||||
this.gear.name,
|
||||
this.gear.manufacturer,
|
||||
this.gear.minSize,
|
||||
this.gear.maxSize,
|
||||
this.gear.aad,
|
||||
this.gear.mainCanopy,
|
||||
this.gear.reserveCanopy,
|
||||
this.gear.equipment,
|
||||
)
|
||||
.subscribe(() => {
|
||||
this.serviceComm.refreshData(AddAction.Gear);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user