Skip to content

Commit 22f5785

Browse files
committed
Prepare challenge branch
1 parent 75ee852 commit 22f5785

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+373
-318
lines changed

src/app/app.component.css

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
}
66

77
.nav-link {
8-
color: rgba(0,0,0,.54);
8+
color: rgba(0, 0, 0, 0.54);
99
display: flex;
10-
align-items:center;
10+
align-items: center;
1111
padding-top: 5px;
1212
padding-bottom: 5px;
1313
}
1414

1515
mat-toolbar {
16-
box-shadow: 0 3px 5px -1px rgba(0,0,0,.2), 0 6px 10px 0 rgba(0,0,0,.14), 0 1px 18px 0 rgba(0,0,0,.12);
16+
box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2),
17+
0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12);
1718
z-index: 1;
1819
}
1920

@@ -22,7 +23,7 @@ mat-toolbar > .mat-mini-fab {
2223
}
2324

2425
mat-sidenav {
25-
box-shadow: 3px 0 6px rgba(0,0,0,.24);
26+
box-shadow: 3px 0 6px rgba(0, 0, 0, 0.24);
2627
width: 200px;
2728
}
2829

src/app/app.component.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<mat-toolbar color="primary">
2-
<button (click)="sidenav.toggle()" mat-mini-fab><mat-icon>menu</mat-icon></button>
2+
<button (click)="sidenav.toggle()" mat-mini-fab>
3+
<mat-icon>menu</mat-icon>
4+
</button>
35
<span>
46
{{ title }}
57
</span>
@@ -8,13 +10,15 @@
810
<mat-sidenav-container>
911
<mat-sidenav #sidenav mode="side" class="app-sidenav">
1012
<nav>
11-
<a mat-button
13+
<a
14+
mat-button
1215
class="nav-link"
1316
*ngFor="let link of links"
1417
[routerLink]="link.path"
15-
routerLinkActive="active">
16-
<mat-icon>{{link.icon}}</mat-icon>
17-
{{link.label}}
18+
routerLinkActive="active"
19+
>
20+
<mat-icon>{{ link.icon }}</mat-icon>
21+
{{ link.label }}
1822
</a>
1923
</nav>
2024
</mat-sidenav>

src/app/app.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { Component } from "@angular/core";
22

33
@Component({
44
selector: "app-root",
5-
templateUrl: './app.component.html',
6-
styleUrls: ['./app.component.css']
5+
templateUrl: "./app.component.html",
6+
styleUrls: ["./app.component.css"]
77
})
88
export class AppComponent {
9-
title = 'NgRx Workshop';
9+
title = "NgRx Workshop";
1010
links = [
11-
{ path: '/movies', icon: 'movie', label: 'Movies'},
12-
{ path: '/books', icon: 'book', label: 'Books'}
13-
];
11+
{ path: "/movies", icon: "movie", label: "Movies" },
12+
{ path: "/books", icon: "book", label: "Books" }
13+
];
1414
}

src/app/app.module.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { BrowserModule } from "@angular/platform-browser";
22
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
33
import { NgModule } from "@angular/core";
4-
import { RouterModule } from '@angular/router';
5-
import { HttpClientModule } from '@angular/common/http';
4+
import { RouterModule } from "@angular/router";
5+
import { HttpClientModule } from "@angular/common/http";
66

77
import { StoreModule } from "@ngrx/store";
88
import { StoreDevtoolsModule } from "@ngrx/store-devtools";
99
import { EffectsModule } from "@ngrx/effects";
1010

11-
import { MaterialModule } from './material.module';
11+
import { MaterialModule } from "./material.module";
1212
import { MoviesModule } from "./movies/movies.module";
1313

1414
import { AppComponent } from "./app.component";
1515

1616
import { reducers, metaReducers } from "./shared/state";
17-
import { BooksModule } from './books/books.module';
17+
import { BooksModule } from "./books/books.module";
1818

