diff --git a/.gitignore b/.gitignore
index 105c00f..e5c1ba1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,3 +44,5 @@ testem.log
# System Files
.DS_Store
Thumbs.db
+
+package-lock.json
\ No newline at end of file
diff --git a/angular.json b/angular.json
index 9b57492..8d57b59 100644
--- a/angular.json
+++ b/angular.json
@@ -31,6 +31,7 @@
"src/assets"
],
"styles": [
+ "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.less"
],
"scripts": []
@@ -99,6 +100,7 @@
"src/assets"
],
"styles": [
+ "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.less"
],
"scripts": []
diff --git a/package-lock.json b/package-lock.json
index 2e931b6..f6501ff 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,13 +9,16 @@
"version": "0.0.0",
"dependencies": {
"@angular/animations": "~13.0.0",
+ "@angular/cdk": "^13.0.3",
"@angular/common": "~13.0.0",
"@angular/compiler": "~13.0.0",
"@angular/core": "~13.0.0",
"@angular/forms": "~13.0.0",
+ "@angular/material": "^13.0.3",
"@angular/platform-browser": "~13.0.0",
"@angular/platform-browser-dynamic": "~13.0.0",
"@angular/router": "~13.0.0",
+ "bootstrap": "4.3.1",
"rxjs": "~7.4.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
@@ -341,6 +344,28 @@
"@angular/core": "13.0.3"
}
},
+ "node_modules/@angular/cdk": {
+ "version": "13.0.3",
+ "resolved": "https://registry.npmjs.org/@angular/cdk/-/cdk-13.0.3.tgz",
+ "integrity": "sha512-nPlnpdLk+Lady3l5eHh+csbHPOiTvfVpMrluUEnb1RAby07QQucUo7cYOKgFiVmSmaMwDBv2aGj1fAoXKzzc5g==",
+ "dependencies": {
+ "tslib": "^2.3.0"
+ },
+ "optionalDependencies": {
+ "parse5": "^5.0.0"
+ },
+ "peerDependencies": {
+ "@angular/common": "^13.0.0 || ^14.0.0-0",
+ "@angular/core": "^13.0.0 || ^14.0.0-0",
+ "rxjs": "^6.5.3 || ^7.4.0"
+ }
+ },
+ "node_modules/@angular/cdk/node_modules/parse5": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz",
+ "integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==",
+ "optional": true
+ },
"node_modules/@angular/cli": {
"version": "13.0.4",
"resolved": "https://registry.npmjs.org/@angular/cli/-/cli-13.0.4.tgz",
@@ -466,6 +491,22 @@
"rxjs": "^6.5.3 || ^7.4.0"
}
},
+ "node_modules/@angular/material": {
+ "version": "13.0.3",
+ "resolved": "https://registry.npmjs.org/@angular/material/-/material-13.0.3.tgz",
+ "integrity": "sha512-6lEofw8wWl1huNLEgngYfIDA7dY4oSq0sB7F16foDfenC+TokRxfIN950GKNYmvGVYqODUuQdrQ1n2bXE2GQGg==",
+ "dependencies": {
+ "tslib": "^2.3.0"
+ },
+ "peerDependencies": {
+ "@angular/animations": "^13.0.0 || ^14.0.0-0",
+ "@angular/cdk": "13.0.3",
+ "@angular/common": "^13.0.0 || ^14.0.0-0",
+ "@angular/core": "^13.0.0 || ^14.0.0-0",
+ "@angular/forms": "^13.0.0 || ^14.0.0-0",
+ "rxjs": "^6.5.3 || ^7.4.0"
+ }
+ },
"node_modules/@angular/platform-browser": {
"version": "13.0.3",
"resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-13.0.3.tgz",
@@ -3358,6 +3399,18 @@
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=",
"dev": true
},
+ "node_modules/bootstrap": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.3.1.tgz",
+ "integrity": "sha512-rXqOmH1VilAt2DyPzluTi2blhk17bO7ef+zLLPlWvG494pDxcM234pJ8wTc/6R40UWizAIIMgxjvxZg5kmsbag==",
+ "engines": {
+ "node": ">=6"
+ },
+ "peerDependencies": {
+ "jquery": "1.9.1 - 3",
+ "popper.js": "^1.14.7"
+ }
+ },
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@@ -6722,6 +6775,12 @@
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
+ "node_modules/jquery": {
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz",
+ "integrity": "sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==",
+ "peer": true
+ },
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@@ -8561,6 +8620,17 @@
"node": ">=8"
}
},
+ "node_modules/popper.js": {
+ "version": "1.16.1",
+ "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz",
+ "integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==",
+ "deprecated": "You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1",
+ "peer": true,
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/popperjs"
+ }
+ },
"node_modules/portfinder": {
"version": "1.0.28",
"resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.28.tgz",
@@ -12700,6 +12770,23 @@
"tslib": "^2.3.0"
}
},
+ "@angular/cdk": {
+ "version": "13.0.3",
+ "resolved": "https://registry.npmjs.org/@angular/cdk/-/cdk-13.0.3.tgz",
+ "integrity": "sha512-nPlnpdLk+Lady3l5eHh+csbHPOiTvfVpMrluUEnb1RAby07QQucUo7cYOKgFiVmSmaMwDBv2aGj1fAoXKzzc5g==",
+ "requires": {
+ "parse5": "^5.0.0",
+ "tslib": "^2.3.0"
+ },
+ "dependencies": {
+ "parse5": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz",
+ "integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==",
+ "optional": true
+ }
+ }
+ },
"@angular/cli": {
"version": "13.0.4",
"resolved": "https://registry.npmjs.org/@angular/cli/-/cli-13.0.4.tgz",
@@ -12778,6 +12865,14 @@
"tslib": "^2.3.0"
}
},
+ "@angular/material": {
+ "version": "13.0.3",
+ "resolved": "https://registry.npmjs.org/@angular/material/-/material-13.0.3.tgz",
+ "integrity": "sha512-6lEofw8wWl1huNLEgngYfIDA7dY4oSq0sB7F16foDfenC+TokRxfIN950GKNYmvGVYqODUuQdrQ1n2bXE2GQGg==",
+ "requires": {
+ "tslib": "^2.3.0"
+ }
+ },
"@angular/platform-browser": {
"version": "13.0.3",
"resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-13.0.3.tgz",
@@ -14943,6 +15038,12 @@
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=",
"dev": true
},
+ "bootstrap": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.3.1.tgz",
+ "integrity": "sha512-rXqOmH1VilAt2DyPzluTi2blhk17bO7ef+zLLPlWvG494pDxcM234pJ8wTc/6R40UWizAIIMgxjvxZg5kmsbag==",
+ "requires": {}
+ },
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@@ -17472,6 +17573,12 @@
}
}
},
+ "jquery": {
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz",
+ "integrity": "sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==",
+ "peer": true
+ },
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@@ -18855,6 +18962,12 @@
"find-up": "^4.0.0"
}
},
+ "popper.js": {
+ "version": "1.16.1",
+ "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz",
+ "integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==",
+ "peer": true
+ },
"portfinder": {
"version": "1.0.28",
"resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.28.tgz",
diff --git a/package.json b/package.json
index 4011c83..c0ca662 100644
--- a/package.json
+++ b/package.json
@@ -11,10 +11,12 @@
"private": true,
"dependencies": {
"@angular/animations": "~13.0.0",
+ "@angular/cdk": "^13.0.3",
"@angular/common": "~13.0.0",
"@angular/compiler": "~13.0.0",
"@angular/core": "~13.0.0",
"@angular/forms": "~13.0.0",
+ "@angular/material": "^13.0.3",
"@angular/platform-browser": "~13.0.0",
"@angular/platform-browser-dynamic": "~13.0.0",
"@angular/router": "~13.0.0",
@@ -36,4 +38,4 @@
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.4.3"
}
-}
+}
\ No newline at end of file
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 0297262..3ba5928 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -1,7 +1,9 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
-const routes: Routes = [];
+const routes: Routes = [
+
+];
@NgModule({
imports: [RouterModule.forRoot(routes)],
diff --git a/src/app/app.component.html b/src/app/app.component.html
index e11ca59..022ce98 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -1,484 +1,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{{ title }} app is running!
-
-
-
-
-
-
-
Resources
-
Here are some links to help you get started:
-
-
-
-
- Learn Angular
-
-
-
-
- CLI Documentation
-
-
-
-
-
- Angular Material
-
-
-
-
-
- Angular Blog
-
-
-
-
-
- Angular DevTools
-
-
-
+
+ Phone Book
+
+
+
+
+
-
-
-
Next Steps
-
What do you want to do next with your app?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ng generate component xyz
-
ng add @angular/material
-
ng add @angular/pwa
-
ng add _____
-
ng test
-
ng build
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/app/app.component.less b/src/app/app.component.less
index e69de29..55d09ed 100644
--- a/src/app/app.component.less
+++ b/src/app/app.component.less
@@ -0,0 +1,39 @@
+mat-toolbar {
+ margin-bottom: 20px;
+ }
+
+ mat-toolbar > span {
+ margin-left: 10px;
+ }
+
+ .content-wrapper {
+ max-width: 1400px;
+ margin: auto;
+ }
+
+ .container-wrapper {
+ display: flex;
+ justify-content: space-around;
+ }
+
+ .container {
+ width: 100%;
+ margin: 0 25px 25px 0;
+ }
+
+ .list {
+ border: solid 1px #ccc;
+ min-height: 60px;
+ border-radius: 4px;
+ }
+
+ .new-record {
+ margin-bottom: 30px;
+ }
+
+ .empty-label {
+ font-size: 2em;
+ padding-top: 10px;
+ text-align: center;
+ opacity: 0.2;
+ }
\ No newline at end of file
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index ed7f3b5..f69757a 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,4 +1,7 @@
import { Component } from '@angular/core';
+import { Record } from './record/record';
+import { MatDialog } from '@angular/material/dialog';
+import { RecordDialogComponent, RecordDialogResult } from './record-dialog/record-dialog.component';
@Component({
selector: 'app-root',
@@ -7,4 +10,57 @@ import { Component } from '@angular/core';
})
export class AppComponent {
title = 'PhoneBook';
+ phoneBook: Record[] = [
+ {
+ name: 'Erdélyi Áron',
+ phoneNumber: '+36707746229'
+ },
+ {
+ name: 'Erdélyi Zsombor',
+ phoneNumber: '+36707746230'
+ }
+ ];
+
+ constructor(private dialog: MatDialog) {}
+
+ newRecord() : void {
+ const dialogRef = this.dialog.open(RecordDialogComponent, {
+ width: '270px',
+ data: {
+ record: {},
+ },
+ });
+ dialogRef
+ .afterClosed()
+ .subscribe((result: RecordDialogResult|undefined) => {
+ if (!result) {
+ return;
+ }
+ this.phoneBook.push(result.record);
+ });
+ }
+
+ editRecord(record: Record): void {
+ const dialogRef = this.dialog.open(RecordDialogComponent, {
+ width: '270px',
+ data: {
+ record: {
+ name: record.name,
+ phoneNumber: record.phoneNumber
+ }
+ },
+ });
+ dialogRef.afterClosed().subscribe((result: RecordDialogResult|undefined) => {
+ if (!result) {
+ return;
+ }
+ const index = this.phoneBook.indexOf(record);
+ this.phoneBook[index] = result.record;
+ });
+ }
+
+ deleteRecord(record: Record): void {
+ const index = this.phoneBook.indexOf(record);
+ this.phoneBook.splice(index, 1);
+ }
}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index b1c6c96..170ed4a 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -3,14 +3,37 @@ import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+
+import { MatToolbarModule } from '@angular/material/toolbar';
+import { RecordComponent } from './record/record.component';
+import { MatCardModule } from '@angular/material/card';
+import { MatButtonModule } from '@angular/material/button';
+import { MatDialogModule } from '@angular/material/dialog';
+import { RecordDialogComponent } from './record-dialog/record-dialog.component';
+import { MatInputModule } from '@angular/material/input';
+import { FormsModule } from '@angular/forms';
+import { MatIconModule } from '@angular/material/icon';
+import { MatGridListModule } from '@angular/material/grid-list';
@NgModule({
declarations: [
- AppComponent
+ AppComponent,
+ RecordComponent,
+ RecordDialogComponent
],
imports: [
BrowserModule,
- AppRoutingModule
+ AppRoutingModule,
+ BrowserAnimationsModule,
+ MatToolbarModule,
+ MatCardModule,
+ MatButtonModule,
+ MatDialogModule,
+ MatInputModule,
+ FormsModule,
+ MatIconModule,
+ MatGridListModule
],
providers: [],
bootstrap: [AppComponent]
diff --git a/src/app/record-dialog/record-dialog.component.html b/src/app/record-dialog/record-dialog.component.html
new file mode 100644
index 0000000..80625e3
--- /dev/null
+++ b/src/app/record-dialog/record-dialog.component.html
@@ -0,0 +1,14 @@
+
+ Name
+
+
+
+
+ Phone number
+
+
+
+
+
+
+
diff --git a/src/app/record-dialog/record-dialog.component.less b/src/app/record-dialog/record-dialog.component.less
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/record-dialog/record-dialog.component.spec.ts b/src/app/record-dialog/record-dialog.component.spec.ts
new file mode 100644
index 0000000..617210b
--- /dev/null
+++ b/src/app/record-dialog/record-dialog.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { RecordDialogComponent } from './record-dialog.component';
+
+describe('RecordDialogComponent', () => {
+ let component: RecordDialogComponent;
+ let fixture: ComponentFixture
;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ RecordDialogComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(RecordDialogComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/record-dialog/record-dialog.component.ts b/src/app/record-dialog/record-dialog.component.ts
new file mode 100644
index 0000000..20e8966
--- /dev/null
+++ b/src/app/record-dialog/record-dialog.component.ts
@@ -0,0 +1,27 @@
+import { Component, OnInit, Inject } from '@angular/core';
+import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
+import { Record } from '../record/record';
+
+@Component({
+ selector: 'app-record-dialog',
+ templateUrl: './record-dialog.component.html',
+ styleUrls: ['./record-dialog.component.less']
+})
+export class RecordDialogComponent implements OnInit {
+ constructor(
+ public dialogRef: MatDialogRef,
+ @Inject(MAT_DIALOG_DATA) public data: RecordDialogData
+ ) {}
+
+ ngOnInit(): void {
+ }
+
+}
+
+export interface RecordDialogData {
+ record: Partial;
+}
+
+export interface RecordDialogResult {
+ record: Record;
+}
diff --git a/src/app/record/record.component.html b/src/app/record/record.component.html
new file mode 100644
index 0000000..608f6d0
--- /dev/null
+++ b/src/app/record/record.component.html
@@ -0,0 +1,23 @@
+
+
+
+ {{ record.name }}
+
+
+
+
+
+
+
+
+
+ {{ record.phoneNumber }}
+
+
+
+
+
diff --git a/src/app/record/record.component.less b/src/app/record/record.component.less
new file mode 100644
index 0000000..46ca5cb
--- /dev/null
+++ b/src/app/record/record.component.less
@@ -0,0 +1,7 @@
+:host {
+ display: block;
+ }
+
+ .item {
+ margin-bottom: 10px;
+ }
\ No newline at end of file
diff --git a/src/app/record/record.component.spec.ts b/src/app/record/record.component.spec.ts
new file mode 100644
index 0000000..7953d49
--- /dev/null
+++ b/src/app/record/record.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { RecordComponent } from './record.component';
+
+describe('RecordComponent', () => {
+ let component: RecordComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ RecordComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(RecordComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/record/record.component.ts b/src/app/record/record.component.ts
new file mode 100644
index 0000000..5bd0aa7
--- /dev/null
+++ b/src/app/record/record.component.ts
@@ -0,0 +1,19 @@
+import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
+import { Record } from './record';
+
+@Component({
+ selector: 'app-record',
+ templateUrl: './record.component.html',
+ styleUrls: ['./record.component.less']
+})
+export class RecordComponent implements OnInit {
+ @Input() record: Record | null = null;
+ @Output() edit = new EventEmitter();
+ @Output() delete = new EventEmitter();
+
+ constructor() { }
+
+ ngOnInit(): void {
+ }
+
+}
diff --git a/src/app/record/record.ts b/src/app/record/record.ts
new file mode 100644
index 0000000..ddae73f
--- /dev/null
+++ b/src/app/record/record.ts
@@ -0,0 +1,5 @@
+export interface Record {
+ id?: string;
+ name: string;
+ phoneNumber: string;
+ }
\ No newline at end of file
diff --git a/src/index.html b/src/index.html
index a3eb31d..0544220 100644
--- a/src/index.html
+++ b/src/index.html
@@ -6,8 +6,11 @@
+
+
+
-
+
diff --git a/src/styles.less b/src/styles.less
index 90d4ee0..7e7239a 100644
--- a/src/styles.less
+++ b/src/styles.less
@@ -1 +1,4 @@
/* You can add global styles to this file, and also import other style files */
+
+html, body { height: 100%; }
+body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }