@smartbit4all/ng-client 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3630,12 +3630,14 @@ let SmartComponentApiClient = class SmartComponentApiClient {
3630
3630
  this.pageName = pageName;
3631
3631
  this._destroy$ = new Subject();
3632
3632
  this.detectChange = new SmartSubject(this._destroy$);
3633
- this.modelChanged = new SmartSubject(this._destroy$);
3633
+ this.uiActionModels = [];
3634
+ this.dataChanged = new SmartSubject(this._destroy$);
3634
3635
  // UseUiAction
3635
3636
  this.submit = new SmartSubject(this._destroy$);
3636
3637
  this.reSubscribeToChange = new SmartSubject(this._destroy$);
3637
- this.detectChange.subscribe((data) => {
3638
- this.data = data;
3638
+ this.detectChange.subscribe((model) => {
3639
+ this.model = model;
3640
+ this.data = model.data;
3639
3641
  });
3640
3642
  }
3641
3643
  get uuid() {
@@ -3650,16 +3652,14 @@ let SmartComponentApiClient = class SmartComponentApiClient {
3650
3652
  }
3651
3653
  set model(model) {
3652
3654
  this._model = model;
3653
- if (model?.data) {
3654
- this.data = model?.data;
3655
- }
3655
+ this.initComponentByModel();
3656
3656
  }
3657
3657
  get data() {
3658
3658
  return this._data;
3659
3659
  }
3660
3660
  set data(model) {
3661
3661
  this._data = model;
3662
- this.modelChanged.next();
3662
+ this.dataChanged.next();
3663
3663
  }
3664
3664
  _ngOnInit() {
3665
3665
  this.run();
@@ -3669,6 +3669,26 @@ let SmartComponentApiClient = class SmartComponentApiClient {
3669
3669
  this._destroy$.next();
3670
3670
  this._destroy$.complete();
3671
3671
  }
3672
+ initComponentByModel() {
3673
+ this.initData();
3674
+ this.initActions();
3675
+ // TODO: layout, valueSet, widgets
3676
+ }
3677
+ initData() {
3678
+ if (this.model?.data) {
3679
+ this.data = this.model?.data;
3680
+ }
3681
+ }
3682
+ initActions() {
3683
+ if (this.model?.actions) {
3684
+ this.uiActionModels = this.model?.actions.map((uiAction) => {
3685
+ return {
3686
+ serviceToUse: this,
3687
+ uiAction,
3688
+ };
3689
+ });
3690
+ }
3691
+ }
3672
3692
  run() {
3673
3693
  if (this.auth.bffApisHaveBeenSetUp) {
3674
3694
  this.load();
@@ -3688,14 +3708,12 @@ let SmartComponentApiClient = class SmartComponentApiClient {
3688
3708
  getModel() {
3689
3709
  return this.data;
3690
3710
  }
3691
- // this should not be abstract
3692
3711
  async performUiActionRequest(uiActionRequest) {
3693
3712
  await this.viewContext.performAction(this.uuid, uiActionRequest);
3694
3713
  }
3695
3714
  handleSpecificDemandsAsynchronously(uiAction, uiActionRequest) {
3696
3715
  throw new Error("handleSpecificDemandsAsynchronously method not implemented.");
3697
3716
  }
3698
- // this should not be abstract
3699
3717
  async load() {
3700
3718
  this.uuid = this.viewContext.getUuidOfPage(this.pageName);
3701
3719
  this.model = await this.viewContext.load(this.uuid);