1919
@NgModule({
2020
declarations: [AppComponent],
@@ -23,7 +23,7 @@ import { BooksModule } from './books/books.module';
2323
BrowserAnimationsModule,
2424
HttpClientModule,
2525
RouterModule.forRoot([
26-
{ path: '', pathMatch: 'full', redirectTo: '/movies' }
26+
{ path: "", pathMatch: "full", redirectTo: "/movies" }
2727
]),
2828
StoreModule.forRoot(reducers, { metaReducers }),
2929
StoreDevtoolsModule.instrument(),

src/app/books/actions/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as BooksPageActions from './books-page.actions';
2-
import * as BooksApiActions from './books-api.actions';
1+
import * as BooksPageActions from "./books-page.actions";
2+
import * as BooksApiActions from "./books-api.actions";
33

4-
export { BooksPageActions, BooksApiActions };
4+
export { BooksPageActions, BooksApiActions };

src/app/books/books.module.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
import { NgModule } from "@angular/core";
2-
import { CommonModule } from '@angular/common';
3-
import { RouterModule } from '@angular/router';
4-
import { ReactiveFormsModule } from '@angular/forms';
2+
import { CommonModule } from "@angular/common";
3+
import { RouterModule } from "@angular/router";
4+
import { ReactiveFormsModule } from "@angular/forms";
55

6-
import { MaterialModule } from 'src/app/material.module';
6+
import { MaterialModule } from "src/app/material.module";
77

8-
import { BooksPageComponent } from './components/books-page/books-page.component';
9-
import { BookDetailComponent } from './components/book-detail/book-detail.component';
10-
import { BooksListComponent } from './components/books-list/books-list.component';
11-
import { BooksTotalComponent } from './components/books-total/books-total.component';
8+
import { BooksPageComponent } from "./components/books-page/books-page.component";
9+
import { BookDetailComponent } from "./components/book-detail/book-detail.component";
10+
import { BooksListComponent } from "./components/books-list/books-list.component";
11+
import { BooksTotalComponent } from "./components/books-total/books-total.component";
1212

1313
@NgModule({
1414
imports: [
1515
CommonModule,
1616
ReactiveFormsModule,
1717
MaterialModule,
18-
RouterModule.forChild([
19-
{ path: 'books', component: BooksPageComponent }
20-
]),
18+
RouterModule.forChild([{ path: "books", component: BooksPageComponent }])
2119
],
2220
declarations: [
2321
BooksPageComponent,

src/app/books/components/book-detail/book-detail.component.html

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,33 @@
22
<mat-card-header>
33
<mat-card-title>
44
<h1>
5-
<span *ngIf="originalBook?.id; else prompt">Editing {{originalBook.name}}</span>
5+
<span *ngIf="originalBook?.id; else prompt"
6+
>Editing {{ originalBook.name }}</span
7+
>
68
<ng-template #prompt>Create Book</ng-template>
79
</h1>
810
</mat-card-title>
911
</mat-card-header>
1012
<form [formGroup]="bookForm" #f="ngForm" (submit)="onSubmit(f.value)">
1113
<mat-card-content>
1214
<mat-form-field class="full-width">
13-
<input matInput placeholder="Name" formControlName="name" type="text">
15+
<input matInput placeholder="Name" formControlName="name" type="text" />
1416
</mat-form-field>
1517
<mat-form-field class="full-width">
16-
<input matInput placeholder="Earnings" formControlName="earnings" type="text">
18+
<input
19+
matInput
20+
placeholder="Earnings"
21+
formControlName="earnings"
22+
type="text"
23+
/>
1724
</mat-form-field>
1825
<mat-form-field class="full-width">
19-
<input matInput placeholder="Description" formControlName="description" type="text">
26+
<input
27+
matInput
28+
placeholder="Description"
29+
formControlName="description"
30+
type="text"
31+
/>
2032
</mat-form-field>
2133
</mat-card-content>
2234
<mat-card-actions>

src/app/books/components/book-detail/book-detail.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* tslint:disable:no-unused-variable */
22

3-
import { TestBed, async } from '@angular/core/testing';
4-
import { BookDetailComponent } from './book-detail.component';
3+
import { TestBed, async } from "@angular/core/testing";
4+
import { BookDetailComponent } from "./book-detail.component";
55

6-
describe('Component: BookDetail', () => {
7-
it('should create an instance', () => {
6+
describe("Component: BookDetail", () => {
7+
it("should create an instance", () => {
88
const component = new BookDetailComponent();
99
expect(component).toBeTruthy();
1010
});

src/app/books/components/book-detail/book-detail.component.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import { Component, EventEmitter, Input, Output } from '@angular/core';
2-
import { Book } from 'src/app/shared/models/book.model';
3-
import { FormGroup, FormControl } from '@angular/forms';
1+
import { Component, EventEmitter, Input, Output } from "@angular/core";
2+
import { Book } from "src/app/shared/models/book.model";
3+
import { FormGroup, FormControl } from "@angular/forms";
44

55
@Component({
6-
selector: 'app-book-detail',
7-
templateUrl: './book-detail.component.html',
8-
styleUrls: ['./book-detail.component.css']
6+
selector: "app-book-detail",
7+
templateUrl: "./book-detail.component.html",
8+
styleUrls: ["./book-detail.component.css"]
99
})
1010
export class BookDetailComponent {
1111
originalBook: Book | undefined;
1212
@Output() save = new EventEmitter();
1313
@Output() cancel = new EventEmitter();
1414

1515
bookForm = new FormGroup({
16-
name: new FormControl(''),
16+
name: new FormControl(""),
1717
earnings: new FormControl(0),
18-
description: new FormControl('')
18+
description: new FormControl("")
1919
});
2020

2121
@Input() set book(book: Book) {

src/app/books/components/books-list/books-list.component.html

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,23 @@ <h1>Books</h1>
66
</mat-card-header>
77
<mat-card-content>
88
<mat-list>
9-
<mat-list-item *ngFor="let book of books" (click)="select.emit(book)" class="record">
10-
<h3 mat-line>{{book.name}}</h3>
9+
<mat-list-item
10+
*ngFor="let book of books"
11+
(click)="select.emit(book)"
12+
class="record"
13+
>
14+
<h3 mat-line>{{ book.name }}</h3>
1115
<p mat-line>
12-
{{book.description}}
16+
{{ book.description }}
1317
</p>
1418
<p>
15-
{{book.earnings | currency}}
19+
{{ book.earnings | currency }}
1620
</p>
17-
<button *ngIf="!readonly" mat-icon-button (click)="delete.emit(book);$event.stopImmediatePropagation();">
21+
<button
22+
*ngIf="!readonly"
23+
mat-icon-button
24+
(click)="delete.emit(book); $event.stopImmediatePropagation()"
25+
>
1826
<mat-icon>close</mat-icon>
1927
</button>
2028
</mat-list-item>

src/app/books/components/books-list/books-list.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* tslint:disable:no-unused-variable */
22

3-
import { TestBed, async } from '@angular/core/testing';
4-
import { BooksListComponent } from './books-list.component';
3+
import { TestBed, async } from "@angular/core/testing";
4+
import { BooksListComponent } from "./books-list.component";
55

6-
describe('Component: BooksList', () => {
7-
it('should create an instance', () => {
6+
describe("Component: BooksList", () => {
7+
it("should create an instance", () => {
88
const component = new BooksListComponent();
99
expect(component).toBeTruthy();
1010
});

src/app/books/components/books-list/books-list.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Component, EventEmitter, Input, Output } from '@angular/core';
2-
import { Book } from 'src/app/shared/models/book.model';
1+
import { Component, EventEmitter, Input, Output } from "@angular/core";
2+
import { Book } from "src/app/shared/models/book.model";
33

44
@Component({
5-
selector: 'app-books-list',
6-
templateUrl: './books-list.component.html',
7-
styleUrls: ['./books-list.component.css']
5+
selector: "app-books-list",
6+
templateUrl: "./books-list.component.html",
7+
styleUrls: ["./books-list.component.css"]
88
})
99
export class BooksListComponent {
1010
@Input() books: Book[];
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
<div class="container">
22
<div class="col-50">
3-
<app-books-total
4-
[total]="total">
5-
</app-books-total>
3+
<app-books-total [total]="total"> </app-books-total>
64

75
<app-books-list
86
[books]="books"
97
(select)="onSelect($event)"
10-
(delete)="onDelete($event)">
8+
(delete)="onDelete($event)"
9+
>
1110
</app-books-list>
1211
</div>
1312

14-
<app-book-detail class="col-50"
13+
<app-book-detail
14+
class="col-50"
1515
[book]="currentBook"
1616
(save)="onSave($event)"
17-
(cancel)="onCancel()">
17+
(cancel)="onCancel()"
18+
>
1819
</app-book-detail>
1920
</div>
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
/* tslint:disable:no-unused-variable */
22

3-
import { TestBed, async, ComponentFixture } from '@angular/core/testing';
4-
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
5-
import { ReactiveFormsModule } from '@angular/forms';
3+
import { TestBed, async, ComponentFixture } from "@angular/core/testing";
4+
import { NoopAnimationsModule } from "@angular/platform-browser/animations";
5+
import { ReactiveFormsModule } from "@angular/forms";
66

7-
import { MaterialModule } from 'src/app/material.module';
7+
import { MaterialModule } from "src/app/material.module";
88

9-
import { BooksPageComponent } from './books-page.component';
10-
import { BooksService } from 'src/app/shared/services/book.service';
11-
import { BooksListComponent } from '../books-list/books-list.component';
12-
import { BookDetailComponent } from '../book-detail/book-detail.component';
13-
import { BooksTotalComponent } from '../books-total/books-total.component';
14-
import { provideMockStore } from '@ngrx/store/testing';
9+
import { BooksPageComponent } from "./books-page.component";
10+
import { BooksService } from "src/app/shared/services/book.service";
11+
import { BooksListComponent } from "../books-list/books-list.component";
12+
import { BookDetailComponent } from "../book-detail/book-detail.component";
13+
import { BooksTotalComponent } from "../books-total/books-total.component";
14+
import { provideMockStore } from "@ngrx/store/testing";
1515

1616
class BooksServiceStub {}
1717

18-
describe('Component: Books Page', () => {
18+
describe("Component: Books Page", () => {
1919
let comp: BooksPageComponent;
2020
let fixture: ComponentFixture<BooksPageComponent>;
2121

2222
beforeEach(() => {
2323
TestBed.configureTestingModule({
24-
imports: [
25-
MaterialModule,
26-
NoopAnimationsModule,
27-
ReactiveFormsModule
28-
],
24+
imports: [MaterialModule, NoopAnimationsModule, ReactiveFormsModule],
2925
declarations: [
3026
BooksPageComponent,
3127
BooksPageComponent,
@@ -43,7 +39,7 @@ describe('Component: Books Page', () => {
4339
comp = fixture.componentInstance;
4440
});
4541

46-
it('should create an instance', () => {
42+
it("should create an instance", () => {
4743
expect(comp).toBeTruthy();
4844
});
4945
});

0 commit comments

Comments
 (0)