import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef} from "@angular/core";
import {VBox} from "@webbpm/base-package";

@Component({
             moduleId: module.id,
             selector: 'vbox-load-values',
             templateUrl: '../../../../../src/resources/template/account_applications/component/container/VBoxLoadValues.html',
             changeDetection: ChangeDetectionStrategy.OnPush
           })
export class VBoxLoadValues extends VBox {

  constructor(el: ElementRef, cd: ChangeDetectorRef) {
    super(el, cd);
  }

  public loadValues(selected: any, guids: any): Promise<any> {
    if (selected) {
      return this.containerLoader.containerLoaderRpcService.loadData(selected, guids, false)
          .then(fieldDataList => this.setData(fieldDataList))
          .then(() => this.fireOnLoadEvent());
    }
    else {
      return Promise.resolve();
    }
  }
}
