Skip to content

Commit

Permalink
fix: misc updates according to PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-stepanenko committed Apr 19, 2022
1 parent 10b0ce9 commit ec0b381
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@
<button fd-nested-list-expand-icon></button>
</div>
<ul fd-nested-list>
<ng-container *ngFor="let item of section.content; trackBy: trackBySectionContent">
<ng-container *ngIf="$any(item).subItems as itemSubItems; else rootListItem">
<ng-container
*ngFor="
let item of $asSectionNestedContent(section.content);
trackBy: trackBySectionContent
"
>
<ng-container *ngIf="item.subItems as itemSubItems; else rootListItem">
<li fd-nested-list-item [expanded]="true">
<div fd-nested-list-content>
<a fd-nested-list-link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export class SectionsToolbarComponent implements OnInit, OnChanges {
return window.innerWidth < SMALL_SCREEN_BREAKPOINT;
}

constructor() {}
/** @hidden type enforcing */
$asSectionNestedContent = (sectionContent: SectionInterfaceContent[]): SectionInterfaceContentNested[] =>
<any>sectionContent;

ngOnInit(): void {
this.onActivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ export class PlatformChekboxTristateComponent implements AfterViewInit {
public cities = new FormGroup({});
public citiesData = new SomeObject(false, 'Yes', null, false, true, null, null, false);

public agreementsFormGroup = new FormGroup({});

public registrationForm = new FormGroup({
agreements: new FormGroup({})
agreements: this.agreementsFormGroup
});

get agreementsFormGroup(): FormGroup {
return this.registrationForm.get('agreements') as FormGroup;
}

public choices: Record<string, any> = { termsAndConditions: true, marketing: true, newsletter: false };

// code for nested form group with tristate checkbox.
Expand Down
16 changes: 7 additions & 9 deletions apps/docs/src/app/schema/pipes/type-casting.pipe.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { Pipe, PipeTransform } from '@angular/core';
import { AbstractControl, FormControl, FormGroup } from '@angular/forms';

@Pipe({ name: 'asFormGroup' })
export class AsFormGroupPipe implements PipeTransform {
transform(value: AbstractControl): FormGroup {
return value as FormGroup;
abstract class TypeEnforcerPipe<AsType, OriginalType = any> implements PipeTransform {
transform(value: OriginalType): AsType {
return (<any>value) as AsType;
}
}

@Pipe({ name: 'asFormGroup' })
export class AsFormGroupPipe extends TypeEnforcerPipe<FormGroup, AbstractControl> implements PipeTransform {}

@Pipe({ name: 'asFormControl' })
export class AsFormControlPipe implements PipeTransform {
transform(value: AbstractControl): FormControl {
return value as FormControl;
}
}
export class AsFormControlPipe extends TypeEnforcerPipe<FormControl, AbstractControl> implements PipeTransform {}
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class CheckboxGroupComponent extends InLineLayoutCollectionBaseInput {

/** @hidden */
public getListItemDisabledValue(item: CheckboxGroupComponent['list'][number]): boolean {
return this.disabled || (typeof item === 'object' && !!(<SelectItem>item).disabled);
return this.disabled || !!(<SelectItem>item)?.disabled;
}

/** @hidden */
Expand Down

0 comments on commit ec0b381

Please sign in to comment.