From 3ea844d3fdc31ad5ea90fadd3df78feecdb1c163 Mon Sep 17 00:00:00 2001 From: Mohammed Abad Date: Tue, 2 Apr 2024 01:19:24 +0000 Subject: [PATCH] Implemented add to list into main card component --- .../cards/main-card/main-card.component.html | 4 +-- .../cards/main-card/main-card.component.ts | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/features/cards/main-card/main-card.component.html b/frontend/src/app/features/cards/main-card/main-card.component.html index da4c238..ce2f10f 100644 --- a/frontend/src/app/features/cards/main-card/main-card.component.html +++ b/frontend/src/app/features/cards/main-card/main-card.component.html @@ -15,8 +15,8 @@ -
- +
+
diff --git a/frontend/src/app/features/cards/main-card/main-card.component.ts b/frontend/src/app/features/cards/main-card/main-card.component.ts index f5eb9c4..7ba96a1 100644 --- a/frontend/src/app/features/cards/main-card/main-card.component.ts +++ b/frontend/src/app/features/cards/main-card/main-card.component.ts @@ -2,6 +2,8 @@ import { Component, Input, OnInit } from '@angular/core'; import { Entry } from '../../../shared/models/entry.model'; import { EntryService } from '../../../core/services/entry.service'; import { LibraryService } from '../../../core/services/library.service'; +import { ListSelectionModalComponent } from '../../../list-selection-modal/list-selection-modal.component'; +import { MatDialog } from '@angular/material/dialog'; @Component({ selector: 'app-main-card', @@ -11,7 +13,10 @@ import { LibraryService } from '../../../core/services/library.service'; export class MainCardComponent implements OnInit { @Input() entry!: Entry; - constructor(private libraryService: LibraryService) {} + constructor( + private libraryService: LibraryService, + public dialog: MatDialog + ) {} ngOnInit(): void { this.libraryService.isInLibrary(this.entry.entryId.tmdb_id).subscribe({ @@ -21,6 +26,7 @@ export class MainCardComponent implements OnInit { this.entry = e; } }, + error: (error) => {}, }); } @@ -39,7 +45,7 @@ export class MainCardComponent implements OnInit { if (entry != null) { entry.isInLibrary = true; this.entry = entry; - console.log(entry); + this.libraryService.getAllEntries(true); } }, error: (error) => { @@ -68,5 +74,22 @@ export class MainCardComponent implements OnInit { logEntry() { console.log(this.entry); } - openInfo() {} + + showAddToListModal() { + if (this.entry) { + console.log("entry exist"); + const dialogRef = this.dialog.open(ListSelectionModalComponent, { + width: '500px', + height: '300px', + data: { + /* données que vous pourriez vouloir passer */ + }, + }); + + dialogRef.afterClosed().subscribe((result) => { + console.log('Le dialogue a été fermé', result); + // Traitez le résultat ici (par exemple, ajoutez la sélection à une liste) + }); + } + } }