Chore: Upgrade to Angular v18
Chore: Upgrade to Python 3.12 Chore: Upgrade to psycopg3
This commit is contained in:
@ -14,6 +14,8 @@
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button color="primary" class="mr-5" (click)="save()">Save</button>
|
||||
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">Delete</button>
|
||||
@if (!!item.id) {
|
||||
<button mat-raised-button color="warn" (click)="confirmDelete()">Delete</button>
|
||||
}
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
|
||||
@ -8,7 +8,7 @@ describe('SectionDetailComponent', () => {
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [SectionDetailComponent],
|
||||
imports: [SectionDetailComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButton } from '@angular/material/button';
|
||||
import { MatCard, MatCardHeader, MatCardTitle, MatCardContent, MatCardActions } from '@angular/material/card';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatFormField, MatLabel } from '@angular/material/form-field';
|
||||
import { MatInput } from '@angular/material/input';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { Section } from '../../core/section';
|
||||
@ -12,6 +16,19 @@ import { SectionService } from '../section.service';
|
||||
selector: 'app-section-detail',
|
||||
templateUrl: './section-detail.component.html',
|
||||
styleUrls: ['./section-detail.component.css'],
|
||||
standalone: true,
|
||||
imports: [
|
||||
MatCard,
|
||||
MatCardHeader,
|
||||
MatCardTitle,
|
||||
MatCardContent,
|
||||
ReactiveFormsModule,
|
||||
MatFormField,
|
||||
MatLabel,
|
||||
MatInput,
|
||||
MatCardActions,
|
||||
MatButton,
|
||||
],
|
||||
})
|
||||
export class SectionDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
@ -57,27 +74,27 @@ export class SectionDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe(
|
||||
() => {
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe({
|
||||
next: () => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/sections');
|
||||
},
|
||||
(error) => {
|
||||
error: (error) => {
|
||||
this.toaster.show('Error', error);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.item.id as string).subscribe(
|
||||
() => {
|
||||
this.ser.delete(this.item.id as string).subscribe({
|
||||
next: () => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/sections');
|
||||
},
|
||||
(error) => {
|
||||
error: (error) => {
|
||||
this.toaster.show('Error', error);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
confirmDelete(): void {
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { Section } from '../core/section';
|
||||
|
||||
import { SectionService } from './section.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SectionListResolver {
|
||||
constructor(private ser: SectionService) {}
|
||||
|
||||
resolve(): Observable<Section[]> {
|
||||
return this.ser.list();
|
||||
}
|
||||
}
|
||||
10
bookie/src/app/sections/section-list.resolver.ts
Normal file
10
bookie/src/app/sections/section-list.resolver.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Section } from '../core/section';
|
||||
|
||||
import { SectionService } from './section.service';
|
||||
|
||||
export const sectionListResolver: ResolveFn<Section[]> = () => {
|
||||
return inject(SectionService).list();
|
||||
};
|
||||
@ -8,7 +8,7 @@ describe('SectionListComponent', () => {
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [SectionListComponent],
|
||||
imports: [SectionListComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(SectionListComponent);
|
||||
|
||||
@ -1,5 +1,20 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { MatAnchor } from '@angular/material/button';
|
||||
import { MatCard, MatCardHeader, MatCardTitleGroup, MatCardTitle, MatCardContent } from '@angular/material/card';
|
||||
import { MatIcon } from '@angular/material/icon';
|
||||
import {
|
||||
MatTable,
|
||||
MatColumnDef,
|
||||
MatHeaderCellDef,
|
||||
MatHeaderCell,
|
||||
MatCellDef,
|
||||
MatCell,
|
||||
MatHeaderRowDef,
|
||||
MatHeaderRow,
|
||||
MatRowDef,
|
||||
MatRow,
|
||||
} from '@angular/material/table';
|
||||
import { ActivatedRoute, RouterLink } from '@angular/router';
|
||||
|
||||
import { Section } from '../../core/section';
|
||||
|
||||
@ -9,6 +24,27 @@ import { SectionListDataSource } from './section-list-datasource';
|
||||
selector: 'app-section-list',
|
||||
templateUrl: './section-list.component.html',
|
||||
styleUrls: ['./section-list.component.css'],
|
||||
standalone: true,
|
||||
imports: [
|
||||
MatCard,
|
||||
MatCardHeader,
|
||||
MatCardTitleGroup,
|
||||
MatCardTitle,
|
||||
MatAnchor,
|
||||
RouterLink,
|
||||
MatIcon,
|
||||
MatCardContent,
|
||||
MatTable,
|
||||
MatColumnDef,
|
||||
MatHeaderCellDef,
|
||||
MatHeaderCell,
|
||||
MatCellDef,
|
||||
MatCell,
|
||||
MatHeaderRowDef,
|
||||
MatHeaderRow,
|
||||
MatRowDef,
|
||||
MatRow,
|
||||
],
|
||||
})
|
||||
export class SectionListComponent implements OnInit {
|
||||
list: Section[] = [];
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { Section } from '../core/section';
|
||||
|
||||
import { SectionService } from './section.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SectionResolver {
|
||||
constructor(private ser: SectionService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<Section> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.ser.get(id);
|
||||
}
|
||||
}
|
||||
11
bookie/src/app/sections/section.resolver.ts
Normal file
11
bookie/src/app/sections/section.resolver.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Section } from '../core/section';
|
||||
|
||||
import { SectionService } from './section.service';
|
||||
|
||||
export const sectionResolver: ResolveFn<Section> = (route) => {
|
||||
const id = route.paramMap.get('id');
|
||||
return inject(SectionService).get(id);
|
||||
};
|
||||
@ -1,13 +0,0 @@
|
||||
import { SectionsRoutingModule } from './sections-routing.module';
|
||||
|
||||
describe('SectionsRoutingModule', () => {
|
||||
let sectionsRoutingModule: SectionsRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
sectionsRoutingModule = new SectionsRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(sectionsRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -1,53 +0,0 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { SectionDetailComponent } from './section-detail/section-detail.component';
|
||||
import { SectionListComponent } from './section-list/section-list.component';
|
||||
import { SectionListResolver } from './section-list-resolver.service';
|
||||
import { SectionResolver } from './section-resolver.service';
|
||||
|
||||
const sectionsRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: SectionListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Sections',
|
||||
},
|
||||
resolve: {
|
||||
list: SectionListResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
component: SectionDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Sections',
|
||||
},
|
||||
resolve: {
|
||||
item: SectionResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: SectionDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Sections',
|
||||
},
|
||||
resolve: {
|
||||
item: SectionResolver,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, RouterModule.forChild(sectionsRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [SectionListResolver, SectionResolver],
|
||||
})
|
||||
export class SectionsRoutingModule {}
|
||||
@ -1,13 +0,0 @@
|
||||
import { SectionsModule } from './sections.module';
|
||||
|
||||
describe('SectionsModule', () => {
|
||||
let sectionsModule: SectionsModule;
|
||||
|
||||
beforeEach(() => {
|
||||
sectionsModule = new SectionsModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(sectionsModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -1,31 +0,0 @@
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
|
||||
import { SectionDetailComponent } from './section-detail/section-detail.component';
|
||||
import { SectionListComponent } from './section-list/section-list.component';
|
||||
import { SectionsRoutingModule } from './sections-routing.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
CdkTableModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SectionsRoutingModule,
|
||||
],
|
||||
declarations: [SectionListComponent, SectionDetailComponent],
|
||||
})
|
||||
export class SectionsModule {}
|
||||
44
bookie/src/app/sections/sections.routes.ts
Normal file
44
bookie/src/app/sections/sections.routes.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { SectionDetailComponent } from './section-detail/section-detail.component';
|
||||
import { SectionListComponent } from './section-list/section-list.component';
|
||||
import { sectionListResolver } from './section-list.resolver';
|
||||
import { sectionResolver } from './section.resolver';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: SectionListComponent,
|
||||
canActivate: [authGuard],
|
||||
data: {
|
||||
permission: 'Sections',
|
||||
},
|
||||
resolve: {
|
||||
list: sectionListResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
component: SectionDetailComponent,
|
||||
canActivate: [authGuard],
|
||||
data: {
|
||||
permission: 'Sections',
|
||||
},
|
||||
resolve: {
|
||||
item: sectionResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: SectionDetailComponent,
|
||||
canActivate: [authGuard],
|
||||
data: {
|
||||
permission: 'Sections',
|
||||
},
|
||||
resolve: {
|
||||
item: sectionResolver,
|
||||
},
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user