Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into ft-1754-flyout-action-button
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbaud-StewartStephens authored Jun 29, 2018
2 parents f8588bd + 1d7aae7 commit 3647d18
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 26 deletions.
4 changes: 4 additions & 0 deletions src/locales/resources_en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
"_description": "error message shown when an invalid date is entered.",
"message": "Please enter a valid date"
},
"date_field_default_label": {
"_description": "The label for the datepicker component's input field for screen readers when the consumer has not specified a label.",
"message": "Date input field."
},
"date_range_picker_at_any_time": {
"_description": "text for date range picker",
"message": "At any time"
Expand Down
13 changes: 11 additions & 2 deletions src/modules/datepicker/datepicker-input.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import {
import {
SkyDatepickerConfigService
} from './datepicker-config.service';
import {
SkyResourcesService
} from '../resources';

// tslint:disable:no-forward-ref no-use-before-declare
const SKY_DATEPICKER_VALUE_ACCESSOR = {
Expand Down Expand Up @@ -80,13 +83,13 @@ export class SkyDatepickerInputDirective implements
public startingDay: number = 0;

private dateFormatter = new SkyDateFormatter();

private modelValue: Date;

public constructor(
private renderer: Renderer,
private elRef: ElementRef,
private config: SkyDatepickerConfigService) {
private config: SkyDatepickerConfigService,
private skyResourceSvc: SkyResourcesService) {
this.configureOptions();
}

Expand All @@ -101,6 +104,12 @@ export class SkyDatepickerInputDirective implements
this.writeValue(newDate);
this._onChange(newDate);
});
if (!this.elRef.nativeElement.getAttribute('aria-label')) {
this.renderer.setElementAttribute(
this.elRef.nativeElement,
'aria-label',
this.skyResourceSvc.getString('date_field_default_label'));
}
}

public ngOnDestroy() {
Expand Down
3 changes: 2 additions & 1 deletion src/modules/datepicker/datepicker.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

<div class="sky-input-group-btn sky-input-group-datepicker-btn">
<sky-dropdown
buttonType="calendar"
alignment="right"
aria-hidden="true"
buttonType="calendar"
[messageStream]="dropdownController">
<sky-dropdown-menu>
<sky-datepicker-calendar
Expand Down
11 changes: 11 additions & 0 deletions src/modules/datepicker/datepicker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ describe('datepicker', () => {
.not.toBeNull();
});

it('should apply aria-label to the datepicker input when none is provided', () => {
fixture.detectChanges();
expect(nativeElement.querySelector('input').getAttribute('aria-label')).toBe('Date input field.');
});

it('should not overwrite aria-label on the datepicker input when one is provided', () => {
nativeElement.querySelector('input').setAttribute('aria-label', 'This is a date field.');
fixture.detectChanges();
expect(nativeElement.querySelector('input').getAttribute('aria-label')).toBe('This is a date field.');
});

it('should keep the calendar open on mode change', fakeAsync(() => {
fixture.detectChanges();
openDatepicker(nativeElement, fixture);
Expand Down
23 changes: 19 additions & 4 deletions src/modules/wait/wait.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {
ApplicationRef
} from '@angular/core';
import {
TestBed,
inject,
Expand All @@ -12,10 +15,9 @@ import {
import {
SkyWaitService
} from './wait.service';

import {
ApplicationRef
} from '@angular/core';
SkyWindowRefService
} from '../window';

describe('Wait service', () => {
let waitService: SkyWaitService;
Expand All @@ -30,6 +32,9 @@ describe('Wait service', () => {
TestBed.configureTestingModule({
imports: [
SkyWaitFixturesModule
],
providers: [
SkyWindowRefService
]
});
});
Expand All @@ -38,7 +43,8 @@ describe('Wait service', () => {
inject(
[
ApplicationRef,
SkyWaitService
SkyWaitService,
SkyWindowRefService
],
(
_applicationRef: ApplicationRef,
Expand Down Expand Up @@ -176,6 +182,15 @@ describe('Wait service', () => {
verifyBlockingPageWaitExists(false);
}));

it('should clear wait even if closed too fast', fakeAsync(() => {
waitService.beginNonBlockingPageWait();
waitService.clearAllPageWaits();
tick();

verifyNonBlockingPageWaitExists(false);
verifyBlockingPageWaitExists(false);
}));

it('should only clear waits if waitcomponent not created', fakeAsync(() => {
waitService.clearAllPageWaits();
tick();
Expand Down
48 changes: 29 additions & 19 deletions src/modules/wait/wait.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {
import {
SkyWaitPageAdapterService
} from './wait-page-adapter.service';
import {
SkyWindowRefService
} from '../window';

@Injectable()
export class SkyWaitService {
Expand All @@ -22,7 +25,8 @@ export class SkyWaitService {
constructor(
private resolver: ComponentFactoryResolver,
private appRef: ApplicationRef,
private waitAdapter: SkyWaitPageAdapterService
private waitAdapter: SkyWaitPageAdapterService,
private windowSvc: SkyWindowRefService
) {}

public beginBlockingPageWait() {
Expand Down Expand Up @@ -71,7 +75,7 @@ export class SkyWaitService {
Dynamic component creation needs to be done in a timeout to prevent ApplicationRef from
crashing when wait service is called in Angular lifecycle functions.
*/
setTimeout(() => {
this.windowSvc.getWindow().setTimeout(() => {
let factory = this.resolver.resolveComponentFactory(SkyWaitPageComponent);

this.waitAdapter.addPageWaitEl();
Expand All @@ -90,25 +94,31 @@ export class SkyWaitService {
}

private endPageWait(isBlocking: boolean) {
if (SkyWaitService.waitComponent) {
if (isBlocking) {
if (SkyWaitService.pageWaitBlockingCount > 0) {
SkyWaitService.pageWaitBlockingCount--;
}

if (SkyWaitService.pageWaitBlockingCount < 1) {
SkyWaitService.waitComponent.hasBlockingWait = false;
}
} else {
if (SkyWaitService.pageWaitNonBlockingCount > 0) {
SkyWaitService.pageWaitNonBlockingCount--;
}

if (SkyWaitService.pageWaitNonBlockingCount < 1) {
SkyWaitService.waitComponent.hasNonBlockingWait = false;
/*
Needs to yield so that wait creation can finish
before it is dismissed in the event of a race.
*/
this.windowSvc.getWindow().setTimeout(() => {
if (SkyWaitService.waitComponent) {
if (isBlocking) {
if (SkyWaitService.pageWaitBlockingCount > 0) {
SkyWaitService.pageWaitBlockingCount--;
}

if (SkyWaitService.pageWaitBlockingCount < 1) {
SkyWaitService.waitComponent.hasBlockingWait = false;
}
} else {
if (SkyWaitService.pageWaitNonBlockingCount > 0) {
SkyWaitService.pageWaitNonBlockingCount--;
}

if (SkyWaitService.pageWaitNonBlockingCount < 1) {
SkyWaitService.waitComponent.hasNonBlockingWait = false;
}
}
}
}
});
}

private clearPageWait(isBlocking: boolean) {
Expand Down

0 comments on commit 3647d18

Please sign in to comment.