Skip to content

Commit

Permalink
feat(selector): add selectors to CV features
Browse files Browse the repository at this point in the history
  • Loading branch information
Yrkki committed May 20, 2021
1 parent 2af1b65 commit 1749b3a
Show file tree
Hide file tree
Showing 34 changed files with 425 additions and 79 deletions.
8 changes: 8 additions & 0 deletions e2e/src/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ describe('workspace-project App', () => {
expect(() => page.navigateToModule('toolbar')).toBeTruthy();
});

it('should be able to navigate to the Selector module', () => {
expect(() => page.navigateToModule('selector')).toBeTruthy();
});

it('should be able to navigate to the SelectorHeader module', () => {
expect(() => page.navigateToModule('selector-header')).toBeTruthy();
});

// [% e2e-test-placeholder %]

// afterEach(waitForAsync() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class AccomplishmentsComponent implements AfterViewInit {
/**
* Update whether should collapse the projects accomplishments section mouse event handler.
*
* @param event The click event initiating the save.
* @param event The initiating click event.
*/
public updateShouldCollapseProjectsAccomplishmentHandler(event: MouseEvent) {
const targetElement = event.currentTarget as HTMLElement;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<span class='frequency'>
<ng-container *ngIf='frequency'>
<a [ngStyle]="getFrequencyStyle(frequency)" #clickable (keypress)="keypress($event)"
(click)='updateSearchToken(frequency[0]);' title="{{ frequency[1].Label + '\n\n' + ui['Search for this']?.text }}"
(click)='updateSearchToken($event);' title="{{ frequency[1].Label + '\n\n' + ui['Search for this']?.text }}"
[attr.aria-label]="frequency[0]">{{ frequency[0] }}</a>
</ng-container>
</span>
22 changes: 20 additions & 2 deletions src/app/components/course-index/course-index.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { TestingCommon } from '../../classes/testing-common/testing-common.spec';

import { Accomplishment } from '../../classes/accomplishment/accomplishment';

import { CourseIndexComponent } from './course-index.component';

import { SorterService } from '../../services/sorter/sorter.service';
Expand Down Expand Up @@ -62,15 +64,31 @@ describe('CourseIndexComponent', () => {
}).not.toThrowError();
});

