@smartbit4all/ng-client 3.3.184 → 3.3.186

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.
@@ -2841,7 +2841,7 @@ class SmartViewContextService {
2841
2841
  openView(view) {
2842
2842
  let alreadyOpened = this.openedViewUuids.some((uuid) => uuid === view.uuid);
2843
2843
  if (alreadyOpened)
2844
- return;
2844
+ return undefined;
2845
2845
  let viewHandler = this.viewHandlers.find((handler) => handler.name === view.viewName);
2846
2846
  if (!viewHandler) {
2847
2847
  throw new Error(`SmartViewHandlerModel was not found by view name: ${view.viewName}`);
@@ -2911,15 +2911,10 @@ class SmartViewContextService {
2911
2911
  this.openedViewData.push(view);
2912
2912
  this.setUuidOfPage(view.viewName, view.uuid, viewHandler.componentName);
2913
2913
  this.uuidOfPageHasBeenChanged.next(view.viewName);
2914
- this.updateViewContext({
2915
- updates: [
2916
- {
2917
- state: ViewState.OPENED,
2918
- uuid: view.uuid,
2919
- },
2920
- ],
2921
- uuid: this.viewContext?.uuid,
2922
- });
2914
+ return {
2915
+ state: ViewState.OPENED,
2916
+ uuid: view.uuid,
2917
+ };
2923
2918
  }
2924
2919
  closeView(view) {
2925
2920
  let viewHandler = this.viewHandlers.find((handler) => handler.name === view.viewName);
@@ -2951,43 +2946,57 @@ class SmartViewContextService {
2951
2946
  this.openedViewData.splice(index, 1);
2952
2947
  this.clearUuidOfPage(view.viewName, viewHandler.componentName);
2953
2948
  }
2949
+ return {
2950
+ state: ViewState.CLOSED,
2951
+ uuid: view.uuid,
2952
+ };
2953
+ }
2954
+ updateContext(updates) {
2954
2955
  this.updateViewContext({
2955
- updates: [
2956
- {
2957
- state: ViewState.CLOSED,
2958
- uuid: view.uuid,
2959
- },
2960
- ],
2956
+ updates,
2961
2957
  uuid: this.viewContext?.uuid,
2962
2958
  });
2963
2959
  }
2964
2960
  async restoreViews(uuid) {
2961
+ const updates = [];
2965
2962
  if (!this.viewContext) {
2966
2963
  await this.getViewContext(uuid);
2967
2964
  }
2968
- this.viewContext.views.map((view) => {
2969
- this.openView(view);
2965
+ this.viewContext.views.filter((view) => view.state === ViewState.OPENED || view.state === ViewState.TO_OPEN).map((view) => {
2966
+ const update = this.openView(view);
2967
+ if (update) {
2968
+ updates.push(update);
2969
+ }
2970
2970
  });
2971
+ if (updates.length > 0) {
2972
+ this.updateContext(updates);
2973
+ }
2971
2974
  }
2972
2975
  syncView() {
2976
+ const updates = [];
2973
2977
  this.viewContext?.views.map((view) => {
2978
+ let update = undefined;
2974
2979
  switch (view.state) {
2975
2980
  case ViewState.TO_OPEN:
2976
- this.openView(view);
2981
+ update = this.openView(view);
2977
2982
  break;
2978
2983
  case ViewState.TO_CLOSE:
2979
- this.closeView(view);
2984
+ update = this.closeView(view);
2980
2985
  break;
2981
2986
  }
2987
+ if (update) {
2988
+ updates.push(update);
2989
+ }
2982
2990
  });
2983
2991
  const viewDataToClose = this.openedViewData.filter((viewData) => !this.viewContext?.views
2984
2992
  .flatMap((viewData) => viewData.uuid)
2985
2993
  .includes(viewData.uuid));
2986
2994
  if (viewDataToClose?.length) {
2987
2995
  viewDataToClose.map((viewData) => {
2988
- this.closeView(viewData);
2996
+ updates.push(this.closeView(viewData));
2989
2997
  });
2990
2998
  }
2999
+ this.updateContext(updates);
2991
3000
  this.viewContext?.links?.map((data) => {
2992
3001
  const link = document.createElement('a');
2993
3002
  let target = '_blank'; // default
@@ -15831,7 +15840,7 @@ class SmartComponentApiClient {
15831
15840
  reference.load();
15832
15841
  }
15833
15842
  }
15834
- else if (reference === undefined) {
15843
+ else if (!skipLoad && reference === undefined) {
15835
15844
  console.error(`Provided reference for ${key} is undefined.`);
15836
15845
  }
15837
15846
  });