Skip to content

Commit

Permalink
fix(core): Disable inferrable-types | cleanup (#3377)
Browse files Browse the repository at this point in the history
  • Loading branch information
salarenko committed Sep 24, 2020
1 parent 2efd34c commit 4254588
Show file tree
Hide file tree
Showing 25 changed files with 48 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class CalendarMobileExampleComponent {
verticalPadding: false,
width: '640px',
height: '400px'
} as DialogConfig);
});
}

openPortraitDialog(dialog: TemplateRef<any>): void {
Expand All @@ -28,7 +28,7 @@ export class CalendarMobileExampleComponent {
verticalPadding: false,
width: '360px',
height: '640px'
} as DialogConfig);
});
}

dateChanged(date: FdDate): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ComponentBasedDialogExampleComponent {
]
},
width: '400px'
} as DialogConfig);
});

dialogRef.afterClosed.subscribe(
(result) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class DialogBackdropContainerExampleComponent {
responsivePadding: true,
backdropClass: 'dialog-custom-overlay-example',
data: `This dialog has a custom backdrop!`
} as DialogConfig);
});
}

openInCustomContainer(dialog, containerRef: HTMLElement): void {
Expand All @@ -35,7 +35,7 @@ export class DialogBackdropContainerExampleComponent {
container: containerRef,
responsivePadding: true,
data: `This dialog has been opened inside a local div!`
} as DialogConfig);
});
}

openStaticDialog(dialog, containerRef: HTMLElement): void {
Expand All @@ -46,6 +46,6 @@ export class DialogBackdropContainerExampleComponent {
responsivePadding: true,
backdropClass: 'static-dialog',
data: `This dialog has been opened inside a local div and displayed as a static element!`
} as DialogConfig);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class DialogComplexExampleComponent {
resizable: true,
verticalPadding: false,
backdropClickCloseable: false
} as DialogConfig);
});
this.dialogRef.loading(true);
setTimeout(() => this.dialogRef.loading(false), 2000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export class DialogConfigurationExample {
width: '300px',
draggable: true,
responsivePadding: true
} as DialogConfig);
});
}

openResizableDialog(template): void {
this._dialogService.open(template, {
width: '300px',
resizable: true,
responsivePadding: true
} as DialogConfig);
});
}

openClosableByButtonDialog(template): void {
Expand All @@ -30,6 +30,6 @@ export class DialogConfigurationExample {
escKeyCloseable: false,
responsivePadding: true,
backdropClickCloseable: false
} as DialogConfig);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export class DialogMobileExampleComponent {
this._dialogService.open(dialogTemplate, {
mobile: true,
responsivePadding: true
} as DialogConfig);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export class DialogPositionExampleComponent {
width: '300px',
responsivePadding: true,
position: { bottom: '100px', right: '100px' }
} as DialogConfig);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class DialogStateExample {
width: '300px',
responsivePadding: true,
data: 'This Dialog will be closed after 4s'
} as DialogConfig);
});
setTimeout(() => dialogRef.close(), 4000);
}

Expand All @@ -22,7 +22,7 @@ export class DialogStateExample {
width: '300px',
responsivePadding: true,
data: 'This Dialog will be dismissed after 4s'
} as DialogConfig);
});
setTimeout(() => dialogRef.dismiss(), 4000);
}

Expand All @@ -31,15 +31,15 @@ export class DialogStateExample {
width: '300px',
responsivePadding: true,
data: 'This Dialog will be hidden after 4s'
} as DialogConfig);
});
setTimeout(() => dialogRef.hide(true), 4000);
}

