Reformat code
This commit is contained in:
parent
4b10d3d056
commit
093180f5b2
17 changed files with 101 additions and 104 deletions
|
|
@ -4,11 +4,13 @@
|
||||||
<button class="navbar-toggler" type="button" (click)="isMenuCollapsed = !isMenuCollapsed">☰</button>
|
<button class="navbar-toggler" type="button" (click)="isMenuCollapsed = !isMenuCollapsed">☰</button>
|
||||||
<div [ngbCollapse]="isMenuCollapsed" class="collapse navbar-collapse">
|
<div [ngbCollapse]="isMenuCollapsed" class="collapse navbar-collapse">
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
@for (route of routes; track $index;) {
|
@for (route of routes; track $index; ) {
|
||||||
@if (route.component !== undefined) {<li class="nav-item">
|
@if (route.component !== undefined) {
|
||||||
<a class="nav-link text-capitalize" [routerLink]="route.path" routerLinkActive="active"
|
<li class="nav-item">
|
||||||
(click)="isMenuCollapsed = true">{{route.path}}</a>
|
<a class="nav-link text-capitalize" [routerLink]="route.path" routerLinkActive="active"
|
||||||
</li>}
|
(click)="isMenuCollapsed = true">{{ route.path }}</a>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { TestBed } from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import { AppComponent } from './app.component';
|
import {AppComponent} from './app.component';
|
||||||
|
|
||||||
describe('AppComponent', () => {
|
describe('AppComponent', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component } from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
import {RouterLink, RouterLinkActive, RouterOutlet} from '@angular/router';
|
import {RouterLink, RouterLinkActive, RouterOutlet} from '@angular/router';
|
||||||
import {ToastContainerComponent} from '../components/toast-container/toast-container/toast-container.component';
|
import {ToastContainerComponent} from '../components/toast-container/toast-container/toast-container.component';
|
||||||
import {NgbCollapse} from '@ng-bootstrap/ng-bootstrap';
|
import {NgbCollapse} from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Routes } from '@angular/router';
|
import {Routes} from '@angular/router';
|
||||||
import {ShowsComponent} from '../pages/shows/shows.component';
|
import {ShowsComponent} from '../pages/shows/shows.component';
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import { CreateModalComponent } from './create-modal.component';
|
import {CreateModalComponent} from './create-modal.component';
|
||||||
|
|
||||||
describe('CreateModalComponent', () => {
|
describe('CreateModalComponent', () => {
|
||||||
let component: CreateModalComponent;
|
let component: CreateModalComponent;
|
||||||
|
|
@ -10,7 +10,7 @@ describe('CreateModalComponent', () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [CreateModalComponent]
|
imports: [CreateModalComponent]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(CreateModalComponent);
|
fixture = TestBed.createComponent(CreateModalComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h4 class="modal-title text-truncate">Delete {{ showName }}?</h4>
|
<h4 class="modal-title text-truncate">Delete {{ showName }}?</h4>
|
||||||
<button type="button" class="btn-close" aria-label="Close" (click)="this.activeModal.dismiss()"></button>
|
<button type="button" class="btn-close" aria-label="Close" (click)="this.activeModal.dismiss()"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>Are you sure you want to delete this show?</p>
|
<p>Are you sure you want to delete this show?</p>
|
||||||
<b class="text-danger-emphasis">This cannot be reversed</b>
|
<b class="text-danger-emphasis">This cannot be reversed</b>
|
||||||
<div class="card" #collapse="ngbCollapse" [(ngbCollapse)]="formHidden">
|
<div class="card" #collapse="ngbCollapse" [(ngbCollapse)]="formHidden">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form [formGroup]="confirmationForm" (ngSubmit)="formSubmitted()">
|
<form [formGroup]="confirmationForm" (ngSubmit)="formSubmitted()">
|
||||||
<label class="form-label">To avoid mistakes, please type the name of the show to continue:</label>
|
<label class="form-label">To avoid mistakes, please type the name of the show to continue:</label>
|
||||||
<input formControlName="name" type="text" class="form-control">
|
<input formControlName="name" type="text" class="form-control">
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="btn btn-danger"
|
class="btn btn-danger"
|
||||||
(click)="deletePressed()"
|
(click)="deletePressed()"
|
||||||
[disabled]="confirmationForm.invalid && buttonDisabled"
|
[disabled]="confirmationForm.invalid && buttonDisabled"
|
||||||
>Delete
|
>Delete
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import { DeleteModalComponent } from './delete-modal.component';
|
import {DeleteModalComponent} from './delete-modal.component';
|
||||||
|
|
||||||
describe('DeleteModalComponent', () => {
|
describe('DeleteModalComponent', () => {
|
||||||
let component: DeleteModalComponent;
|
let component: DeleteModalComponent;
|
||||||
let fixture: ComponentFixture<DeleteModalComponent>;
|
let fixture: ComponentFixture<DeleteModalComponent>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [DeleteModalComponent]
|
imports: [DeleteModalComponent]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(DeleteModalComponent);
|
fixture = TestBed.createComponent(DeleteModalComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,46 @@
|
||||||
import {Component, inject} from '@angular/core';
|
import {Component, inject} from '@angular/core';
|
||||||
import {NgbActiveModal, NgbCollapse} from '@ng-bootstrap/ng-bootstrap';
|
import {NgbActiveModal, NgbCollapse} from '@ng-bootstrap/ng-bootstrap';
|
||||||
import {
|
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||||
FormControl,
|
|
||||||
FormGroup,
|
|
||||||
FormsModule,
|
|
||||||
ReactiveFormsModule,
|
|
||||||
Validators
|
|
||||||
} from '@angular/forms';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-delete-modal',
|
selector: 'app-delete-modal',
|
||||||
imports: [
|
imports: [
|
||||||
NgbCollapse,
|
NgbCollapse,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
ReactiveFormsModule
|
ReactiveFormsModule
|
||||||
],
|
],
|
||||||
templateUrl: './delete-modal.component.html',
|
templateUrl: './delete-modal.component.html',
|
||||||
styleUrl: './delete-modal.component.css'
|
styleUrl: './delete-modal.component.css'
|
||||||
})
|
})
|
||||||
export class DeleteModalComponent {
|
export class DeleteModalComponent {
|
||||||
protected activeModal: NgbActiveModal = inject(NgbActiveModal)
|
protected activeModal: NgbActiveModal = inject(NgbActiveModal)
|
||||||
showName: string = ""
|
showName: string = ""
|
||||||
formHidden: boolean = true;
|
formHidden: boolean = true;
|
||||||
buttonDisabled: boolean = false;
|
buttonDisabled: boolean = false;
|
||||||
confirmationForm: FormGroup
|
confirmationForm: FormGroup
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.confirmationForm = new FormGroup({
|
this.confirmationForm = new FormGroup({
|
||||||
name: new FormControl("",Validators.required)
|
name: new FormControl("", Validators.required)
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
deletePressed() {
|
|
||||||
if (this.formHidden) {
|
|
||||||
const regex = new RegExp(this.showName)
|
|
||||||
const control = new FormControl("", [Validators.required, Validators.pattern(regex)])
|
|
||||||
this.confirmationForm.setControl("name", control)
|
|
||||||
this.formHidden = false;
|
|
||||||
this.buttonDisabled = true;
|
|
||||||
} else {
|
|
||||||
this.formSubmitted()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
formSubmitted() {
|
|
||||||
if (this.confirmationForm.valid) {
|
deletePressed() {
|
||||||
this.activeModal.close(true)
|
if (this.formHidden) {
|
||||||
|
const regex = new RegExp(this.showName)
|
||||||
|
const control = new FormControl("", [Validators.required, Validators.pattern(regex)])
|
||||||
|
this.confirmationForm.setControl("name", control)
|
||||||
|
this.formHidden = false;
|
||||||
|
this.buttonDisabled = true;
|
||||||
|
} else {
|
||||||
|
this.formSubmitted()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
formSubmitted() {
|
||||||
|
if (this.confirmationForm.valid) {
|
||||||
|
this.activeModal.close(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,6 @@
|
||||||
[header]="toast.header || ''" [autohide]="true" [delay]="toast.delay || 5000"
|
[header]="toast.header || ''" [autohide]="true" [delay]="toast.delay || 5000"
|
||||||
(hidden)="toastService.remove(toast)"
|
(hidden)="toastService.remove(toast)"
|
||||||
[animation]="true" [class]="toast.htmlClass"
|
[animation]="true" [class]="toast.htmlClass"
|
||||||
>{{ toast.body }}</ngb-toast>
|
>{{ toast.body }}
|
||||||
|
</ngb-toast>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import { ToastContainerComponent } from './toast-container.component';
|
import {ToastContainerComponent} from './toast-container.component';
|
||||||
|
|
||||||
describe('ToastContainerComponent', () => {
|
describe('ToastContainerComponent', () => {
|
||||||
let component: ToastContainerComponent;
|
let component: ToastContainerComponent;
|
||||||
|
|
@ -10,7 +10,7 @@ describe('ToastContainerComponent', () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [ToastContainerComponent]
|
imports: [ToastContainerComponent]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(ToastContainerComponent);
|
fixture = TestBed.createComponent(ToastContainerComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<app-root></app-root>
|
<app-root></app-root>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/// <reference types="@angular/localize" />
|
/// <reference types="@angular/localize" />
|
||||||
|
|
||||||
import { bootstrapApplication } from '@angular/platform-browser';
|
import {bootstrapApplication} from '@angular/platform-browser';
|
||||||
import { appConfig } from './app/app.config';
|
import {appConfig} from './app/app.config';
|
||||||
import { AppComponent } from './app/app.component';
|
import {AppComponent} from './app/app.component';
|
||||||
|
|
||||||
bootstrapApplication(AppComponent, appConfig)
|
bootstrapApplication(AppComponent, appConfig)
|
||||||
.catch((err) => console.error(err));
|
.catch((err) => console.error(err));
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import { ShowsComponent } from './shows.component';
|
import {ShowsComponent} from './shows.component';
|
||||||
|
|
||||||
describe('ShowsComponent', () => {
|
describe('ShowsComponent', () => {
|
||||||
let component: ShowsComponent;
|
let component: ShowsComponent;
|
||||||
|
|
@ -10,7 +10,7 @@ describe('ShowsComponent', () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [ShowsComponent]
|
imports: [ShowsComponent]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(ShowsComponent);
|
fixture = TestBed.createComponent(ShowsComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { TestBed } from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import { ShowsApiService } from './shows-api.service';
|
import {ShowsApiService} from './shows-api.service';
|
||||||
|
|
||||||
describe('ShowsApiService', () => {
|
describe('ShowsApiService', () => {
|
||||||
let service: ShowsApiService;
|
let service: ShowsApiService;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export class ShowsApiService {
|
||||||
}
|
}
|
||||||
|
|
||||||
getShow(id: string): Observable<ShowsApiIdResponse> {
|
getShow(id: string): Observable<ShowsApiIdResponse> {
|
||||||
return this.http.get<ShowsApiIdResponse>(this.showsEndpoint + "id/" + id )
|
return this.http.get<ShowsApiIdResponse>(this.showsEndpoint + "id/" + id)
|
||||||
}
|
}
|
||||||
|
|
||||||
sendShow(newShow: {}) {
|
sendShow(newShow: {}) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { TestBed } from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import { ToastService } from './toast.service';
|
import {ToastService} from './toast.service';
|
||||||
|
|
||||||
describe('ToastService', () => {
|
describe('ToastService', () => {
|
||||||
let service: ToastService;
|
let service: ToastService;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Injectable } from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {Toast} from '../../interfaces/toast';
|
import {Toast} from '../../interfaces/toast';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue