Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: CodeSequence/ngconf2019-ngrx-workshop
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b2d2184b662a58306fdd85b619dc90f2cb5c503d
Choose a base ref
..
head repository: CodeSequence/ngconf2019-ngrx-workshop
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1f8e09c5f8b14ceca7cf273f306337c171fbe585
Choose a head ref
Showing with 385 additions and 320 deletions.
  1. +5 −4 src/app/app.component.css
  2. +9 −5 src/app/app.component.html
  3. +6 −6 src/app/app.component.ts
  4. +5 −5 src/app/app.module.ts
  5. +9 −10 src/app/books/actions/books-page.actions.ts
  6. +3 −3 src/app/books/actions/index.ts
  7. +9 −11 src/app/books/books.module.ts
  8. +16 −4 src/app/books/components/book-detail/book-detail.component.html
  9. +4 −4 src/app/books/components/book-detail/book-detail.component.spec.ts
  10. +8 −8 src/app/books/components/book-detail/book-detail.component.ts
  11. +13 −5 src/app/books/components/books-list/books-list.component.html
  12. +4 −4 src/app/books/components/books-list/books-list.component.spec.ts
  13. +5 −5 src/app/books/components/books-list/books-list.component.ts
  14. +7 −6 src/app/books/components/books-page/books-page.component.html
  15. +13 −17 src/app/books/components/books-page/books-page.component.spec.ts
  16. +15 −15 src/app/books/components/books-page/books-page.component.ts
  17. +0 −1 src/app/books/components/books-total/books-total.component.html
  18. +9 −13 src/app/books/components/books-total/books-total.component.spec.ts
  19. +4 −4 src/app/books/components/books-total/books-total.component.ts
  20. +4 −5 src/app/material.module.ts
  21. +16 −4 src/app/movies/components/movie-detail/movie-detail.component.html
  22. +4 −4 src/app/movies/components/movie-detail/movie-detail.component.spec.ts
  23. +8 −8 src/app/movies/components/movie-detail/movie-detail.component.ts
  24. +13 −5 src/app/movies/components/movies-list/movies-list.component.html
  25. +4 −4 src/app/movies/components/movies-list/movies-list.component.spec.ts
  26. +5 −5 src/app/movies/components/movies-list/movies-list.component.ts
  27. +8 −7 src/app/movies/components/movies-page/movies-page.component.html
  28. +43 −40 src/app/movies/components/movies-page/movies-page.component.spec.ts
  29. +15 −13 src/app/movies/components/movies-page/movies-page.component.ts
  30. +0 −1 src/app/movies/components/movies-total/movies-total.component.html
  31. +9 −13 src/app/movies/components/movies-total/movies-total.component.spec.ts
  32. +4 −4 src/app/movies/components/movies-total/movies-total.component.ts
  33. +2 −2 src/app/movies/movie-api.effects.spec.ts
  34. +8 −3 src/app/movies/movie-api.effects.ts
  35. +9 −11 src/app/movies/movies.module.ts
  36. +1 −1 src/app/shared/models/movie.model.ts
  37. +2 −4 src/app/shared/state/books.reducer.spec.ts
  38. +20 −11 src/app/shared/state/books.reducer.ts
  39. +5 −6 src/app/shared/state/index.ts
  40. +34 −12 src/app/shared/state/movie.reducer.ts
  41. +11 −11 src/index.html
  42. +6 −5 src/main.ts
  43. +1 −2 src/polyfills.ts
  44. +9 −9 src/styles.css
9 changes: 5 additions & 4 deletions src/app/app.component.css
Original file line number Diff line number Diff line change
@@ -5,15 +5,16 @@
}

.nav-link {
color: rgba(0,0,0,.54);
color: rgba(0, 0, 0, 0.54);
display: flex;
align-items:center;
align-items: center;
padding-top: 5px;
padding-bottom: 5px;
}

mat-toolbar {
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);
box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2),
0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12);
z-index: 1;
}

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

mat-sidenav {
box-shadow: 3px 0 6px rgba(0,0,0,.24);
box-shadow: 3px 0 6px rgba(0, 0, 0, 0.24);
width: 200px;
}

14 changes: 9 additions & 5 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<mat-toolbar color="primary">
<button (click)="sidenav.toggle()" mat-mini-fab><mat-icon>menu</mat-icon></button>
<button (click)="sidenav.toggle()" mat-mini-fab>
<mat-icon>menu</mat-icon>
</button>
<span>
{{ title }}
</span>
@@ -8,13 +10,15 @@
<mat-sidenav-container>
<mat-sidenav #sidenav mode="side" class="app-sidenav">
<nav>
<a mat-button
<a
mat-button
class="nav-link"
*ngFor="let link of links"
[routerLink]="link.path"
routerLinkActive="active">
<mat-icon>{{link.icon}}</mat-icon>
{{link.label}}
routerLinkActive="active"
>
<mat-icon>{{ link.icon }}</mat-icon>
{{ link.label }}
</a>
</nav>
</mat-sidenav>
12 changes: 6 additions & 6 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -2,13 +2,13 @@ import { Component } from "@angular/core";

@Component({
selector: "app-root",
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
title = 'NgRx Workshop';
title = "NgRx Workshop";
links = [
{ path: '/movies', icon: 'movie', label: 'Movies'},
{ path: '/books', icon: 'book', label: 'Books'}
];
{ path: "/movies", icon: "movie", label: "Movies" },
{ path: "/books", icon: "book", label: "Books" }
];
}
10 changes: 5 additions & 5 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { NgModule } from "@angular/core";
import { RouterModule } from '@angular/router';
import { HttpClientModule } from '@angular/common/http';
import { RouterModule } from "@angular/router";
import { HttpClientModule } from "@angular/common/http";

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

import { MaterialModule } from './material.module';
import { MaterialModule } from "./material.module";
import { MoviesModule } from "./movies/movies.module";

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

import { reducers, metaReducers } from "./shared/state";
import { BooksModule } from './books/books.module';
import { BooksModule } from "./books/books.module";

@NgModule({
declarations: [AppComponent],
@@ -23,7 +23,7 @@ import { BooksModule } from './books/books.module';
BrowserAnimationsModule,
HttpClientModule,
RouterModule.forRoot([
{ path: '', pathMatch: 'full', redirectTo: '/movies' }
{ path: "", pathMatch: "full", redirectTo: "/movies" }
]),
StoreModule.forRoot(reducers, { metaReducers }),
StoreDevtoolsModule.instrument(),
19 changes: 9 additions & 10 deletions src/app/books/actions/books-page.actions.ts
Original file line number Diff line number Diff line change
@@ -2,12 +2,12 @@ import { Book } from "src/app/shared/models/book.model";
import { Action } from "@ngrx/store";

export enum BooksActionTypes {
Enter = '[Books Page] Enter',
SelectBook = '[Books Page] Select Book',
ClearSelectedBook = '[Books Page] Clear Selected Book',
CreateBook = '[Books Page] Create Book',
UpdateBook = '[Books Page] Update Book',
DeleteBook = '[Books Page] Delete Book'
Enter = "[Books Page] Enter",
SelectBook = "[Books Page] Select Book",
ClearSelectedBook = "[Books Page] Clear Selected Book",
CreateBook = "[Books Page] Create Book",
UpdateBook = "[Books Page] Update Book",
DeleteBook = "[Books Page] Delete Book"
}

export class Enter implements Action {
@@ -29,7 +29,7 @@ export class CreateBook implements Action {

constructor(public book: Book) {}
}

export class UpdateBook implements Action {
readonly type = BooksActionTypes.UpdateBook;

@@ -42,11 +42,10 @@ export class DeleteBook implements Action {
constructor(public book: Book) {}
}

export type BooksActions =
export type BooksActions =
| Enter
| SelectBook
| ClearSelectedBook
| CreateBook
| UpdateBook
| DeleteBook
;
| DeleteBook;
6 changes: 3 additions & 3 deletions src/app/books/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as BooksPageActions from './books-page.actions';
import * as BooksApiActions from './books-api.actions';
import * as BooksPageActions from "./books-page.actions";
import * as BooksApiActions from "./books-api.actions";

export { BooksPageActions, BooksApiActions };
export { BooksPageActions, BooksApiActions };
20 changes: 9 additions & 11 deletions src/app/books/books.module.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { NgModule } from "@angular/core";
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { ReactiveFormsModule } from '@angular/forms';
import { CommonModule } from "@angular/common";
import { RouterModule } from "@angular/router";
import { ReactiveFormsModule } from "@angular/forms";

import { MaterialModule } from 'src/app/material.module';
import { MaterialModule } from "src/app/material.module";

import { BooksPageComponent } from './components/books-page/books-page.component';
import { BookDetailComponent } from './components/book-detail/book-detail.component';
import { BooksListComponent } from './components/books-list/books-list.component';
import { BooksTotalComponent } from './components/books-total/books-total.component';
import { BooksPageComponent } from "./components/books-page/books-page.component";
import { BookDetailComponent } from "./components/book-detail/book-detail.component";
import { BooksListComponent } from "./components/books-list/books-list.component";
import { BooksTotalComponent } from "./components/books-total/books-total.component";

@NgModule({
imports: [
CommonModule,
ReactiveFormsModule,
MaterialModule,
RouterModule.forChild([
{ path: 'books', component: BooksPageComponent }
]),
RouterModule.forChild([{ path: "books", component: BooksPageComponent }])
],
declarations: [
BooksPageComponent,
20 changes: 16 additions & 4 deletions src/app/books/components/book-detail/book-detail.component.html
Original file line number Diff line number Diff line change
@@ -2,21 +2,33 @@
<mat-card-header>
<mat-card-title>
<h1>
<span *ngIf="originalBook?.id; else prompt">Editing {{originalBook.name}}</span>
<span *ngIf="originalBook?.id; else prompt"
>Editing {{ originalBook.name }}</span
>
<ng-template #prompt>Create Book</ng-template>
</h1>
</mat-card-title>
</mat-card-header>
<form [formGroup]="bookForm" #f="ngForm" (submit)="onSubmit(f.value)">
<mat-card-content>
<mat-form-field class="full-width">
<input matInput placeholder="Name" formControlName="name" type="text">
<input matInput placeholder="Name" formControlName="name" type="text" />
</mat-form-field>
<mat-form-field class="full-width">
<input matInput placeholder="Earnings" formControlName="earnings" type="text">
<input
matInput
placeholder="Earnings"
formControlName="earnings"
type="text"
/>
</mat-form-field>
<mat-form-field class="full-width">
<input matInput placeholder="Description" formControlName="description" type="text">
<input
matInput
placeholder="Description"
formControlName="description"
type="text"
/>
</mat-form-field>
</mat-card-content>
<mat-card-actions>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* tslint:disable:no-unused-variable */

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

describe('Component: BookDetail', () => {
it('should create an instance', () => {
describe("Component: BookDetail", () => {
it("should create an instance", () => {
const component = new BookDetailComponent();
expect(component).toBeTruthy();
});
16 changes: 8 additions & 8 deletions src/app/books/components/book-detail/book-detail.component.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Book } from 'src/app/shared/models/book.model';
import { FormGroup, FormControl } from '@angular/forms';
import { Component, EventEmitter, Input, Output } from "@angular/core";
import { Book } from "src/app/shared/models/book.model";
import { FormGroup, FormControl } from "@angular/forms";

@Component({
selector: 'app-book-detail',
templateUrl: './book-detail.component.html',
styleUrls: ['./book-detail.component.css']
selector: "app-book-detail",
templateUrl: "./book-detail.component.html",
styleUrls: ["./book-detail.component.css"]
})
export class BookDetailComponent {
originalBook: Book | undefined;
@Output() save = new EventEmitter();
@Output() cancel = new EventEmitter();

bookForm = new FormGroup({
name: new FormControl(''),
name: new FormControl(""),
earnings: new FormControl(0),
description: new FormControl('')
description: new FormControl("")
});

@Input() set book(book: Book) {
18 changes: 13 additions & 5 deletions src/app/books/components/books-list/books-list.component.html
Original file line number Diff line number Diff line change
@@ -6,15 +6,23 @@ <h1>Books</h1>
</mat-card-header>
<mat-card-content>
<mat-list>
<mat-list-item *ngFor="let book of books" (click)="select.emit(book)" class="record">
<h3 mat-line>{{book.name}}</h3>
<mat-list-item
*ngFor="let book of books"
(click)="select.emit(book)"
class="record"
>
<h3 mat-line>{{ book.name }}</h3>
<p mat-line>
{{book.description}}
{{ book.description }}
</p>
<p>
{{book.earnings | currency}}
{{ book.earnings | currency }}
</p>
<button *ngIf="!readonly" mat-icon-button (click)="delete.emit(book);$event.stopImmediatePropagation();">
<button
*ngIf="!readonly"
mat-icon-button
(click)="delete.emit(book); $event.stopImmediatePropagation()"
>
<mat-icon>close</mat-icon>
</button>
</mat-list-item>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* tslint:disable:no-unused-variable */

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

describe('Component: BooksList', () => {
it('should create an instance', () => {
describe("Component: BooksList", () => {
it("should create an instance", () => {
const component = new BooksListComponent();
expect(component).toBeTruthy();
});
10 changes: 5 additions & 5 deletions src/app/books/components/books-list/books-list.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Book } from 'src/app/shared/models/book.model';
import { Component, EventEmitter, Input, Output } from "@angular/core";
import { Book } from "src/app/shared/models/book.model";

@Component({
selector: 'app-books-list',
templateUrl: './books-list.component.html',
styleUrls: ['./books-list.component.css']
selector: "app-books-list",
templateUrl: "./books-list.component.html",
styleUrls: ["./books-list.component.css"]
})
export class BooksListComponent {
@Input() books: Book[];
13 changes: 7 additions & 6 deletions src/app/books/components/books-page/books-page.component.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<div class="container">
<div class="col-50">
<app-books-total
[total]="total">
</app-books-total>
<app-books-total [total]="total"> </app-books-total>

<app-books-list
[books]="books$ | async"
(select)="onSelect($event)"
(delete)="onDelete($event)">
(delete)="onDelete($event)"
>
</app-books-list>
</div>

<app-book-detail class="col-50"
<app-book-detail
class="col-50"
[book]="currentBook"
(save)="onSave($event)"
(cancel)="onCancel()">
(cancel)="onCancel()"
>
</app-book-detail>
</div>
Loading