diff --git a/frontend/src/app/features/entry/entries.module.ts b/frontend/src/app/features/entry/entries.module.ts index 4fedc00..328cf1f 100644 --- a/frontend/src/app/features/entry/entries.module.ts +++ b/frontend/src/app/features/entry/entries.module.ts @@ -4,13 +4,14 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { EntryPageComponent } from './entry-page/entry-page.component'; import { EntriesRoutingModule } from './entries-routing.module'; import { CommonModule } from '@angular/common'; +import { SeasonMainCardComponent } from './season-main-card/season-main-card.component'; @NgModule({ - declarations: [EntryPageComponent], + declarations: [EntryPageComponent, SeasonMainCardComponent], imports: [ CommonModule, SharedModule, - + FormsModule, ReactiveFormsModule, EntriesRoutingModule, diff --git a/frontend/src/app/shared/cards/season-main-card/season-main-card.component.css b/frontend/src/app/features/entry/season-main-card/season-main-card.component.css similarity index 100% rename from frontend/src/app/shared/cards/season-main-card/season-main-card.component.css rename to frontend/src/app/features/entry/season-main-card/season-main-card.component.css diff --git a/frontend/src/app/shared/cards/season-main-card/season-main-card.component.html b/frontend/src/app/features/entry/season-main-card/season-main-card.component.html similarity index 72% rename from frontend/src/app/shared/cards/season-main-card/season-main-card.component.html rename to frontend/src/app/features/entry/season-main-card/season-main-card.component.html index 2006fc0..ed3a45f 100644 --- a/frontend/src/app/shared/cards/season-main-card/season-main-card.component.html +++ b/frontend/src/app/features/entry/season-main-card/season-main-card.component.html @@ -1,5 +1,3 @@ - -
Episode poster
@@ -11,7 +9,7 @@
-
+
{{episodesWatchedCount}}/{{this.season.episode_count}}
-
-
\ No newline at end of file diff --git a/frontend/src/app/shared/cards/season-main-card/season-main-card.component.spec.ts b/frontend/src/app/features/entry/season-main-card/season-main-card.component.spec.ts similarity index 100% rename from frontend/src/app/shared/cards/season-main-card/season-main-card.component.spec.ts rename to frontend/src/app/features/entry/season-main-card/season-main-card.component.spec.ts diff --git a/frontend/src/app/shared/cards/season-main-card/season-main-card.component.ts b/frontend/src/app/features/entry/season-main-card/season-main-card.component.ts similarity index 95% rename from frontend/src/app/shared/cards/season-main-card/season-main-card.component.ts rename to frontend/src/app/features/entry/season-main-card/season-main-card.component.ts index 208d110..fe7fdfd 100644 --- a/frontend/src/app/shared/cards/season-main-card/season-main-card.component.ts +++ b/frontend/src/app/features/entry/season-main-card/season-main-card.component.ts @@ -1,5 +1,5 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { Season } from '../../models/season.model'; +import { Season } from '../../../shared/models/season.model'; import { SeasonService } from '../../../core/services/season.service'; import { trigger, @@ -8,10 +8,10 @@ import { transition, animate, } from '@angular/animations'; -import { Episode } from '../../models/episode.models'; +import { Episode } from '../../../shared/models/episode.models'; import { EpisodeSeenService } from '../../../core/services/episode-seen.service'; import { MatDialog } from '@angular/material/dialog'; -import { SeenModalComponent } from '../../components/modals/seen-modal/seen-modal.component'; +import { SeenModalComponent } from '../../../shared/components/modals/seen-modal/seen-modal.component'; @Component({ selector: 'app-season-main-card', diff --git a/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.css b/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.css new file mode 100644 index 0000000..e69de29 diff --git a/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.html b/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.html new file mode 100644 index 0000000..570279a --- /dev/null +++ b/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.html @@ -0,0 +1,19 @@ +
+ +
+
+
+

{{message}}

+
+
+
+ + +
+
+
+
+
\ No newline at end of file diff --git a/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.spec.ts b/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.spec.ts new file mode 100644 index 0000000..7c19553 --- /dev/null +++ b/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ConfirmModalComponent } from './confirm-modal.component'; + +describe('ConfirmModalComponent', () => { + let component: ConfirmModalComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ConfirmModalComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ConfirmModalComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.ts b/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.ts new file mode 100644 index 0000000..acebd4f --- /dev/null +++ b/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.ts @@ -0,0 +1,34 @@ +import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { FormBuilder } from '@angular/forms'; + +@Component({ + selector: 'app-confirm-modal', + templateUrl: './confirm-modal.component.html', + styleUrl: './confirm-modal.component.css', +}) +export class ConfirmModalComponent implements OnInit { + title: string = 'Confirm your action'; + message: string = 'Are you sure?'; + type: string = 'dangger'; + + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) {} + + ngOnInit() { + if (this.data == null) return; + this.title = this.data.title; + this.message = this.data.message; + this.type = this.data.type; + } + + onConfirm(): void { + this.dialogRef.close({ confirmed: true }); + } + + onClose(): void { + this.dialogRef.close(); + } +} diff --git a/frontend/src/app/shared/pipes/float-format/float-format.pipe.spec.ts b/frontend/src/app/shared/pipes/float-format/float-format.pipe.spec.ts new file mode 100644 index 0000000..03d1173 --- /dev/null +++ b/frontend/src/app/shared/pipes/float-format/float-format.pipe.spec.ts @@ -0,0 +1,8 @@ +import { FloatFormatPipe } from './float-format.pipe'; + +describe('FloatFormatPipe', () => { + it('create an instance', () => { + const pipe = new FloatFormatPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/shared/pipes/float-format/float-format.pipe.ts b/frontend/src/app/shared/pipes/float-format/float-format.pipe.ts new file mode 100644 index 0000000..924221c --- /dev/null +++ b/frontend/src/app/shared/pipes/float-format/float-format.pipe.ts @@ -0,0 +1,12 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'floatFormat', +}) +export class FloatFormatPipe implements PipeTransform { + transform(value: number, toFixed: number): unknown { + if (!value) return 0; + + return value.toFixed(toFixed); + } +} diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.ts index 906ae03..5ffdfc6 100644 --- a/frontend/src/app/shared/shared.module.ts +++ b/frontend/src/app/shared/shared.module.ts @@ -1,11 +1,10 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -// * cards -import { SeasonMainCardComponent } from './cards/season-main-card/season-main-card.component'; // * modals import { SeenModalComponent } from './components/modals/seen-modal/seen-modal.component'; +import { ConfirmModalComponent } from './components/modals/confirm-modal/confirm-modal.component'; // * pipes import { DateFormatPipe } from './pipes/date-format/date-format.pipe'; @@ -14,46 +13,38 @@ import { DateFormatPipe } from './pipes/date-format/date-format.pipe'; import { RatingModule } from 'ngx-bootstrap/rating'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { CollectionEditModalComponent } from '../features/collections/user-collection-info/collection-edit-modal/collection-edit-modal.component'; +import { FloatFormatPipe } from './pipes/float-format/float-format.pipe'; @NgModule({ imports: [ CommonModule, - + FormsModule, ReactiveFormsModule, - + RatingModule.forRoot(), ], declarations: [ // * pipes DateFormatPipe, + FloatFormatPipe, // ? components - SeasonMainCardComponent, SeenModalComponent, - CollectionEditModalComponent + CollectionEditModalComponent, + ConfirmModalComponent, - // ? other imported components - - // NotificationPopupComponent, - // MainCardComponent, - // DynamicEntryListComponent, - // NotificationPopupComponent, - // ListSelectionModalComponent, - - // ? modules ], exports: [ // * pipes DateFormatPipe, + FloatFormatPipe, FormsModule, ReactiveFormsModule, - //NotificationPopupComponent, - SeasonMainCardComponent, SeenModalComponent, - + ConfirmModalComponent, RatingModule, ], })