add table view for collection info page
This commit is contained in:
1 parent
7e493d8866
commit
ec45cd342f
13 files changed
+330
-9
No files matched your search
Whitespace-only changes.
+42
@@ -0,0 +1,42 @@
|
||||
<!-- <div class="movies-container" cdkDropList [cdkDropListData]="entries" (cdkDropListDropped)="drop($any($event))">
|
||||
<ng-container>
|
||||
<app-userCollection-grid-card cdkDrag [entry]="entry" [listId]="listId" (refrechEvent)="refrechEventReceiver()"
|
||||
@animateDestroy>
|
||||
</app-userCollection-grid-card>
|
||||
</ng-container>
|
||||
</div> -->
|
||||
|
||||
<div class="card mt-4">
|
||||
<div class="card-body">
|
||||
<div class="product-table">
|
||||
<div class="table-responsive white-space-nowrap">
|
||||
<table class="table align-middle">
|
||||
<thead class="table-light">
|
||||
<!-- * table head start -->
|
||||
<tr>
|
||||
<th>
|
||||
<input class="form-check-input" type="checkbox">
|
||||
</th>
|
||||
<th>Title</th>
|
||||
<th>Type</th>
|
||||
<th>Genres</th>
|
||||
<th>Rating</th>
|
||||
<th>Released</th>
|
||||
<th>Date Seen</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
<!-- + table head end -->
|
||||
</thead>
|
||||
<tbody cdkDropList [cdkDropListData]="entries" (cdkDropListDropped)="drop($any($event))">
|
||||
<!-- * table body start -->
|
||||
<ng-container *ngFor="let entry of entries">
|
||||
<tr app-collection-table-line cdkDrag [entry]="entry"></tr>
|
||||
<!-- <app-collection-table-line cdkDrag [entry]="entry"></app-collection-table-line> -->
|
||||
</ng-container>
|
||||
<!-- + table body end -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CollectionEntryTableComponent } from './collection-entry-table.component';
|
||||
|
||||
describe('CollectionEntryTableComponent', () => {
|
||||
let component: CollectionEntryTableComponent;
|
||||
let fixture: ComponentFixture<CollectionEntryTableComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [CollectionEntryTableComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(CollectionEntryTableComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Entry } from '../../../../shared/models/entry.model';
|
||||
import {
|
||||
CdkDragDrop,
|
||||
CdkDragEnd,
|
||||
CdkDragStart,
|
||||
moveItemInArray,
|
||||
} from '@angular/cdk/drag-drop';
|
||||
import {
|
||||
animate,
|
||||
state,
|
||||
style,
|
||||
transition,
|
||||
trigger,
|
||||
} from '@angular/animations';
|
||||
|
||||
@Component({
|
||||
selector: 'app-collection-entry-table',
|
||||
templateUrl: './collection-entry-table.component.html',
|
||||
styleUrl: './collection-entry-table.component.css',
|
||||
animations: [
|
||||
trigger('animateDestroy', [
|
||||
state('void', style({ opacity: '0' })),
|
||||
transition('* => void', animate('300ms ease')),
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class CollectionEntryTableComponent {
|
||||
@Input() entries: Entry[] = [];
|
||||
@Input() listId: string = '';
|
||||
|
||||
refrechEventReceiver() {
|
||||
console.log('event recieved');
|
||||
}
|
||||
|
||||
drop(event: CdkDragDrop<any[]>) {
|
||||
moveItemInArray(this.entries, event.previousIndex, event.currentIndex);
|
||||
}
|
||||
|
||||
dragStart(event: CdkDragStart): void {
|
||||
event.source.element.nativeElement.classList.add('custom-dragging-class');
|
||||
}
|
||||
|
||||
dragEnd(event: CdkDragEnd): void {
|
||||
event.source.element.nativeElement.classList.remove(
|
||||
'custom-dragging-class'
|
||||
);
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
+44
@@ -0,0 +1,44 @@
|
||||
<td>
|
||||
<input class="form-check-input" type="checkbox">
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<div class="product-box">
|
||||
<img src="https://picsum.photos/70" width="70" class="rounded-3" alt="">
|
||||
</div>
|
||||
<div class="product-info">
|
||||
<a href="javascript:;" class="product-title">{{entry.title}}</a>
|
||||
<p class="mb-0 product-category" *ngIf="entry.is_tvseries">{{entry.seasons.length}}
|
||||
Season{{entry.seasons.length
|
||||
> 1 ? 's' : ''}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{entry.is_tvseries ? 'Series' : 'Movie'}}</td>
|
||||
<td>
|
||||
<div class="product-tags">
|
||||
<a href="javascript:;" class="btn-tags" *ngFor="let genre of entry.genres">{{genre}}</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="product-rating">
|
||||
<i class="bi bi-star-fill text-warning me-2"></i><span>{{entry.entryRating.tmdb_rating |
|
||||
floatFormat:1}}</span>
|
||||
</div>
|
||||
</td>
|
||||
<!-- <td>
|
||||
<a href="javascript:;">Michle Shoes England</a>
|
||||
</td> -->
|
||||
<td>{{entry.release_date | dateFormat:'MMM dd, yyyy '}}</td>
|
||||
<td>{{entry.date_first_seen | dateFormat:'MMM dd, yyyy '}}</td>
|
||||
<td>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-sm btn-filter dropdown-toggle dropdown-toggle-nocaret" type="button"
|
||||
data-bs-toggle="dropdown">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li (click)="removeEntryFromList()"><a class="dropdown-item">Remove</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CollectionTableLineComponent } from './collection-table-line.component';
|
||||
|
||||
describe('CollectionTableLineComponent', () => {
|
||||
let component: CollectionTableLineComponent;
|
||||
let fixture: ComponentFixture<CollectionTableLineComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [CollectionTableLineComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(CollectionTableLineComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnInit,
|
||||
Output,
|
||||
ViewEncapsulation,
|
||||
} from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { LibraryService } from '../../../../core/services/library.service';
|
||||
import { Entry } from '../../../../shared/models/entry.model';
|
||||
import { trigger, transition, style, animate } from '@angular/animations';
|
||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
||||
|
||||
@Component({
|
||||
selector: 'tr [app-collection-table-line]',
|
||||
templateUrl: './collection-table-line.component.html',
|
||||
styleUrl: './collection-table-line.component.css',
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
animations: [
|
||||
trigger('fadeInOut', [
|
||||
transition(':enter', [
|
||||
style({ opacity: 0 }),
|
||||
animate('0.5s ease-out', style({ opacity: 1 })),
|
||||
]),
|
||||
transition(':leave', [animate('0.5s ease-in', style({ opacity: 0 }))]),
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class CollectionTableLineComponent implements OnInit {
|
||||
@Input() entry!: Entry;
|
||||
@Input() listId: string = '';
|
||||
@Output() refrechEvent = new EventEmitter();
|
||||
|
||||
constructor(
|
||||
private libraryService: LibraryService,
|
||||
private userCollectionService: UserCollectionService,
|
||||
public dialog: MatDialog,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
}
|
||||
|
||||
get releaseYear(): number {
|
||||
return new Date(this.entry.release_date).getFullYear();
|
||||
}
|
||||
|
||||
get formattedRate(): string {
|
||||
return this.entry.entryRating.tmdb_rating.toFixed(1);
|
||||
}
|
||||
|
||||
getTmdbLink() {
|
||||
let type = this.entry.is_tvseries ? 'tv' : 'movie';
|
||||
return `https://www.themoviedb.org/${type}/${this.entry.entryId.tmdb_id}`;
|
||||
}
|
||||
|
||||
getPostPath() {
|
||||
if (this.entry.poster_path == null) return 'https://pic.pnnet.dev/256x256';
|
||||
|
||||
return `https://image.tmdb.org/t/p/w500` + this.entry.poster_path;
|
||||
}
|
||||
|
||||
removeEntryFromList() {
|
||||
const dialogRef = this.dialog.open(ConfirmModalComponent, {
|
||||
width: '400px',
|
||||
data: {
|
||||
title: 'Confirmation',
|
||||
message: `Are you sure you want to remove ${this.entry.title} from this collection?`,
|
||||
type: 'danger',
|
||||
},
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
if (result.confirmed != true) return;
|
||||
|
||||
this.userCollectionService
|
||||
.removeEntryFromCollection(this.listId, this.entry.id)
|
||||
.subscribe({
|
||||
next: (response) => {
|
||||
// TODO confirm notification
|
||||
|
||||
console.log('Entry successfully removed from list.', response);
|
||||
this.entry.id = 0;
|
||||
this.entry.isInLibrary = false;
|
||||
},
|
||||
error: (error) => {
|
||||
// TODO error notification
|
||||
console.error('Error removing entry from list:', error);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ? EVENTS
|
||||
cardClick() {
|
||||
if (this.entry.isInLibrary)
|
||||
this.router.navigate([`/entries/${this.entry.id}`]);
|
||||
}
|
||||
|
||||
// ? EVENT EMITTER
|
||||
emitRefrechEvent() {
|
||||
this.refrechEvent.emit();
|
||||
}
|
||||
}
|
||||
+9
-2
@@ -26,7 +26,7 @@
|
||||
<li>
|
||||
<a class="dropdown-item" href="javascript:;" (click)="openEditModal()">Edit</a>
|
||||
</li>
|
||||
<li><a class="dropdown-item" href="javascript:;" (click)="changeOrder()">Change order</a></li>
|
||||
<li><a class="dropdown-item" href="javascript:;" (click)="switchViewMode()">Switch View</a></li>
|
||||
<li><a class="dropdown-item" href="javascript:;" (click)="deleteCollection()">Delete</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -39,9 +39,16 @@
|
||||
</div>
|
||||
<div *ngIf="collection.description != ''">{{collection.description}}</div>
|
||||
<hr>
|
||||
<div>
|
||||
<!-- ! grid -->
|
||||
<div *ngIf="viewMode == 'grid'">
|
||||
<app-userCollection-entry-grid [entries]="collection.entries"
|
||||
[listId]="getListId()"></app-userCollection-entry-grid>
|
||||
</div>
|
||||
|
||||
<!-- ! table -->
|
||||
<div *ngIf="viewMode == 'table'">
|
||||
<app-collection-entry-table [entries]="collection.entries"
|
||||
[listId]="getListId()"></app-collection-entry-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+8
-4
@@ -19,6 +19,8 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
||||
createdAt: string = '';
|
||||
updatedAt: string = '';
|
||||
|
||||
viewMode: string = 'grid';
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private userCollectionService: UserCollectionService,
|
||||
@@ -65,7 +67,7 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
||||
|
||||
// Check if the date is invalid
|
||||
if (isNaN(modifiedDate.getTime())) {
|
||||
console.error('Invalid date:', updatedAt);
|
||||
// console.error('Invalid date:', updatedAt);
|
||||
// Handle invalid date, perhaps return a fallback message or undefined
|
||||
return 'Date not available';
|
||||
}
|
||||
@@ -109,7 +111,6 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
if (result.formData == null) return;
|
||||
@@ -120,7 +121,7 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
||||
next: (userCollection) => {
|
||||
if (userCollection) {
|
||||
// TODO confirm notification
|
||||
console.log(`User Collection updated: `, userCollection);
|
||||
// console.log(`User Collection updated: `, userCollection);
|
||||
this.collection = userCollection;
|
||||
}
|
||||
},
|
||||
@@ -133,7 +134,10 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
changeOrder() {}
|
||||
switchViewMode() {
|
||||
this.viewMode = this.viewMode == 'grid' ? 'table' : 'grid';
|
||||
}
|
||||
|
||||
deleteCollection() {
|
||||
if (!this.collection) return;
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ import { UserCollectionGridCardComponent } from './user-collection-info/userColl
|
||||
import { UserCollectionInfoPageComponent } from './user-collection-info/userCollection-info-page/userCollection-info-page.component';
|
||||
import { UserCollectionsModalComponent } from '../../shared/components/modals/list-selection-modal/user-collections-modal.component';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { CollectionEntryTableComponent } from './user-collection-info/collection-entry-table/collection-entry-table.component';
|
||||
import { CollectionTableLineComponent } from './user-collection-info/collection-table-line/collection-table-line.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -32,8 +34,14 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
|
||||
// collection info page
|
||||
UserCollectionInfoPageComponent,
|
||||
|
||||
UserCollectionEntryGridComponent,
|
||||
UserCollectionGridCardComponent,
|
||||
|
||||
CollectionEntryTableComponent,
|
||||
CollectionTableLineComponent,
|
||||
|
||||
|
||||
UserCollectionsModalComponent,
|
||||
],
|
||||
exports: [],
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ export class UserCollectionsPageComponent implements OnInit {
|
||||
getCollections() {
|
||||
this.collectionsService.getCollections().subscribe({
|
||||
next: (l) => {
|
||||
console.log(`Loaded ${l.length} lists.`);
|
||||
// console.log(`Loaded ${l.length} lists.`);
|
||||
this.collections = l;
|
||||
this.collectionsToShow = this.collections;
|
||||
this.applyFilter();
|
||||
|
||||
Reference in new issue
Block a user