Skip to content

Commit

Permalink
fix: restore some syntax fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Stefano Cappa <[email protected]>
  • Loading branch information
Ks89 committed Jul 8, 2023
1 parent c1db23d commit 248f422
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,18 @@ export class CarouselPreviewsComponent extends AccessibleComponent implements On
* TODO write doc
*/
@Input()
// @ts-ignore
id: number;
id!: number;
/**
* Object of type `InternalLibImage` that represent the visible image.
*/
@Input()
// @ts-ignore
currentImage: InternalLibImage;
currentImage!: InternalLibImage;
/**
* Array of `InternalLibImage` that represent the model of this library with all images,
* thumbs and so on.
*/
@Input()
// @ts-ignore
images: InternalLibImage[];
images!: InternalLibImage[];

/**
* Output to emit the clicked preview. The payload contains the `InternalLibImage` associated to the clicked preview.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,18 @@ export class CurrentImageComponent extends AccessibleComponent implements OnInit
* the service to call modal gallery without open it manually.
*/
@Input()
// @ts-ignore
id: number;
id!: number;
/**
* Object of type `InternalLibImage` that represent the visible image.
*/
@Input()
// @ts-ignore
currentImage: InternalLibImage;
currentImage!: InternalLibImage;
/**
* Array of `InternalLibImage` that represent the model of this library with all images,
* thumbs and so on.
*/
@Input()
// @ts-ignore
images: InternalLibImage[];
images!: InternalLibImage[];
/**
* Boolean that it is true if the modal gallery is visible.
* If yes, also this component should be visible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ export class LoadingSpinnerComponent {
* It contains a field to choose a loading spinner.
*/
@Input()
loadingConfig: LoadingConfig | undefined;
loadingConfig!: LoadingConfig;
/**
* Object of type `AccessibilityConfig` to init custom accessibility features.
* For instance, it contains titles, alt texts, aria-labels and so on.
*/
@Input()
accessibilityConfig!: AccessibilityConfig | undefined;
accessibilityConfig!: AccessibilityConfig;

/**
* Enum of type `LoadingType` to choose the standard loading spinner.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class DotsComponent extends AccessibleComponent implements OnInit, OnChan
* the service to call modal gallery.
*/
@Input()
id: number | undefined
id!: number
/**
* Object of type `InternalLibImage` that represent the visible image.
*/
Expand All @@ -68,7 +68,7 @@ export class DotsComponent extends AccessibleComponent implements OnInit, OnChan
* For instance, it contains a param to show/hide this component.
*/
@Input()
dotsConfig: DotsConfig | undefined;
dotsConfig!: DotsConfig;

/**
* Output to emit clicks on dots. The payload contains a number that represent
Expand Down Expand Up @@ -97,9 +97,6 @@ export class DotsComponent extends AccessibleComponent implements OnInit, OnChan
* In particular, it's called only one time!!!
*/
ngOnInit(): void {
if (this.id === null || this.id === undefined) {
throw new Error('Internal library error - id must be defined');
}
const libConfig: LibConfig | undefined = this.configService.getConfig(this.id);
if (!libConfig) {
throw new Error('Internal library error - libConfig must be defined');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On
* the service to call modal gallery.
*/
@Input()
id: number | undefined;
id!: number;
/**
* Object of type `InternalLibImage` that represent the visible image.
*/
@Input()
currentImage: InternalLibImage | undefined;
currentImage!: InternalLibImage;
/**
* Array of `InternalLibImage` that represent the model of this library with all images,
* thumbs and so on.
*/
@Input()
images: InternalLibImage[] | undefined;
images!: InternalLibImage[];

/**
* Optional template reference for the rendering of previews.
Expand Down Expand Up @@ -135,19 +135,13 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On
* In particular, it's called only one time!!!
*/
ngOnInit(): void {
if (this.id === null || this.id === undefined) {
throw new Error('Internal library error - id must be defined');
}
const libConfig: LibConfig | undefined = this.configService.getConfig(this.id);
if (!libConfig) {
throw new Error('Internal library error - libConfig must be defined');
}
this.accessibilityConfig = libConfig.accessibilityConfig;
this.slideConfig = libConfig.slideConfig;
this.previewConfig = libConfig.previewConfig;
if (!this.currentImage || !this.images) {
throw new Error('Internal library error - currentImage and images must be defined');
}
this.initPreviews(this.currentImage, this.images);
}

Expand All @@ -157,7 +151,7 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On
* @returns boolean true if is active, false otherwise
*/
isActive(preview: InternalLibImage): boolean {
if (!preview || !this.currentImage) {
if (!preview) {
return false;
}
return preview.id === this.currentImage.id;
Expand Down Expand Up @@ -190,9 +184,6 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On
// It's suggested to stop propagation of the event, so the
// Cdk background will not catch a click and close the modal (like it does on Windows Chrome/FF).
event?.stopPropagation();
if (!this.id || !this.images) {
throw new Error('Internal library error - id and images must be defined');
}
if (!this.previewConfig || !this.previewConfig.clickable) {
return;
}
Expand Down Expand Up @@ -290,8 +281,8 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On
* Private method to update the visible previews navigating to the right (next).
*/
private next(): void {
if (!this.images || !this.previewConfig) {
throw new Error('Internal library error - images must be defined');
if (!this.previewConfig) {
throw new Error('Internal library error - previewConfig must be defined');
}
if(this.end >= this.images.length) {
// check if nextImage should be blocked
Expand All @@ -312,8 +303,8 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On
* Private method to update the visible previews navigating to the left (previous).
*/
private previous(): void {
if (!this.images || !this.previewConfig) {
throw new Error('Internal library error - images must be defined');
if (!this.previewConfig) {
throw new Error('Internal library error - previewConfig must be defined');
}
if(this.start <= 0) {
// check if prevImage should be blocked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ export class UpperButtonsComponent extends AccessibleComponent implements OnInit
* the service to call modal gallery.
*/
@Input()
id: number | undefined;
id!: number;
/**
* Object of type `Image` that represent the visible image.
*/
@Input()
currentImage: Image | undefined;
currentImage!: Image;

/**
* Output to emit clicks on refresh button. The payload contains a `ButtonEvent`.
Expand Down Expand Up @@ -151,9 +151,6 @@ export class UpperButtonsComponent extends AccessibleComponent implements OnInit
* In particular, it's called only one time!!!
*/
ngOnInit(): void {
if (this.id === null || this.id === undefined) {
throw new Error('Internal library error - id must be defined');
}
const libConfig: LibConfig | undefined = this.configService.getConfig(this.id);
if (!libConfig || !libConfig.buttonsConfig) {
throw new Error('Internal library error - libConfig and buttonsConfig must be defined');
Expand Down Expand Up @@ -188,9 +185,6 @@ export class UpperButtonsComponent extends AccessibleComponent implements OnInit
* @throws an error if the button type is unknown
*/
onEvent(button: InternalButtonConfig, event: KeyboardEvent | MouseEvent, action: Action = Action.CLICK): void {
if (this.id === null || this.id === undefined) {
throw new Error('Internal library error - id must be defined');
}
if (!event) {
return;
}
Expand Down

0 comments on commit 248f422

Please sign in to comment.