various changes
This commit is contained in:
1 parent
cd4514fd2d
commit
2f27c4cfdf
8 files changed
+20
-129
No files matched your search
@@ -4,7 +4,7 @@ import { BrowserModule } from '@angular/platform-browser';
|
|||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { EntryListComponent } from './features/lists/entry-list/entry-list.component';
|
import { EntryListComponent } from './features/lists/entry-list/entry-list.component';
|
||||||
import { HomeComponent } from './features/pages/home/home.component';
|
import { HomeComponent } from './features/pages/home/home.component';
|
||||||
import { SidebarComponent } from './core/components/sidebar/sidebar.component';
|
import { SidebarComponent } from './core/components/sidebar/sidebar.component';
|
||||||
@@ -16,7 +16,7 @@ import { MainCardComponent } from './features/cards/main-card/main-card.componen
|
|||||||
import { DynamicEntryListComponent } from './features/lists/dynamic-entry-list/dynamic-entry-list.component';
|
import { DynamicEntryListComponent } from './features/lists/dynamic-entry-list/dynamic-entry-list.component';
|
||||||
import { LibraryComponent } from './features/pages/library/library.component';
|
import { LibraryComponent } from './features/pages/library/library.component';
|
||||||
import { CoreModule } from './core/core.module';
|
import { CoreModule } from './core/core.module';
|
||||||
import { ListSelectionModalComponent } from './list-selection-modal/list-selection-modal.component';
|
import { ListSelectionModalComponent } from './features/modals/list-selection-modal/list-selection-modal.component';
|
||||||
|
|
||||||
import { MatDialogModule } from '@angular/material/dialog';
|
import { MatDialogModule } from '@angular/material/dialog';
|
||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
@@ -29,6 +29,7 @@ import { ListsComponent } from './features/pages/lists/lists.component';
|
|||||||
import { UserListItemComponent } from './features/cards/user-list-item/user-list-item.component';
|
import { UserListItemComponent } from './features/cards/user-list-item/user-list-item.component';
|
||||||
import { UserListItemCardComponent } from './features/cards/user-list-item-card/user-list-item-card.component';
|
import { UserListItemCardComponent } from './features/cards/user-list-item-card/user-list-item-card.component';
|
||||||
import { DateFormatPipe } from './core/pipes/date-format/date-format.pipe';
|
import { DateFormatPipe } from './core/pipes/date-format/date-format.pipe';
|
||||||
|
import { SharedModule } from './shared/shared.module';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@@ -50,11 +51,14 @@ import { DateFormatPipe } from './core/pipes/date-format/date-format.pipe';
|
|||||||
DateFormatPipe,
|
DateFormatPipe,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
|
CoreModule,
|
||||||
|
SharedModule,
|
||||||
|
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
CoreModule ,
|
FormsModule,
|
||||||
|
|
||||||
MatDialogModule,
|
MatDialogModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { ListService } from '../../../core/services/list.service';
|
|||||||
export class ListsComponent implements OnInit {
|
export class ListsComponent implements OnInit {
|
||||||
searchControl = new FormControl('');
|
searchControl = new FormControl('');
|
||||||
showAddButton: boolean = false;
|
showAddButton: boolean = false;
|
||||||
|
listsCount: number = 0;
|
||||||
|
|
||||||
lists: List[] = [];
|
lists: List[] = [];
|
||||||
listsToShow: List[] = [];
|
listsToShow: List[] = [];
|
||||||
@@ -27,8 +28,8 @@ export class ListsComponent implements OnInit {
|
|||||||
getLists() {
|
getLists() {
|
||||||
this.listService.getLists().subscribe({
|
this.listService.getLists().subscribe({
|
||||||
next: (l) => {
|
next: (l) => {
|
||||||
|
console.log(`Loaded ${l.length} lists.`);
|
||||||
this.lists = l;
|
this.lists = l;
|
||||||
console.log(this.lists);
|
|
||||||
this.listsToShow = this.lists;
|
this.listsToShow = this.lists;
|
||||||
this.applyFilter();
|
this.applyFilter();
|
||||||
},
|
},
|
||||||
@@ -50,6 +51,7 @@ export class ListsComponent implements OnInit {
|
|||||||
this.listsToShow = this.lists.filter((collection) =>
|
this.listsToShow = this.lists.filter((collection) =>
|
||||||
collection.name.toLowerCase().trim().includes(normalizedFilter)
|
collection.name.toLowerCase().trim().includes(normalizedFilter)
|
||||||
);
|
);
|
||||||
|
this.listsCount = this.listsToShow.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
createList() {
|
createList() {
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
mat-form-field {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<h2 mat-dialog-title>Choose a list</h2>
|
|
||||||
<mat-dialog-content>
|
|
||||||
<mat-form-field appearance="fill">
|
|
||||||
<mat-label>List Name</mat-label>
|
|
||||||
<input [formControl]="searchControl" matInput>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-dialog-actions align="center" *ngIf="doShowAddButton()">
|
|
||||||
<button mat-button (click)="createList()" *ngIf="doShowAddButton()">Create List</button>
|
|
||||||
</mat-dialog-actions>
|
|
||||||
<mat-selection-list #shoes>
|
|
||||||
<mat-list-option *ngFor="let list of listsToShow" [value]="list">
|
|
||||||
{{list.name}}
|
|
||||||
</mat-list-option>
|
|
||||||
</mat-selection-list>
|
|
||||||
</mat-dialog-content>
|
|
||||||
<mat-dialog-actions align="end">
|
|
||||||
<button mat-button [mat-dialog-close]="true">OK</button>
|
|
||||||
<button mat-button mat-dialog-close>Cancel</button>
|
|
||||||
</mat-dialog-actions>
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { ListSelectionModalComponent } from './list-selection-modal.component';
|
|
||||||
|
|
||||||
describe('ListSelectionModalComponent', () => {
|
|
||||||
let component: ListSelectionModalComponent;
|
|
||||||
let fixture: ComponentFixture<ListSelectionModalComponent>;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ListSelectionModalComponent]
|
|
||||||
});
|
|
||||||
fixture = TestBed.createComponent(ListSelectionModalComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
import { Component, Inject, OnInit } from '@angular/core';
|
|
||||||
import { FormControl } from '@angular/forms';
|
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
||||||
import { ListService } from '../core/services/list.service';
|
|
||||||
import { List } from '../shared/models/list.model';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-list-selection-modal',
|
|
||||||
templateUrl: './list-selection-modal.component.html',
|
|
||||||
styleUrls: ['./list-selection-modal.component.css'],
|
|
||||||
})
|
|
||||||
export class ListSelectionModalComponent implements OnInit {
|
|
||||||
searchControl = new FormControl('');
|
|
||||||
showAddButton: boolean = false;
|
|
||||||
|
|
||||||
lists: List[] = [];
|
|
||||||
listsToShow: List[] = [];
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
public dialogRef: MatDialogRef<ListSelectionModalComponent>,
|
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
|
||||||
private listService: ListService
|
|
||||||
) {}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.getLists();
|
|
||||||
|
|
||||||
this.searchControl.valueChanges.subscribe((value) => {
|
|
||||||
this.applyFilter(value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getLists() {
|
|
||||||
this.listService.getLists().subscribe({
|
|
||||||
next: (l) => {
|
|
||||||
this.lists = l;
|
|
||||||
this.listsToShow = this.lists;
|
|
||||||
this.applyFilter(this.searchControl.value);
|
|
||||||
|
|
||||||
},
|
|
||||||
error: (error) => {
|
|
||||||
console.log("Counldn't get lists from backend.");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
applyFilter(filterValue: string | null) {
|
|
||||||
if (filterValue == null) {
|
|
||||||
this.listsToShow = [...this.lists]; // Show all lists if filter is cleared or null
|
|
||||||
this.showAddButton = false; // Assuming you want to hide the button when there's no filter
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalizedFilter = filterValue.toLowerCase().trim();
|
|
||||||
|
|
||||||
this.listsToShow = this.lists.filter((collection) =>
|
|
||||||
collection.name.toLowerCase().trim().includes(normalizedFilter)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.showAddButton = this.listsToShow.length === 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
createList() {
|
|
||||||
const listName = this.searchControl.value; // string
|
|
||||||
|
|
||||||
let myNewList = { name: listName } as List;
|
|
||||||
|
|
||||||
this.listService.createList(myNewList).subscribe(async (list) => {
|
|
||||||
await this.getLists();
|
|
||||||
console.log(this.searchControl.value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
doShowAddButton(): boolean {
|
|
||||||
return this.showAddButton;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { ListEntry } from './listEntry.model';
|
||||||
|
|
||||||
export interface List {
|
export interface List {
|
||||||
id: number;
|
id: number;
|
||||||
|
|
||||||
@@ -7,6 +9,10 @@ export interface List {
|
|||||||
|
|
||||||
poster_path: string;
|
poster_path: string;
|
||||||
|
|
||||||
|
listEntries: ListEntry[];
|
||||||
|
changed: boolean;
|
||||||
|
isChecked: boolean;
|
||||||
|
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
modifiedAt: Date;
|
modifiedAt: Date;
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { NotificationPopupComponent } from './notification-popup/notification-popup.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [],
|
declarations: [NotificationPopupComponent],
|
||||||
imports: [
|
imports: [CommonModule],
|
||||||
CommonModule, // Common module for common directives
|
exports: [NotificationPopupComponent],
|
||||||
],
|
|
||||||
exports: [],
|
|
||||||
})
|
})
|
||||||
export class SharedModule {}
|
export class SharedModule {}
|
||||||
Reference in new issue
Block a user