Skip to content

Commit

Permalink
fix: corrige diverses erreurs + améliorations
Browse files Browse the repository at this point in the history
* [auth/login] affiche de nouveau les messages d'erreur
* [auth/signup] affiche de nouveau les messages d'erreur
* modifie le composant de pagination afin qu'il ne prenne plus de Pageable en entrée
* corrige le multiselect du widget admin user pour que la liste de valeur soit visible même quand elle dépasse du composant parent
  • Loading branch information
matthieuaudemard committed May 1, 2023
1 parent 7dbb525 commit aef8ebc
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ <h2 class="card-title">{{title}}</h2>
<td role="cell">{{user.firstname}} {{user.lastname}}</td>
<td role="cell">
<div>
<!-- appendTo="body" permet d'afficher toutes les options du dropdown quand la card est trop petite -->
<p-multiSelect
appendTo="body"
optionLabel="label"
optionValue="code"
[styleClass]="'col-8'"
[styleClass]="'col-5 col-sm-8'"
[(ngModel)]="user.roles"
[showHeader]="false"
[options]="roles"
Expand Down Expand Up @@ -99,9 +101,9 @@ <h2 class="card-title">{{title}}</h2>
</div>
<div class="d-flex justify-content-end align-items-center datatable-bottom">
<app-paginator
(pageChange)="updatePage($event.page)"
[totalPages]="totalPage"
[page]="page"
(pageChange)="updatePage($event.page)"
></app-paginator>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ export class LoginPageComponent implements OnInit, OnDestroy {
.pipe(finalize(() => this.isLoading = false), take(1))
.subscribe({
next: principal => this.redirectSuccess(principal.username),
// pour l'instant on ne fait rien, l'error-interceptor s'occupe de gérer les erreurs
error: () => ({}),
error: (err) => {
if (err.error.errorMessage)
this.alertService.error('Erreur', err.error.errorMessage, null);
},
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ export class SignupPageComponent implements OnInit, OnDestroy {
this.authService
.signup(signupPaylod)
.pipe(finalize(() => this.isLoading = false), take(1))
.subscribe(() => this.router.navigate(['/auth/login'], {queryParams: {signupSuccess: true}}));
.subscribe({
next: () => this.router.navigate(['/auth/login'], {queryParams: {signupSuccess: true}}),
error: (err) => {
if (err.error.errorMessage)
this.alertService.error('Erreur', err.error.errorMessage, null);
}
});
}

ngOnDestroy(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@
</app-profile-card-base>
</div>
</ng-container>
</div>

<div class="d-flex justify-content-end">
<app-paginator
class="align-self-end"
(pageChange)="setCurrentPage($event.page)"
[totalPages]="pageable.totalPages"
[page]="pageable.number"
></app-paginator>

<div class=" ms-lg-2 p-4">
<app-paginator
class="align-self-end"
(pageChange)="setCurrentPage($event.page)"
[totalPages]="pageable.totalPages"
[page]="pageable.number"
></app-paginator>
</div>
</div>

<ng-template #templateLoading>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<nav>
<nav [ngStyle]="{'visibility': visible ? 'visible' : 'hidden'}">
<ul class="pagination justify-content-center align-items-end m-0">
<li *ngIf="!first" class="page-item cursor-pointer">
<span
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output, SimpleChanges} from '@angular/core';
import {PaginationUpdate} from "../../models/pagination-update";
import {PaginationUpdate} from '../../models/pagination-update';

@Component({
selector: 'app-paginator',
Expand All @@ -11,16 +11,19 @@ export class PaginatorComponent implements OnChanges {

@Input() page: number;
@Input() totalPages: number;
@Input() alwaysShow: boolean;

@Output() pageChange = new EventEmitter<PaginationUpdate>();

first: boolean;
last: boolean;
visible: boolean;

ngOnChanges(changes: SimpleChanges): void {
if (changes.hasOwnProperty('page') || changes.hasOwnProperty('totalPages')) {
this.first = !this.page
this.first = !this.page;
this.last = this.page >= (this.totalPages - 1);
this.visible = this.alwaysShow || this.totalPages > 1;
}
}

Expand Down
7 changes: 5 additions & 2 deletions frontend-implicaction/src/assets/primeng.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
}

.p-element {
&:hover, &.p-highlight {
background-color: $secondary !important;
&.p-dropdown-item, &.p-multiselect-item {

&:hover, &.p-highlight {
background-color: $secondary !important;
}
}
}

Expand Down

0 comments on commit aef8ebc

Please sign in to comment.