amelioration du style de la partie user

This commit is contained in:
MiharyR 2021-11-21 12:56:11 +01:00
parent 3dce1f6865
commit 7c24996e73
18 changed files with 137 additions and 148 deletions

View file

@ -0,0 +1,95 @@
import {Component, Inject, OnInit} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {MessageService} from "../../../utils/services/message/message.service";
import {PlaylistDB} from "../../../utils/interfaces/playlist";
@Component({
selector: 'app-popup-create-playlist',
templateUrl: './popup-create-playlist.component.html',
styleUrls: ['./popup-create-playlist.component.scss']
})
export class PopupCreatePlaylistComponent implements OnInit
{
name: string = "" ;
hasError: boolean = false;
tabNomPlaylist: string[] = [];
errorMessage: string = "" ;
constructor( public dialogRef: MatDialogRef<PopupCreatePlaylistComponent>,
@Inject(MAT_DIALOG_DATA) public data,
private messageService: MessageService) { }
ngOnInit(): void
{
this.tabNomPlaylist = this.data.map( playlist0 => playlist0.name );
}
onValider(): void
{
// --- FAUX CODE ---
//
this.checkError();
if(!this.hasError)
{
const playlist: PlaylistDB = {
_id: "",
userId: "userId",
name: this.name,
videoIds: [],
isActive: true,
createdAt: new Date(),
updatedAt: new Date(),
};
this.dialogRef.close(playlist);
}
// --- VRAI CODE ---
/*
this.checkError();
if(!this.hasError)
{
this.messageService
.sendMessage("user/create/playlist", {title: this.data.title})
.subscribe(retour => {
if (retour.status === "error") {
console.log(retour);
this.dialogRef.close(null);
} else {
this.dialogRef.close(retour.data.playlist);
}
});
}
*/
}
checkError(): void
{
if(this.name === "") {
this.errorMessage = "Le nom ne peut pas être vide" ;
this.hasError = true;
}
else if(this.tabNomPlaylist.includes(this.name)){
this.errorMessage = "Ce nom est déjà utilisé" ;
this.hasError = true;
}
else {
this.hasError = false;
this.errorMessage = "" ;
}
console.log("em:" + this.errorMessage);
}
onAnnuler(): void
{
this.dialogRef.close(null);
}
}