-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* info-child-box works * style fix * refactoring * fix * directive * style
- Loading branch information
Showing
38 changed files
with
640 additions
and
209 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/app/shared/components/child-info-box/child-info-box.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<mat-card class="card" #childInfoBox [style]="{top:top, left:left}"> | ||
<mat-card-header fxLayout='column' fxLayoutAlign='center start'> | ||
<div mat-card-avatar fxLayout='column' fxLayoutAlign='center start'></div> | ||
<mat-card-title>ДАНІ ДИТИНИ</mat-card-title> | ||
<h3>{{child.firstName}} {{child.lastName}} {{child.patronymic}}</h3> | ||
<h4>{{child.birthDay}}</h4><br> | ||
</mat-card-header> | ||
<mat-card-content fxLayout='column' fxLayoutAlign='center start'> | ||
<h4>Соціальна група</h4> | ||
<p>Відсутня</p> | ||
<h4>Батьки</h4> | ||
<p>{{child.parent?.firstName}} {{child.parent.lastName}} {{child.parent.secondName}}</p> | ||
<h4>Телефон</h4> | ||
<p>{{child.parent?.phone}}</p> | ||
<h4>Емейл</h4> | ||
<p>{{child.parent?.email}}</p> | ||
</mat-card-content> | ||
</mat-card> |
11 changes: 11 additions & 0 deletions
11
src/app/shared/components/child-info-box/child-info-box.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.card{ | ||
display: block; | ||
position: absolute; | ||
z-index: 2; | ||
background:white; | ||
box-shadow: 0px 6px 16px rgba(0, 0, 0, 0.08); | ||
min-width:400px; | ||
border-radius: 5px; | ||
padding: 1rem; | ||
margin: 1rem 0; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/app/shared/components/child-info-box/child-info-box.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ChildInfoBoxComponent } from './child-info-box.component'; | ||
|
||
describe('ChildInfoBoxComponent', () => { | ||
let component: ChildInfoBoxComponent; | ||
let fixture: ComponentFixture<ChildInfoBoxComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ ChildInfoBoxComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ChildInfoBoxComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
src/app/shared/components/child-info-box/child-info-box.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core'; | ||
import { Child } from '../../models/child.model'; | ||
|
||
@Component({ | ||
selector: 'app-child-info-box', | ||
templateUrl: './child-info-box.component.html', | ||
styleUrls: ['./child-info-box.component.scss'] | ||
}) | ||
export class ChildInfoBoxComponent implements OnInit { | ||
|
||
constructor() { } | ||
|
||
@Input() child: Child; | ||
@ViewChild('childInfoBox') childInfoBox: ElementRef<HTMLInputElement>; | ||
@Input() top: string; | ||
@Input() left: string; | ||
|
||
ngOnInit(): void { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { InfoBoxHostDirective } from './info-box-host.directive'; | ||
|
||
describe('InfoBoxHostDirective', () => { | ||
it('should create an instance', () => { | ||
const directive = new InfoBoxHostDirective(); | ||
expect(directive).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Directive, ViewContainerRef } from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: '[appInfoBoxHost]' | ||
}) | ||
export class InfoBoxHostDirective { | ||
|
||
constructor(public viewContainerRef: ViewContainerRef) { } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
|
||
import { Parent } from "./parent.model"; | ||
export class Child { | ||
firstName: string; | ||
lastName: string; | ||
secondName: string; | ||
birthDay: Date; | ||
patronymic: string; | ||
birthDay: string; | ||
type: Boolean; | ||
gender: string; | ||
gender: number; | ||
parent: Parent; | ||
socialGroupId: number; | ||
|
||
|
||
constructor(info) { | ||
this.firstName = info.firstName; | ||
this.lastName= info.lastName; | ||
this.secondName= info.secondName; | ||
this.birthDay= info.birthDay; | ||
this.type = info.type; | ||
this.gender = info.gender; | ||
this.lastName = info.lastName; | ||
this.patronymic = info.second; | ||
this.birthDay = "2021-04-27"; | ||
this.gender = 0; | ||
this.socialGroupId = 0; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export class Parent { | ||
firstName: string; | ||
lastName: string; | ||
secondName: string; | ||
birthDay: Date; | ||
gender: string; | ||
phone: string; | ||
email: string; | ||
|
||
constructor(info) { | ||
this.firstName = info.firstName; | ||
this.lastName = info.lastName; | ||
this.secondName = info.secondName; | ||
this.birthDay = info.birthDay; | ||
this.gender = info.gender; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Workshop } from "./workshop.model"; | ||
|
||
export class Provider { | ||
title: string; | ||
phone: string; | ||
email: string; | ||
workshop: Workshop | ||
|
||
constructor(info) { | ||
this.title = info.title; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { InfoBoxService } from './info-box.service'; | ||
|
||
describe('InfoBoxService', () => { | ||
let service: InfoBoxService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(InfoBoxService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Component, ComponentFactoryResolver, Injectable, Type, ViewContainerRef } from '@angular/core'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { ChildInfoBoxComponent } from '../../components/child-info-box/child-info-box.component'; | ||
import { Child } from '../../models/child.model'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class InfoBoxService { | ||
|
||
private isMouseOver = new BehaviorSubject(false); | ||
isMouseOver$ = this.isMouseOver.asObservable(); | ||
child: Child; | ||
top: string; | ||
left: string; | ||
|
||
constructor(private cfr: ComponentFactoryResolver) { } | ||
|
||
onMouseOver({ element, child }: { element: Element, child: Child }) { | ||
this.isMouseOver.next(true); | ||
this.child = child; | ||
this.getPosition(element); | ||
} | ||
|
||
onMouseLeave() { | ||
this.isMouseOver.next(false); | ||
} | ||
|
||
async loadComponent(vcr: ViewContainerRef, isMouseOver: boolean) { | ||
const { ChildInfoBoxComponent } = await import('../../components/child-info-box/child-info-box.component'); | ||
|
||
vcr.clear(); | ||
const component: Type<ChildInfoBoxComponent> = ChildInfoBoxComponent; | ||
if (isMouseOver) { | ||
const componentRef = vcr.createComponent(this.cfr.resolveComponentFactory(component)); | ||
|
||
(<ChildInfoBoxComponent>componentRef.instance).child = this.child ? this.child : null; | ||
(<ChildInfoBoxComponent>componentRef.instance).top = this.top ? this.top : null; | ||
(<ChildInfoBoxComponent>componentRef.instance).left = this.left ? this.left : null; | ||
|
||
return componentRef; | ||
} | ||
} | ||
|
||
/** | ||
* This method get position pf emitted element | ||
* @param Element element | ||
*/ | ||
getPosition(element: Element): void { | ||
const bodyRect = document.body.getBoundingClientRect(); | ||
const elementRect = element.getBoundingClientRect(); | ||
const offset = elementRect.top - bodyRect.top + 20; | ||
this.top = offset + 'px'; | ||
this.left = elementRect.left + 'px'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.