Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 93x 93x 93x 93x 2x 2x 9x 2x 7x 6x 1x | import { Metadata } from '@zeedhi/core';
import { ComponentRender } from '../zd-component/component-render';
import { IIterablePageComponent } from './interfaces';
import { Iterable } from './iterable';
/**
* Base class for Iterable Page component
*/
export class IterablePageComponent extends ComponentRender implements IIterablePageComponent {
/**
* Iterable component name
*/
public iterableComponentName!: string;
/**
* Iterable component name
*/
public iterableComponent!: Iterable;
/* istanbul ignore next */
/**
* Creates a new Iterable Page component.
* @param props Iterable page component properties
*/
constructor(props: IIterablePageComponent) {
super(props);
this.iterableComponentName = this.getInitValue(
'iterableComponentName',
props.iterableComponentName,
this.iterableComponent,
);
this.setIterableComponent();
}
/**
* Set the Iterable Component
* @param element Element mounted reference
*/
public onMounted(element: any) {
super.onMounted(element);
this.setIterableComponent();
}
private setIterableComponent() {
if (this.iterableComponentName && Metadata.getInstances(this.iterableComponentName).length > 0) {
this.iterableComponent = Metadata.getInstance(this.iterableComponentName) as Iterable;
} else if (this.parent instanceof Iterable) {
this.iterableComponent = this.parent;
} else {
throw new Error(`Could not find the iterable component associated with ${this.name}`);
}
}
}
|