diff --git a/src/app/profile/dashboard/orientation-details/orientation-details.component.html b/src/app/profile/dashboard/orientation-details/orientation-details.component.html index 6308a31a75de1e72c2bf775f2d5febbdd0139137..b3689bb4a1d030a310240635eb8eaf79ccefc19e 100644 --- a/src/app/profile/dashboard/orientation-details/orientation-details.component.html +++ b/src/app/profile/dashboard/orientation-details/orientation-details.component.html @@ -16,25 +16,18 @@ </div> </div> <app-button - *ngIf="from === 'todoOrientations'" + *ngIf="from === 'todoOrientations' && !isClosed" class="hide-on-mobile" [label]="'Clôturer'" [variant]="'primaryBlack'" (action)="showModal()" /> <app-button - *ngIf="!isEditMode && from === 'todoOrientations'" + *ngIf="from === 'todoOrientations' && isClosed" class="hide-on-mobile" [label]="'Modifier'" [variant]="'secondary'" - (action)="editOrientation()" - /> - <app-button - *ngIf="isEditMode && from === 'todoOrientations'" - class="hide-on-mobile" - [label]="'Enregistrer'" - [variant]="'primary'" - (action)="editOrientation()" + (action)="showModal()" /> </div> @@ -42,25 +35,19 @@ <section> <span class="secondary-header"> <h2>Traitement</h2> - <!--app-button - *ngIf="from === 'todoOrientations'" - class="hide-on-desktop" - [label]="'Clôturer'" - [variant]="'primaryBlack'" - (action)="showModal()" /--> <app-button - *ngIf="!isEditMode && from === 'todoOrientations'" + *ngIf="from === 'todoOrientations' && !isClosed" class="hide-on-desktop" - [label]="'Modifier'" - [variant]="'secondary'" - (action)="editOrientation()" + [label]="'Clôturer'" + [variant]="'primaryBlack'" + (action)="showModal()" /> <app-button - *ngIf="isEditMode && from === 'todoOrientations'" + *ngIf="from === 'todoOrientations' && isClosed" class="hide-on-desktop" [label]="'Modifier'" - [variant]="'primary'" - (action)="editOrientation()" + [variant]="'secondary'" + (action)="showModal()" /> </span> <div class="content"> @@ -109,10 +96,9 @@ <div class="inline"> <app-svg-icon [iconClass]="'icon-20'" [folder]="'tags'" [icon]="'calendarBlue'" /> <div class="datePickerContainer"> - <span class="category-name">Date de RDV :</span> + <span class="category-name" id="dateLabel">Date de RDV :</span> <span class="datePicker"> - <label for="date">Date:</label> - <input type="date" id="date" name="date" /> + <input type="date" id="date" name="date" aria-labelledby="dateLabel" /> </span> </div> </div> @@ -179,14 +165,7 @@ <app-svg-icon [iconClass]="'icon-20'" [folder]="'tags'" [icon]="'commentBlue'" /> <p class="inline"> <span class="category-name" id="processingCommentLabel">Commentaire :</span> - <ng-container *ngIf="!isEditMode">{{ orientation.processingComment || 'Non renseigné' }}</ng-container> - <app-textarea - *ngIf="isEditMode" - id="processingComment" - aria-labelledby="processingCommentLabel" - [value]="orientation.processingComment" - (valueChange)="setProcessingComment($event)" - /> + {{ orientation.processingComment || 'Non renseigné' }} </p> </div> </ng-container> @@ -298,12 +277,10 @@ <div class="modalForm"> <div class="subtitle">Statut de l'accompagnement :</div> <div class="inline"> - {{ orientation.status }} <input id="completed" type="radio" name="status" value="completed" [(ngModel)]="selectedStatus" /> <label for="completed">Terminé</label> </div> <div class="inline"> - {{ orientation.status }} <input id="uncompleted" type="radio" name="status" value="uncompleted" [(ngModel)]="selectedStatus" /> <label for="uncompleted">Non réalisé</label> </div> diff --git a/src/app/profile/dashboard/orientation-details/orientation-details.component.scss b/src/app/profile/dashboard/orientation-details/orientation-details.component.scss index 32ee9921d4ecd715f528602f2794fcb1a4e64770..9c6b0133bd525369e6257ccc15fae6a9f917f74c 100644 --- a/src/app/profile/dashboard/orientation-details/orientation-details.component.scss +++ b/src/app/profile/dashboard/orientation-details/orientation-details.component.scss @@ -120,6 +120,10 @@ padding: 8px; } } + @media #{$phone} { + flex-direction: column; + align-items: self-start; + } } .pipe { diff --git a/src/app/profile/dashboard/orientation-details/orientation-details.component.ts b/src/app/profile/dashboard/orientation-details/orientation-details.component.ts index dd702fbab243fb02880ef68bf1efae0243318be2..1f36e09e304a9eb472ad5bdb2ec8b2e00e808c40 100644 --- a/src/app/profile/dashboard/orientation-details/orientation-details.component.ts +++ b/src/app/profile/dashboard/orientation-details/orientation-details.component.ts @@ -26,10 +26,10 @@ export class OrientationDetailsComponent implements OnInit { public orientation; public isModalOpenned = false; public userProfile: User; - public isEditMode = false; public from: string; public closingComment = ''; public selectedStatus = ''; + public isClosed: boolean; ngOnInit(): void { this.route.queryParams.subscribe((params) => { @@ -42,6 +42,7 @@ export class OrientationDetailsComponent implements OnInit { this.orientationService.getOrientation(orientationId).subscribe((orientation) => { this.orientation = orientation; this.acknowledgeNewOrientation(); + this.isOrientationClosed(); this.selectedStatus = this.orientation.status; }); } @@ -66,6 +67,7 @@ export class OrientationDetailsComponent implements OnInit { const sanitizedComment = this.sanitizer.sanitize(SecurityContext.HTML, comment); this.patchOrientation({ status: this.selectedStatus, + action: null, closingComment: sanitizedComment, closingDate: new Date(), modifiedBy: this.userProfile._id, @@ -76,32 +78,20 @@ export class OrientationDetailsComponent implements OnInit { public acknowledgeNewOrientation(): void { if (this.orientation.status === 'new') { - this.patchOrientation({ status: 'waiting', modifiedBy: this.userProfile._id }); + this.patchOrientation({ status: 'waiting', action: 'defineAppointment', modifiedBy: this.userProfile._id }); } } - public editOrientation(): void { - // TODO : edit orientation - if (this.isEditMode) { - // wip test patch - this.patchOrientation({ - // status: 'completed', - processingComment: 'processing comment', - modifiedBy: this.userProfile._id, - }); - } - - this.isEditMode = !this.isEditMode; - } - - public setProcessingComment(comment): void { - // TODO : patch comment - } - get isValidateDisabled(): boolean { + console.log(!this.selectedStatus || !this.commentTextarea?.value?.trim()); return !this.selectedStatus || !this.commentTextarea?.value?.trim(); } + public isOrientationClosed(): void { + const closedStatuses = ['completed', 'uncompleted', 'expired']; + this.isClosed = closedStatuses.includes(this.orientation.status); + } + private patchOrientation(updatedFields): void { this.orientationService.patchOrientation(this.orientation._id, updatedFields).subscribe({ next: (orientation) => {