création de la page businessunit et de la page businessunitedit

pull/6/head
Clement FERRERE 3 years ago
parent 270733cee1
commit b018d20079
  1. 1
      src/app/components/businessunit/businessunit-edit/businessunit-edit.component.html
  2. 0
      src/app/components/businessunit/businessunit-edit/businessunit-edit.component.scss
  3. 15
      src/app/components/businessunit/businessunit-edit/businessunit-edit.component.ts
  4. 32
      src/app/components/businessunit/businessunit.component.html
  5. 0
      src/app/components/businessunit/businessunit.component.scss
  6. 37
      src/app/components/businessunit/businessunit.component.ts

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-businessunit-edit',
templateUrl: './businessunit-edit.component.html',
styleUrls: ['./businessunit-edit.component.scss']
})
export class BusinessunitEditComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

@ -0,0 +1,32 @@
<div xmlns="">
<h2 class = mb-4>Business Unit</h2>
<table class = mb-5>
<tr>
<th class="spaced">Name</th>
</tr>
<tr *ngFor="let businessunit of businessunits">
<td class="spaced"> {{businessunit.name}} </td>
<td class="spaced"> <a routerLink="{{businessunit.id}}"> Modifier </a></td>
</tr>
</table>
<h3>Ajouter une businessunit : </h3>
<div class = mb-3>
<table>
<tr>
<th>Name</th>
</tr>
<tr>
<td>
<input id="businessunit-name" [(ngModel)]="businessunit.name" placeholder="name">
</td>
</tr>
</table>
</div>
<button class="add-button" (click)="add(businessunit)">
Ajouter une businessunit
</button>
</div>

@ -0,0 +1,37 @@
import { Component, OnInit } from '@angular/core';
import {Businessunit} from "../../interfaces/businessunit";
import {HttpClient} from "@angular/common/http";
import {BusinessunitService} from "../../services/businessunit.service";
@Component({
selector: 'app-businessunit',
templateUrl: './businessunit.component.html',
styleUrls: ['./businessunit.component.scss']
})
export class BusinessunitComponent implements OnInit {
businessunits : Businessunit[] = [];
businessunit = {} as Businessunit ;
constructor(
private http : HttpClient,
private businessunitService: BusinessunitService,
) { }
ngOnInit(): void {
this.getBusinessunits();
}
getBusinessunits():void {
this.businessunitService.getBusinessunits()
.subscribe(businessunits => this.businessunits = businessunits);
}
add(businessunit: Businessunit): void {
this.businessunitService.addBusinessunit(businessunit)
.subscribe(businessunit => {
this.businessunits.push(businessunit);
});
}
}
Loading…
Cancel
Save