import { CustomViewBase } from '../../../view/customview-base';
import { AppLayoutService } from '../../../app-service';

/**
 * 应用自定义视图基类
 *
 * @export
 * @class AppCustomViewBase
 * @extends {CustomViewBase}
 */
export class AppCustomViewBase extends CustomViewBase {
  render(h: any) {
    if (!this.viewIsLoaded) {
      return null;
    }
    const targetViewLayoutComponent: any = AppLayoutService.getLayoutComponent(`${this.viewInstance.viewType}-${this.viewInstance.viewStyle}`);
    return h(
      targetViewLayoutComponent,
      {
        props: { viewInstance: this.viewInstance, model: this.model, modelService: this.modelService, viewparams: this.viewparams, context: this.context },
      },
      [this.renderToolBar(), this.renderTopMessage(), this.renderBodyMessage(), ...this.renderViewControls(), this.renderBottomMessage()],
    );
  }
}
