Skip to content
Snippets Groups Projects
Commit c31ba2b4 authored by Marlène SIMONDANT's avatar Marlène SIMONDANT
Browse files

Detail

parent f7c46b93
No related branches found
No related tags found
2 merge requests!993Notif,!983feat(dashboard) : create dashboard !
...@@ -11,20 +11,26 @@ ...@@ -11,20 +11,26 @@
> >
</h1> </h1>
<div class="date inline"> <div class="date inline">
<app-svg-icon [icon]="'clock'" [folder]="'ico'" [iconClass]="'icon-12'" /> <app-svg-icon *ngIf="from === 'todoOrientations'" [icon]="'clock'" [folder]="'ico'" [iconClass]="'icon-12'" />
Il y a {{ this.orientationService.daysAgo(orientation.createdAt) }} jour(s) Il y a {{ this.orientationService.daysAgo(orientation.createdAt) }} jour(s)
</div> </div>
</div> </div>
<!--app-button class="hide-on-mobile" [label]="'Clôturer'" [variant]="'primaryBlack'" (action)="showModal()" /-->
<app-button <app-button
*ngIf="!isEditMode" *ngIf="from === 'todoOrientations'"
class="hide-on-mobile"
[label]="'Clôturer'"
[variant]="'primaryBlack'"
(action)="showModal()"
/>
<app-button
*ngIf="!isEditMode && from === 'todoOrientations'"
class="hide-on-mobile" class="hide-on-mobile"
[label]="'Modifier'" [label]="'Modifier'"
[variant]="'secondary'" [variant]="'secondary'"
(action)="editOrientation()" (action)="editOrientation()"
/> />
<app-button <app-button
*ngIf="isEditMode" *ngIf="isEditMode && from === 'todoOrientations'"
class="hide-on-mobile" class="hide-on-mobile"
[label]="'Enregistrer'" [label]="'Enregistrer'"
[variant]="'primary'" [variant]="'primary'"
...@@ -36,16 +42,21 @@ ...@@ -36,16 +42,21 @@
<section> <section>
<span class="secondary-header"> <span class="secondary-header">
<h2>Traitement</h2> <h2>Traitement</h2>
<!--app-button class="hide-on-desktop" [label]="'Clôturer'" [variant]="'primaryBlack'" (action)="showModal()" /--> <!--app-button
*ngIf="from === 'todoOrientations'"
class="hide-on-desktop"
[label]="'Clôturer'"
[variant]="'primaryBlack'"
(action)="showModal()" /-->
<app-button <app-button
*ngIf="!isEditMode" *ngIf="!isEditMode && from === 'todoOrientations'"
class="hide-on-desktop" class="hide-on-desktop"
[label]="'Modifier'" [label]="'Modifier'"
[variant]="'secondary'" [variant]="'secondary'"
(action)="editOrientation()" (action)="editOrientation()"
/> />
<app-button <app-button
*ngIf="isEditMode" *ngIf="isEditMode && from === 'todoOrientations'"
class="hide-on-desktop" class="hide-on-desktop"
[label]="'Modifier'" [label]="'Modifier'"
[variant]="'primary'" [variant]="'primary'"
...@@ -97,10 +108,13 @@ ...@@ -97,10 +108,13 @@
<ng-container *ngIf="orientation.accompanimentType !== 'onlineMediation'"> <ng-container *ngIf="orientation.accompanimentType !== 'onlineMediation'">
<div class="inline"> <div class="inline">
<app-svg-icon [iconClass]="'icon-20'" [folder]="'tags'" [icon]="'calendarBlue'" /> <app-svg-icon [iconClass]="'icon-20'" [folder]="'tags'" [icon]="'calendarBlue'" />
<p> <div class="datePickerContainer">
<span class="category-name">Date de RDV :</span> <span class="category-name">Date de RDV :</span>
TODO : date + datepicker <span class="datePicker">
</p> <label for="date">Date:</label>
<input type="date" id="date" name="date" />
</span>
</div>
</div> </div>
<div class="inline"> <div class="inline">
...@@ -146,9 +160,17 @@ ...@@ -146,9 +160,17 @@
<p class="inline"> <p class="inline">
<span class="category-name">Traité par : </span> <span class="category-name">Traité par : </span>
<app-tag-item <app-tag-item
[label]="'Jean-Paul Machin'" *ngIf="orientation.modifiedBy"
class="hide-on-mobile"
[ariaLabel]="
'Accompagnant souhaité : ' +
orientation.modifiedBy.name +
' ' +
(orientation.modifiedBy.surname | uppercase)
"
[label]="orientation.modifiedBy.name + ' ' + orientation.modifiedBy.surname.toUpperCase()"
[iconFolder]="'avatar'" [iconFolder]="'avatar'"
[iconName]="'avatar1'" [iconName]="orientation.modifiedBy.avatar || 'avatar1'"
[type]="'entity light'" [type]="'entity light'"
/> />
</p> </p>
...@@ -267,6 +289,7 @@ ...@@ -267,6 +289,7 @@
*ngIf="orientation" *ngIf="orientation"
[opened]="isModalOpenned" [opened]="isModalOpenned"
[title]="'Clôturer un accompagnement'" [title]="'Clôturer un accompagnement'"
[validateDisabled]="isValidateDisabled"
(closed)="closeOrientation($event)" (closed)="closeOrientation($event)"
> >
<div class="modalContent emphasized"> <div class="modalContent emphasized">
...@@ -275,17 +298,19 @@ ...@@ -275,17 +298,19 @@
<div class="modalForm"> <div class="modalForm">
<div class="subtitle">Statut de l'accompagnement :</div> <div class="subtitle">Statut de l'accompagnement :</div>
<div class="inline"> <div class="inline">
<input id="finished" type="radio" name="status" value="finished" /> {{ orientation.status }}
<label for="finished">Terminé</label> <input id="completed" type="radio" name="status" value="completed" [(ngModel)]="selectedStatus" />
<label for="completed">Terminé</label>
</div> </div>
<div class="inline"> <div class="inline">
<input type="radio" name="status" value="notDone" /> {{ orientation.status }}
<label for="notDone">Non réalisé</label> <input id="uncompleted" type="radio" name="status" value="uncompleted" [(ngModel)]="selectedStatus" />
<label for="uncompleted">Non réalisé</label>
</div> </div>
<div> <div>
<label for="comment">Commentaires <span class="optional">(facultatifs)</span></label> <label for="comment">Commentaires <span class="optional">(facultatifs)</span></label>
<app-textarea id="comment" /> <app-textarea #comment id="comment" [value]="orientation.closingComment" />
</div> </div>
</div> </div>
</app-modal> </app-modal>
...@@ -108,6 +108,20 @@ ...@@ -108,6 +108,20 @@
color: $grey-4-5-1; color: $grey-4-5-1;
} }
.datePickerContainer {
display: flex;
align-items: center;
.datePicker {
display: inline-grid;
input {
margin-top: 8px;
width: 250px;
height: 32px;
padding: 8px;
}
}
}
.pipe { .pipe {
color: $grey-7; color: $grey-7;
padding: 8px; padding: 8px;
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, SecurityContext, ViewChild } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { User } from '../../../models/user.model'; import { User } from '../../../models/user.model';
import { NotificationService } from '../../../services/notification.service'; import { NotificationService } from '../../../services/notification.service';
import { OrientationService } from '../../../services/orientation.service'; import { OrientationService } from '../../../services/orientation.service';
import { TextareaComponent } from '../../../shared/components/textarea/textarea.component';
import { ProfileService } from '../../services/profile.service'; import { ProfileService } from '../../services/profile.service';
@Component({ @Component({
...@@ -16,13 +18,18 @@ export class OrientationDetailsComponent implements OnInit { ...@@ -16,13 +18,18 @@ export class OrientationDetailsComponent implements OnInit {
public orientationService: OrientationService, public orientationService: OrientationService,
private notificationService: NotificationService, private notificationService: NotificationService,
private profileService: ProfileService, private profileService: ProfileService,
private sanitizer: DomSanitizer,
) {} ) {}
@ViewChild('comment', { static: false }) commentTextarea: TextareaComponent;
public orientation; public orientation;
public isModalOpenned = false; public isModalOpenned = false;
public userProfile: User; public userProfile: User;
public isEditMode = false; public isEditMode = false;
public from: string; public from: string;
public closingComment = '';
public selectedStatus = '';
ngOnInit(): void { ngOnInit(): void {
this.route.queryParams.subscribe((params) => { this.route.queryParams.subscribe((params) => {
...@@ -34,9 +41,12 @@ export class OrientationDetailsComponent implements OnInit { ...@@ -34,9 +41,12 @@ export class OrientationDetailsComponent implements OnInit {
if (orientationId) { if (orientationId) {
this.orientationService.getOrientation(orientationId).subscribe((orientation) => { this.orientationService.getOrientation(orientationId).subscribe((orientation) => {
this.orientation = orientation; this.orientation = orientation;
this.acknowledgeNewOrientation();
this.selectedStatus = this.orientation.status;
}); });
} }
}); });
this.profileService.getProfile().then((profile) => { this.profileService.getProfile().then((profile) => {
this.userProfile = new User(profile); this.userProfile = new User(profile);
}); });
...@@ -52,11 +62,11 @@ export class OrientationDetailsComponent implements OnInit { ...@@ -52,11 +62,11 @@ export class OrientationDetailsComponent implements OnInit {
public closeOrientation(event): void { public closeOrientation(event): void {
if (event) { if (event) {
// close orientation const comment = this.commentTextarea?.value || '';
// wip test patch const sanitizedComment = this.sanitizer.sanitize(SecurityContext.HTML, comment);
this.patchOrientation({ this.patchOrientation({
status: 'completed', status: this.selectedStatus,
closingComment: 'closing comment', closingComment: sanitizedComment,
closingDate: new Date(), closingDate: new Date(),
modifiedBy: this.userProfile._id, modifiedBy: this.userProfile._id,
}); });
...@@ -64,8 +74,13 @@ export class OrientationDetailsComponent implements OnInit { ...@@ -64,8 +74,13 @@ export class OrientationDetailsComponent implements OnInit {
this.isModalOpenned = false; this.isModalOpenned = false;
} }
public setOrientationStatus(status): void { public acknowledgeNewOrientation(): void {
// TODO : patch status if (this.orientation.status === 'new') {
this.patchOrientation({
status: 'acknowledged',
modifiedBy: this.userProfile._id,
});
}
} }
public editOrientation(): void { public editOrientation(): void {
...@@ -86,6 +101,10 @@ export class OrientationDetailsComponent implements OnInit { ...@@ -86,6 +101,10 @@ export class OrientationDetailsComponent implements OnInit {
// TODO : patch comment // TODO : patch comment
} }
get isValidateDisabled(): boolean {
return !this.selectedStatus || !this.commentTextarea?.value?.trim();
}
private patchOrientation(updatedFields): void { private patchOrientation(updatedFields): void {
this.orientationService.patchOrientation(this.orientation._id, updatedFields).subscribe({ this.orientationService.patchOrientation(this.orientation._id, updatedFields).subscribe({
next: (orientation) => { next: (orientation) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment