@smartbit4all/ng-client 3.3.185 → 3.3.187

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,32 +2946,46 @@ class SmartViewContextService {
2951
2946
  this.openedViewData.splice(index, 1);
2952
2947
  this.clearUuidOfPage(view.viewName, viewHandler.componentName);
2953
2948
  }
2954
- this.updateViewContext({
2955
- updates: [
2956
- {
2957
- state: ViewState.CLOSED,
2958
- uuid: view.uuid,
2959
- },
2960
- ],
2961
- uuid: this.viewContext?.uuid,
2949
+ return {
2950
+ state: ViewState.CLOSED,
2951
+ uuid: view.uuid,
2952
+ };
2953
+ }
2954
+ sendViewContextUpdates(updatesToSend) {
2955
+ const updates = [];
2956
+ updatesToSend.forEach((update) => {
2957
+ if (update !== undefined && update !== null)
2958
+ updates.push(update);
2962
2959
  });
2960
+ if (updates.length > 0) {
2961
+ this.updateViewContext({
2962
+ updates,
2963
+ uuid: this.viewContext?.uuid,
2964
+ });
2965
+ }
2963
2966
  }
2964
2967
  async restoreViews(uuid) {
2968
+ const updates = [];
2965
2969
  if (!this.viewContext) {
2966
2970
  await this.getViewContext(uuid);
2967
2971
  }
2968
- this.viewContext.views.map((view) => {
2969
- this.openView(view);
2972
+ this.viewContext.views.filter((view) => view.state === ViewState.OPENED || view.state === ViewState.TO_OPEN).map((view) => {
2973
+ const update = this.openView(view);
2974
+ if (update) {
2975
+ updates.push(update);
2976
+ }
2970
2977
  });
2978
+ this.sendViewContextUpdates(updates);
2971
2979
  }
2972
2980
  syncView() {
2981
+ const updates = [];
2973
2982
  this.viewContext?.views.map((view) => {
2974
2983
  switch (view.state) {
2975
2984
  case ViewState.TO_OPEN:
2976
- this.openView(view);
2985
+ updates.push(this.openView(view));
2977
2986
  break;
2978
2987
  case ViewState.TO_CLOSE:
2979
- this.closeView(view);
2988
+ updates.push(this.closeView(view));
2980
2989
  break;
2981
2990
  }
2982
2991
  });
@@ -2985,9 +2994,10 @@ class SmartViewContextService {
2985
2994
  .includes(viewData.uuid));
2986
2995
  if (viewDataToClose?.length) {
2987
2996
  viewDataToClose.map((viewData) => {
2988
- this.closeView(viewData);
2997
+ updates.push(this.closeView(viewData));
2989
2998
  });
2990
2999
  }
3000
+ this.sendViewContextUpdates(updates);
2991
3001
  this.viewContext?.links?.map((data) => {
2992
3002
  const link = document.createElement('a');
2993
3003
  let target = '_blank'; // default