it('should check public interface', () => {
it('should check public interface properties', () => {
expect(() => {
let readAll;
readAll = component.key;
const accomplishment = component.propertyName = new Accomplishment();
accomplishment.Language = 'some language';
readAll = component.key;

readAll = component.frequency;
readAll = component.getFrequenciesCache(component.key);
accomplishment.Language = '';
['Certification', 'Conference', 'Brigade', 'Ownership', 'Training', 'Language course'].forEach((_) => {
accomplishment.Type = _;
readAll = component.frequency;
});

readAll = component.frequenciesDivider;
}).not.toThrowError();
});

it('should check public interface methods', () => {
expect(() => {
let readAll;
readAll = component.getFrequenciesCache(component.key);
readAll = component.getFrequencyStyle(component.engine.filterService.emptyFrequency);
readAll = component.updateSearchToken(new MouseEvent('click'));
}).not.toThrowError();
});

Expand Down
2 changes: 1 addition & 1 deletion src/app/components/course-index/course-index.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class CourseIndexComponent extends PropertyComponent {
public get frequenciesDivider() { return this.uiService.frequenciesDivider; }

/** Update search token delegate. */
public updateSearchToken(newValue: string) { this.engine.searchService.updateSearchToken(newValue); }
public updateSearchToken(event: MouseEvent) { this.engine.searchService.updateSearchToken(event); }

/**
* Constructs the Course index component.
Expand Down
47 changes: 24 additions & 23 deletions src/app/components/education/education.component.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
<div class="container-fluid">
<div class="row">
<div class="col-md-3 cell-key">
<ng-container *ngComponentOutlet="PropertyComponent"></ng-container>
</div>
<div class="col-md-9 cell-value">
<ng-container *ngIf="propertyName['Link']; else elseBlock">
<a class="d-inline-block" href="{{ propertyName['Link'] }}" target="_blank" rel="noopener noreferrer"
[attr.aria-label]="linkLabel(ui['Education']?.text)">
<img src="{{ getBackgroundLogoImageUri(propertyName['Image']) }}" onerror="this.style.display='none'"
class="thumbnail" alt="" /> {{ propertyName['School'] }}
</a>
</ng-container>
<ng-template #elseBlock>{{ propertyName['School'] }}</ng-template>
<div *ngIf="schoolSubject.length > 0" class="{{ propertyName['Highlight'] }} half-line-trailing">
{{ schoolSubject }}
</div>
<div *ngIf="honors">
<span class="detailHanging"></span>{{ honors ? detailBullet : '' }} {{ honors }}
<app-selector-header [key]="propertyName.School">
<div class="container-fluid">
<div class="row">
<div class="col-md-3 cell-key">
<ng-container *ngComponentOutlet="PropertyComponent"></ng-container>
</div>
<div *ngFor="let line of description; trackBy: trackByFn">
<span class="detailHanging">{{ line ? detailBullet : '' }} {{ line }}</span>
<br />
<div class="col-md-9 cell-value">
<ng-container *ngIf="propertyName['Link']; else elseBlock">
<a class="d-inline-block" href="{{ propertyName['Link'] }}" target="_blank" rel="noopener noreferrer"
[attr.aria-label]="linkLabel(ui['Education']?.text)">
<img src="{{ getBackgroundLogoImageUri(propertyName['Image']) }}" onerror="this.style.display='none'"
class="thumbnail" alt="" /> {{ propertyName['School'] }}
</a>
</ng-container>
<ng-template #elseBlock>{{ propertyName['School'] }}</ng-template>
<div *ngIf="schoolSubject.length > 0" class="{{ propertyName['Highlight'] }} half-line-trailing">
{{ schoolSubject }}
</div>
<div *ngIf="honors">
<app-selector [text]="[honors ? detailBullet : '', honors].join(' ')"></app-selector>
</div>
<div *ngFor="let line of description; trackBy: trackByFn">
<app-selector [text]="[line ? detailBullet : '', line].join(' ')"></app-selector>
</div>
</div>
</div>
</div>
</div>
</app-selector-header>
12 changes: 6 additions & 6 deletions src/app/components/education/education.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ export class EducationComponent extends PropertyComponent {
* @param params The inherited injector params injected dependency.
*/
constructor(
public portfolioService: PortfolioService,
public inputService: InputService,
public uiService: UiService,
public dataService: DataService,
public excelDateFormatterService: ExcelDateFormatterService,
public params?: Params) {
public readonly portfolioService: PortfolioService,
public readonly inputService: InputService,
public readonly uiService: UiService,
public readonly dataService: DataService,
public readonly excelDateFormatterService: ExcelDateFormatterService,
public readonly params?: Params) {
super(portfolioService, inputService, uiService, dataService, excelDateFormatterService, params);
}

Expand Down
20 changes: 11 additions & 9 deletions src/app/components/personal-data/personal-data.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<div class="container-fluid">
<div class="row">
<div class="col-md-3 cell-key">
{{ propertyName['Caption'] }}
</div>
<div class="col-md-9 cell-value">
<div class="{{ propertyName['Highlight'] }}">
{{ propertyName['Personal data'] }}
<app-selector-header [key]="propertyName.Caption">
<div class="container-fluid">
<div class="row">
<div class="col-md-3 cell-key">
{{ propertyName['Caption'] }}
</div>
<div class="col-md-9 cell-value">
<div class="{{ propertyName['Highlight'] }}">
<app-selector [text]="propertyName['Personal data']"></app-selector>
</div>
</div>
</div>
</div>
</div>
</app-selector-header>
2 changes: 1 addition & 1 deletion src/app/components/portfolio/portfolio.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ describe('PortfolioComponent', () => {
const propertyName = 'Responsibilities';
readAll = component.portfolioService.getFrequenciesCache(propertyName);
readAll = component.portfolioService.checkToggleCollapsed(propertyName);
readAll = engine.searchService.updateSearchToken('kon');
readAll = engine.searchService.updateSearchToken(new MouseEvent('click'));
}).not.toThrowError();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div class="container-fluid">
<div class="row">
<div class="col-md-3 cell-key">
<ng-container *ngComponentOutlet="PropertyComponent"></ng-container>
</div>
<div class="col-md-9 cell-value">
<div>
<app-selector-header [key]="propertyName.Experience">
<div class="container-fluid">
<div class="row">
<div class="col-md-3 cell-key">
<ng-container *ngComponentOutlet="PropertyComponent"></ng-container>
</div>
<div class="col-md-9 cell-value">
<ng-container *ngIf="propertyName['Link']; else elseBlockExperience">
<a class="d-inline-block" href="{{ propertyName['Link'] }}" target="_blank" rel="noopener noreferrer"
[attr.aria-label]="linkLabel(ui['Experience']?.text)">
Expand All @@ -13,14 +13,14 @@
</a>
</ng-container>
<ng-template #elseBlockExperience>{{ propertyName['Experience'] }}</ng-template>
</div>
<div class="{{ propertyName['Highlight'] }} half-line-trailing">
{{ propertyName['Position'] }}
</div>
<div *ngFor="let line of description; trackBy: trackByFn">
<span class="detailHanging">{{ line ? detailBullet : '' }} {{ line }}</span>
<br />
<div class="{{ propertyName['Highlight'] }} half-line-trailing">
{{ propertyName['Position'] }}
</div>
<div *ngFor="let line of description; trackBy: trackByFn">
<app-selector [text]="[line ? detailBullet : '', line].join(' ')"></app-selector>
<br />
</div>
</div>
</div>
</div>
</div>
</app-selector-header>
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export class ProfessionalExperienceComponent extends PropertyComponent {
* @param params The inherited injector params injected dependency.
*/
constructor(
public portfolioService: PortfolioService,
public inputService: InputService,
public uiService: UiService,
public dataService: DataService,
public excelDateFormatterService: ExcelDateFormatterService,
public params?: Params) {
public readonly portfolioService: PortfolioService,
public readonly inputService: InputService,
public readonly uiService: UiService,
public readonly dataService: DataService,
public readonly excelDateFormatterService: ExcelDateFormatterService,
public readonly params?: Params) {
super(portfolioService, inputService, uiService, dataService, excelDateFormatterService, params);
}

Expand Down
6 changes: 5 additions & 1 deletion src/app/components/property/property.component.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@import "../stylesheets/stylesheets.component.scss";

.half-line-trailing {
margin-bottom: 0.0em; // 0.5em;
margin-bottom: 0em; // 0.5em;
}

span {
cursor: pointer;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<span class='frequency'>
<a [ngStyle]="getFrequencyStyle(frequency)" #clickable (keypress)="keypress($event)"
(click)='updateSearchToken(frequency[0]);' title="{{ frequency[1].Label + '\n\n' + ui['Search for this']?.text }}"
(click)='updateSearchToken($event);' title="{{ frequency[1].Label + '\n\n' + ui['Search for this']?.text }}"
[attr.aria-label]="frequency[0]">{{ frequency[0] }}</a>
</span>
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,20 @@ describe('PublicationIndexComponent', () => {
}).not.toThrowError();
});

it('should check public interface', () => {
it('should check public interface properies', () => {
expect(() => {
let readAll: any;
readAll = component.frequency;
readAll = component.getFrequenciesCache(component.key);
readAll = component.frequenciesDivider;
}).not.toThrowError();
});

it('should check public interface methods', () => {
expect(() => {
let readAll: any;
readAll = component.getFrequenciesCache(component.key);
readAll = component.getFrequencyStyle(component.engine.filterService.emptyFrequency);
readAll = component.updateSearchToken(new MouseEvent('click'));
}).not.toThrowError();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class PublicationIndexComponent extends PropertyComponent {
public get frequenciesDivider() { return this.uiService.frequenciesDivider; }

/** Update search token delegate. */
public updateSearchToken(newValue: string) { this.engine.searchService.updateSearchToken(newValue); }
public updateSearchToken(event: MouseEvent) { this.engine.searchService.updateSearchToken(event); }

/**
* Constructs the Publication component.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<header *ngIf="toolbarService.editMode || !persistenceService.getToggleValue(key)" [id]="key" #clickable
[class.collapsed]="persistenceService.getToggleValue(key)" (keypress)="inputService.keypress($event)"
(click)="$event.stopPropagation(); persistenceService.saveToggle($event)"
[attr.aria-labelledby]="uiService.tabName(key)">
<ng-content></ng-content>
</header>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "../stylesheets/stylesheets.component.scss";
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { TestingCommon } from '../../classes/testing-common/testing-common.spec';

import { SelectorHeaderComponent } from './selector-header.component';

import { AppModule } from '../../app.module';
import { FormsModule } from '@angular/forms';
import { APP_BASE_HREF } from '@angular/common';

// eslint-disable-next-line max-lines-per-function
describe('SelectorHeaderComponent', () => {
let component: SelectorHeaderComponent;
let fixture: ComponentFixture<SelectorHeaderComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [
AppModule,
FormsModule
],
providers: [
SelectorHeaderComponent,
{ provide: APP_BASE_HREF, useValue: '/' }
]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(SelectorHeaderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});

it('should check lifecycle hooks', () => {
expect(() => {
TestingCommon.checkLifecycleHooks(component);
}).not.toThrowError();
});

it('should initialize', () => {
expect(() => { component.Initialize(); }).not.toThrowError();
});

it('should simulate mouse click', () => {
expect(() => {
TestingCommon.shouldSimulateMouseClick([component.clickable]);
}).not.toThrowError();
});

it('should simulate mouse click using keyboard', () => {
expect(() => {
TestingCommon.shouldSimulateMouseClickUsingKeyboard([component.clickable]);
}).not.toThrowError();
});

it('should check public interface properties', () => {
expect(() => {
// let readAll;
component.key = component.key;
}).not.toThrowError();
});

it('should check public interface methods', () => {
expect(() => {
// let readAll;
}).not.toThrowError();
});
});

0 comments on commit 1749b3a

Please sign in to comment.