openLoadingDialog(template): void {
const dialogRef = this.dialogService.open(template, {
width: '300px',
responsivePadding: true
} as DialogConfig);
});
dialogRef.loading(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export class DialogStackedExampleComponent {
constructor(private _dialogService: DialogService) {}

openDialog(): void {
this._dialogService.open(FirstDialogExampleComponent, { responsivePadding: true } as DialogConfig);
this._dialogService.open(FirstDialogExampleComponent, { responsivePadding: true });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ export class FirstDialogExampleComponent {
constructor(@Inject(DIALOG_REF) public dialogRef: DialogRef, public _dialogService: DialogService) {}

openDialog(): void {
this._dialogService.open(SecondDialogExampleComponent, { responsivePadding: true } as DialogConfig);
this._dialogService.open(SecondDialogExampleComponent, { responsivePadding: true });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class TemplateBasedDialogExampleComponent {
constructor(private _dialogService: DialogService) {}

openDialog(dialog: TemplateRef<any>): void {
const dialogRef = this._dialogService.open(dialog, { responsivePadding: true } as DialogConfig);
const dialogRef = this._dialogService.open(dialog, { responsivePadding: true });

dialogRef.afterClosed.subscribe(
(result) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const DEFAULT_CONFIG: DialogConfig = {
draggable: true,
escKeyCloseable: false,
backdropClickCloseable: false
} as DialogConfig;
};

@NgModule({
providers: [{ provide: DIALOG_DEFAULT_CONFIG, useValue: DEFAULT_CONFIG }]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MOBILE_MODE_CONFIG, MobileModeControl, MobileModeConfigToken, DialogCon

const SELECT_MOBILE_CONFIG: MobileModeConfigToken = {
target: MobileModeControl.SELECT,
config: { hasCloseButton: true, dialogConfig: { mobileOuterSpacing: true } as DialogConfig }
config: { hasCloseButton: true, dialogConfig: { mobileOuterSpacing: true } }
};

@NgModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class MultiInputMobileExampleComponent {
hasCloseButton: true,
dialogConfig: {
ariaLabel: 'Select fruits dialog'
} as DialogConfig
}
};

values: any[] = ['Apple', 'Banana', 'Pineapple', 'Tomato', 'Kiwi', 'Strawberry', 'Blueberry', 'Orange'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export class PopoverDialogExampleComponent {
this._dialogService.open(template, {
width: '500px',
responsivePadding: true
} as DialogConfig);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class TableCustomColumnsExampleComponent {
data: {
columns: this.originalDisplayedColumns
}
} as DialogConfig);
});


dialogRef.afterClosed.subscribe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class TableToolbarExampleComponent implements OnInit {
}

openDialog(dialog: TemplateRef<any>): void {
const dialogRef = this._dialogService.open(dialog, { responsivePadding: true } as DialogConfig);
const dialogRef = this._dialogService.open(dialog, { responsivePadding: true });

dialogRef.afterClosed.subscribe(
(result) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { DialogConfig } from '@fundamental-ngx/core';
export const MOBILE_DIALOG_PORTRAIT: DialogConfig = {
width: '360px',
height: '640px'
} as DialogConfig;
};

export const MOBILE_DIALOG_LANDSCAPE: DialogConfig = {
width: '640px',
height: '360px'
} as DialogConfig;
};
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export class DialogContainerComponent implements AfterViewInit, CssClassBuilder
/** @hidden */
@applyCssClass
buildComponentCssClass(): string[] {
return [this.dialogConfig.containerClass, this._class];
return [
this.dialogConfig.containerClass ? this.dialogConfig.containerClass : '',
this._class
];
}

/** @hidden */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class DialogFooterComponent implements AfterContentInit {
@ContentChildren(TemplateDirective) customTemplates: QueryList<TemplateDirective>;

constructor(@Optional() @Inject(DIALOG_CONFIG) public dialogConfig: DialogConfig) {
this.dialogConfig = this.dialogConfig || {} as DialogConfig;
this.dialogConfig = this.dialogConfig || {};
}

/** @hidden */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class DialogHeaderComponent implements AfterContentInit {
@ContentChildren(TemplateDirective) customTemplates: QueryList<TemplateDirective>;

constructor(@Optional() @Inject(DIALOG_CONFIG) public dialogConfig: DialogConfig) {
this.dialogConfig = this.dialogConfig || {} as DialogConfig;
this.dialogConfig = this.dialogConfig || {};
}

/** @hidden */
Expand Down
4 changes: 2 additions & 2 deletions libs/core/src/lib/dialog/dialog-service/dialog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class DialogService {
* @param contentType Content of the dialog component.
* @param dialogConfig Configuration of the dialog component.
*/
public open(contentType: Type<any> | TemplateRef<any> | DefaultDialogObject, dialogConfig?: Partial<DialogConfig>): DialogRef {
public open(contentType: Type<any> | TemplateRef<any> | DefaultDialogObject, dialogConfig?: DialogConfig): DialogRef {
const dialogRef: DialogRef = new DialogRef();

dialogConfig = this._applyDefaultConfig(dialogConfig, this._defaultConfig || new DialogConfig());
Expand Down Expand Up @@ -77,7 +77,7 @@ export class DialogService {
}

/** @hidden Extends dialog config using default values*/
private _applyDefaultConfig(config: Partial<DialogConfig>, defaultConfig: DialogConfig): DialogConfig {
private _applyDefaultConfig(config: DialogConfig, defaultConfig: DialogConfig): DialogConfig {
return { ...defaultConfig, ...config };
}
}
21 changes: 11 additions & 10 deletions libs/core/src/lib/dialog/dialog-utils/dialog-config.class.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* tslint:disable:no-inferrable-types */
/**
* Configuration for opening a dialog with the DialogService.
*/
Expand Down Expand Up @@ -43,25 +44,25 @@ export class DialogConfig implements DynamicComponentConfig {
ariaDescribedBy?: string = null;

/** Whether the dialog should have a backdrop. */
hasBackdrop = true;
hasBackdrop?: boolean = true;

/** Whether clicking on the backdrop should close the dialog. Only works if hasBackdrop is true. */
backdropClickCloseable = true;
backdropClickCloseable?: boolean = true;

/** Global classes to apply to the backdrop. */
backdropClass = '';
backdropClass?: string;

/** Classes to apply to the `fd-dialog-container` */
containerClass = '';
containerClass?: string;

/** Global classes to apply to the dialog panel. */
dialogPanelClass = '';
dialogPanelClass?: string;

/** Whether the escape key should close the dialog. */
escKeyCloseable = true;
escKeyCloseable?: boolean = true;

/** Whether the dialog should be focus trapped. */
focusTrapped = true;
focusTrapped?: boolean = true;

/** The container that the dialog is appended to. By default, it is appended to the body. */
container?: HTMLElement | 'body' = 'body';
Expand All @@ -85,16 +86,16 @@ export class DialogConfig implements DynamicComponentConfig {
resizable?: boolean;

/** Whether the dialog should have vertical padding. */
verticalPadding = true;
verticalPadding?: boolean = true;

/** Whether the dialog should have responsive horizontal padding changing with Dialogs window width.
* max-width: 599px - .fd-dialog__content--s
* min-width: 600px and max-width: 1023px - .fd-dialog__content--m
* min-width: 1024px and max-width: 1439px - .fd-dialog__content--l
* min-width: 1440px - .fd-dialog__content--xl
* */
responsivePadding = false;
responsivePadding?: boolean = false;

/** Whether to close the dialog on router navigation start. */
closeOnNavigation = true;
closeOnNavigation?: boolean = true;
}
2 changes: 1 addition & 1 deletion libs/core/src/lib/dialog/dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class DialogComponent implements OnInit, AfterViewInit, OnDestroy, CssCla
this.dialogConfig.hasBackdrop ? 'fd-dialog' : '',
this.showDialogWindow ? 'fd-dialog--active' : '',
this._class,
this.dialogConfig.backdropClass
this.dialogConfig.backdropClass ? this.dialogConfig.backdropClass : ''
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('MenuMobileComponent', () => {
it('should use custom dialog configuration', fakeAsync(() => {
const customDialogClass = 'test-dialog-class';

setup({ dialogConfig: { dialogPanelClass: customDialogClass } as DialogConfig});
setup({ dialogConfig: { dialogPanelClass: customDialogClass }});

menu.open();
fixture.detectChanges();
Expand Down

0 comments on commit 4254588

Please sign in to comment.