add table view for collection info page

This commit is contained in:
X4Lo committed 2024-05-17 18:09:05 +01:00
1 parent 7e493d8866
commit ec45cd342f
13 files changed
+330 -9

No files matched your search

@@ -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>
@@ -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;