various changes
This commit is contained in:
1 parent
cd4514fd2d
commit
2f27c4cfdf
8 files changed
+21
-130
No files matched your search
@@ -4,7 +4,7 @@ import { BrowserModule } from '@angular/platform-browser';
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { AppComponent } from './app.component';
|
||||
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 { HomeComponent } from './features/pages/home/home.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 { LibraryComponent } from './features/pages/library/library.component';
|
||||
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 { 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 { UserListItemCardComponent } from './features/cards/user-list-item-card/user-list-item-card.component';
|
||||
import { DateFormatPipe } from './core/pipes/date-format/date-format.pipe';
|
||||
import { SharedModule } from './shared/shared.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@@ -50,12 +51,15 @@ import { DateFormatPipe } from './core/pipes/date-format/date-format.pipe';
|
||||
DateFormatPipe,
|
||||
],
|
||||
imports: [
|
||||
CoreModule,
|
||||
SharedModule,
|
||||
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
HttpClientModule,
|
||||
ReactiveFormsModule,
|
||||
CoreModule ,
|
||||
|
||||
FormsModule,
|
||||
|
||||
MatDialogModule,
|
||||
MatInputModule,
|
||||
MatButtonModule,
|
||||
|
||||
@@ -11,6 +11,7 @@ import { ListService } from '../../../core/services/list.service';
|
||||
export class ListsComponent implements OnInit {
|
||||
searchControl = new FormControl('');
|
||||
showAddButton: boolean = false;
|
||||
listsCount: number = 0;
|
||||
|
||||
lists: List[] = [];
|
||||
listsToShow: List[] = [];
|
||||
@@ -27,8 +28,8 @@ export class ListsComponent implements OnInit {
|
||||
getLists() {
|
||||
this.listService.getLists().subscribe({
|
||||
next: (l) => {
|
||||
console.log(`Loaded ${l.length} lists.`);
|
||||
this.lists = l;
|
||||
console.log(this.lists);
|
||||
this.listsToShow = this.lists;
|
||||
this.applyFilter();
|
||||
},
|
||||
@@ -50,6 +51,7 @@ export class ListsComponent implements OnInit {
|
||||
this.listsToShow = this.lists.filter((collection) =>
|
||||
collection.name.toLowerCase().trim().includes(normalizedFilter)
|
||||
);
|
||||
this.listsCount = this.listsToShow.length;
|
||||
}
|
||||
|
||||
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 {
|
||||
id: number;
|
||||
|
||||
@@ -7,6 +9,10 @@ export interface List {
|
||||
|
||||
poster_path: string;
|
||||
|
||||
listEntries: ListEntry[];
|
||||
changed: boolean;
|
||||
isChecked: boolean;
|
||||
|
||||
createdAt: Date;
|
||||
modifiedAt: Date;
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NotificationPopupComponent } from './notification-popup/notification-popup.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
imports: [
|
||||
CommonModule, // Common module for common directives
|
||||
],
|
||||
exports: [],
|
||||
declarations: [NotificationPopupComponent],
|
||||
imports: [CommonModule],
|
||||
exports: [NotificationPopupComponent],
|
||||
})
|
||||
export class SharedModule {}
|
||||
Reference in new issue
Block a user