ajout du component alert pour les confirmations d'actions
This commit is contained in:
parent
6e8b258fbc
commit
92be353905
8 changed files with 57 additions and 22 deletions
|
@ -39,6 +39,7 @@ import { PageCreationTeamComponent } from './pages/page-creation-team/page-creat
|
||||||
import { AutofocusFixModule } from 'ngx-autofocus-fix';
|
import { AutofocusFixModule } from 'ngx-autofocus-fix';
|
||||||
import { EmoticonComponent } from './emoticon/emoticon.component';
|
import { EmoticonComponent } from './emoticon/emoticon.component';
|
||||||
import { DayPilot, DayPilotModule } from "@daypilot/daypilot-lite-angular";
|
import { DayPilot, DayPilotModule } from "@daypilot/daypilot-lite-angular";
|
||||||
|
import { AlertComponent } from './components/alert/alert.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
@ -75,6 +76,7 @@ import { DayPilot, DayPilotModule } from "@daypilot/daypilot-lite-angular";
|
||||||
PageModifierContactComponent,
|
PageModifierContactComponent,
|
||||||
PageCreationTeamComponent,
|
PageCreationTeamComponent,
|
||||||
EmoticonComponent,
|
EmoticonComponent,
|
||||||
|
AlertComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
|
4
src/app/components/alert/alert.component.html
Normal file
4
src/app/components/alert/alert.component.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<div class="alert alert-{{alert.type}} alert-dismissible fade show" role="alert" style="position:absolute;z-index:9999;top:10px;right:10px;">
|
||||||
|
{{alert.content}}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close" (click)="onClickCloseAlert()"></button>
|
||||||
|
</div>
|
0
src/app/components/alert/alert.component.scss
Normal file
0
src/app/components/alert/alert.component.scss
Normal file
25
src/app/components/alert/alert.component.spec.ts
Normal file
25
src/app/components/alert/alert.component.spec.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { AlertComponent } from './alert.component';
|
||||||
|
|
||||||
|
describe('AlertComponent', () => {
|
||||||
|
let component: AlertComponent;
|
||||||
|
let fixture: ComponentFixture<AlertComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ AlertComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(AlertComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
20
src/app/components/alert/alert.component.ts
Normal file
20
src/app/components/alert/alert.component.ts
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-alert',
|
||||||
|
templateUrl: './alert.component.html',
|
||||||
|
styleUrls: ['./alert.component.scss']
|
||||||
|
})
|
||||||
|
export class AlertComponent implements OnInit {
|
||||||
|
@Input() alert:any;
|
||||||
|
@Output() eventClose = new EventEmitter<string>();
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
onClickCloseAlert(){
|
||||||
|
//console.log('fermeture from component');
|
||||||
|
this.eventClose.emit('true');
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,7 @@
|
||||||
<app-header></app-header>
|
<app-header></app-header>
|
||||||
|
|
||||||
|
|
||||||
<div class="alert alert-{{alert.type}}" role="alert" style="position:absolute;z-index:999;top:50%;left:40%; width: 500px;" *ngIf="isShow" id="showAlert">
|
<app-alert *ngIf="alert" id="showAlert" [alert]="alert" (eventClose)="closeAlert($event)"></app-alert>
|
||||||
{{alert.content}}
|
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close" (click)="onClickCloseAlert()">
|
|
||||||
<span aria-hidden="true">×</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="display: flex;">
|
<div style="display: flex;">
|
||||||
<div style="width:150px;">
|
<div style="width:150px;">
|
||||||
|
|
|
@ -13,14 +13,12 @@ export class PageAgendaComponent implements AfterViewInit {
|
||||||
|
|
||||||
userId : any;
|
userId : any;
|
||||||
teamId : any;
|
teamId : any;
|
||||||
isShow: boolean;
|
|
||||||
alert:any;
|
alert:any;
|
||||||
|
|
||||||
@ViewChild("navigator") navigator!: DayPilotNavigatorComponent;
|
@ViewChild("navigator") navigator!: DayPilotNavigatorComponent;
|
||||||
@ViewChild("calendar") calendar!: DayPilotCalendarComponent;
|
@ViewChild("calendar") calendar!: DayPilotCalendarComponent;
|
||||||
|
|
||||||
constructor(private evenementService:EvenementService) {
|
constructor(private evenementService:EvenementService) {
|
||||||
this.isShow = false;
|
|
||||||
this.alert = "";
|
this.alert = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,9 +43,9 @@ export class PageAgendaComponent implements AfterViewInit {
|
||||||
|
|
||||||
events: DayPilot.EventData[] = [];
|
events: DayPilot.EventData[] = [];
|
||||||
|
|
||||||
onClickCloseAlert(){
|
closeAlert(value:any){
|
||||||
console.log('fermeture');
|
//console.log('fermeture'+value);
|
||||||
this.isShow = ! this.isShow;
|
this.alert="";
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
|
@ -88,12 +86,10 @@ export class PageAgendaComponent implements AfterViewInit {
|
||||||
next: result => {
|
next: result => {
|
||||||
this.viewChange();
|
this.viewChange();
|
||||||
this.alert={"type":"success", "content":"L'évènement à bien été modifié"};
|
this.alert={"type":"success", "content":"L'évènement à bien été modifié"};
|
||||||
this.isShow = true;
|
|
||||||
},
|
},
|
||||||
error: err => {
|
error: err => {
|
||||||
this.viewChange();
|
this.viewChange();
|
||||||
this.alert={"type":"danger", "content":"Problème lors de la modification de l'évenment"};
|
this.alert={"type":"danger", "content":"Problème lors de la modification de l'évenment"};
|
||||||
this.isShow = true;
|
|
||||||
},
|
},
|
||||||
complete: () => console.log('DONE!')
|
complete: () => console.log('DONE!')
|
||||||
}
|
}
|
||||||
|
@ -130,13 +126,11 @@ export class PageAgendaComponent implements AfterViewInit {
|
||||||
this.evenementService.addEvenements(event).subscribe({
|
this.evenementService.addEvenements(event).subscribe({
|
||||||
next: result => {
|
next: result => {
|
||||||
this.viewChange();
|
this.viewChange();
|
||||||
this.alert={"type":"success", "content":"L'évènement à été correctement ajouté au calendrier"};
|
this.alert={"type":"success", "content":"L'évènement à correctement été ajouté au calendrier"};
|
||||||
this.isShow = true;
|
|
||||||
},
|
},
|
||||||
error: err => {
|
error: err => {
|
||||||
this.viewChange();
|
this.viewChange();
|
||||||
this.alert={"type":"danger", "content":"Problème lors de l'ajout de l'évenment"};
|
this.alert={"type":"danger", "content":"Problème lors de l'ajout de l'évenment"};
|
||||||
this.isShow = true;
|
|
||||||
},
|
},
|
||||||
complete: () => console.log('DONE!')
|
complete: () => console.log('DONE!')
|
||||||
});
|
});
|
||||||
|
@ -147,13 +141,11 @@ export class PageAgendaComponent implements AfterViewInit {
|
||||||
this.evenementService.deleteEvenements(Number(args.e.id())).subscribe({
|
this.evenementService.deleteEvenements(Number(args.e.id())).subscribe({
|
||||||
next: result => {
|
next: result => {
|
||||||
this.viewChange();
|
this.viewChange();
|
||||||
this.alert={"type":"success", "content":"L'évènement à été correctement supprimé du calendrier"};
|
this.alert={"type":"success", "content":"L'évènement à correctement été supprimé du calendrier"};
|
||||||
this.isShow = true;
|
|
||||||
},
|
},
|
||||||
error: err => {
|
error: err => {
|
||||||
this.viewChange();
|
this.viewChange();
|
||||||
this.alert={"type":"danger", "content":"Problème lors de la suppression de l'évenment"};
|
this.alert={"type":"danger", "content":"Problème lors de la suppression de l'évenment"};
|
||||||
this.isShow = true;
|
|
||||||
},
|
},
|
||||||
complete: () => console.log('DONE!')
|
complete: () => console.log('DONE!')
|
||||||
})
|
})
|
||||||
|
@ -175,12 +167,10 @@ export class PageAgendaComponent implements AfterViewInit {
|
||||||
next: result => {
|
next: result => {
|
||||||
this.viewChange();
|
this.viewChange();
|
||||||
this.alert={"type":"success", "content":"L'évènement à bien été modifié"};
|
this.alert={"type":"success", "content":"L'évènement à bien été modifié"};
|
||||||
this.isShow = true;
|
|
||||||
},
|
},
|
||||||
error: err => {
|
error: err => {
|
||||||
this.viewChange();
|
this.viewChange();
|
||||||
this.alert={"type":"danger", "content":"Problème lors de la modification de l'évenment"};
|
this.alert={"type":"danger", "content":"Problème lors de la modification de l'évenment"};
|
||||||
this.isShow = true;
|
|
||||||
},
|
},
|
||||||
complete: () => console.log('DONE!')
|
complete: () => console.log('DONE!')
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
<base href="/">
|
<base href="/">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<app-root></app-root>
|
<app-root></app-root>
|
||||||
|
|
Loading…
Add table
Reference in a new issue