@wolkabout/commons 0.0.53 → 0.0.56

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.
@@ -71,7 +71,7 @@ import { jwtDecode } from 'jwt-decode';
71
71
  import { loadRemoteModule } from '@angular-architects/native-federation';
72
72
  import * as i1$3 from '@angular/platform-browser';
73
73
  import { DomSanitizer } from '@angular/platform-browser';
74
- import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
74
+ import { takeUntilDestroyed, toSignal, toObservable } from '@angular/core/rxjs-interop';
75
75
  import * as i1 from '@angular/material/snack-bar';
76
76
  import { TonalPalette, Hct, argbFromHex, hexFromArgb } from '@material/material-color-utilities';
77
77
  import { TemplatePortal } from '@angular/cdk/portal';
@@ -266,8 +266,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
266
266
  }]
267
267
  }] });
268
268
 
269
+ /**
270
+ * Checks if the user can edit something based on the context.
271
+ * The main context (context with ID 1) is special and can expose its assets to other contexts.
272
+ * The asset should be editable only if the user (using its authority) and the asset are in the same context.
273
+ * The isMainContext is a bit simplified parameter because only the main context can share its assets, and we only care if it is in the main tenant, or any other.
274
+ */
269
275
  function isContextAccessible(authority, isMainContext) {
270
- return !isMainContext || authority.contextId === 1;
276
+ return (authority.contextId === 1) === isMainContext;
271
277
  }
272
278
 
273
279
  var DataType;
@@ -4420,7 +4426,7 @@ class CardLabeledValueComponent {
4420
4426
  ? this.permissionService.hasAnyGlobalOrAssetPermission(requiredPermissions)
4421
4427
  : this.permissionService.hasAnyPermission(requiredPermissions);
4422
4428
  }, ...(ngDevMode ? [{ debugName: "permissionFunction" }] : []));
4423
- hasPermission = toSignal(this.permissionFunction());
4429
+ hasPermission = toSignal(toObservable(this.permissionFunction).pipe(switchMap(obs => obs)), { initialValue: false });
4424
4430
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CardLabeledValueComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
4425
4431
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: CardLabeledValueComponent, isStandalone: true, selector: "app-card-labeled-value", inputs: { permissions: { classPropertyName: "permissions", publicName: "permissions", isSignal: true, isRequired: false, transformFunction: null }, useAssetPermissions: { classPropertyName: "useAssetPermissions", publicName: "useAssetPermissions", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, tooltip: { classPropertyName: "tooltip", publicName: "tooltip", isSignal: true, isRequired: false, transformFunction: null }, editFunction: { classPropertyName: "editFunction", publicName: "editFunction", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<mat-card\r\n [ngClass]=\"{'cursor-pointer hover:bg-hover-color': editFunction() && hasPermission() }\"\r\n [matTooltipDisabled]=\"!hasPermission()\" (click)=\"editFunction() && hasPermission() ? editFunction()!() : null\"\r\n [matTooltip]=\"tooltip() | translate\"\r\n matTooltipPosition=\"above\"\r\n>\r\n <div class=\"flex items-center justify-between p-4 gap-x-4 h-full\">\r\n <div class=\"flex flex-col w-full h-full overflow-hidden\">\r\n <div class=\"font-semibold shrink-0\">{{ label() | translate }}</div>\r\n <div class=\"text-mat-sys-primary flex items-center grow\">\r\n <ng-content/>\r\n </div>\r\n </div>\r\n @if (editFunction() && hasPermission()) {\r\n <button mat-icon-button [ngClass]=\"icon() === 'delete' ? 'text-mat-sys-on-error-container' : 'text-mat-sys-primary'\" (click)=\"editFunction()!(); $event.stopPropagation()\">\r\n <mat-icon>{{ icon() }}</mat-icon>\r\n </button>\r\n }\r\n </div>\r\n</mat-card>\r\n", styles: ["mat-card{height:100%;min-height:5.5rem}\n"], dependencies: [{ kind: "ngmodule", type: i2.MatButtonModule }, { kind: "component", type: i2.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: i3.MatCheckboxModule }, { kind: "ngmodule", type: i4.MatToolbarModule }, { kind: "ngmodule", type: i5.MatMenuModule }, { kind: "ngmodule", type: i6.MatFormFieldModule }, { kind: "ngmodule", type: i7.MatTooltipModule }, { kind: "directive", type: i7.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: i8.MatSidenavModule }, { kind: "ngmodule", type: i9.MatTabsModule }, { kind: "ngmodule", type: i10.MatTableModule }, { kind: "ngmodule", type: i11.MatIconModule }, { kind: "component", type: i11.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: i12.MatCardModule }, { kind: "component", type: i12.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "ngmodule", type: i13.MatSelectModule }, { kind: "ngmodule", type: i14.MatDialogModule }, { kind: "ngmodule", type: i15.MatSortModule }, { kind: "ngmodule", type: i16.MatRadioModule }, { kind: "ngmodule", type: i17.MatRippleModule }, { kind: "ngmodule", type: i18.MatDividerModule }, { kind: "ngmodule", type: i19.MatInputModule }, { kind: "ngmodule", type: i20.MatProgressBarModule }, { kind: "ngmodule", type: i21.MatProgressSpinnerModule }, { kind: "ngmodule", type: i22.MatTreeModule }, { kind: "ngmodule", type: i23.MatExpansionModule }, { kind: "ngmodule", type: i24.MatDatepickerModule }, { kind: "ngmodule", type: i25.MatAutocompleteModule }, { kind: "ngmodule", type: i26.MatChipsModule }, { kind: "ngmodule", type: i27.MatGridListModule }, { kind: "ngmodule", type: i28.MatPaginatorModule }, { kind: "ngmodule", type: i29.MatSliderModule }, { kind: "ngmodule", type: i1$1.TranslateModule }, { kind: "ngmodule", type: i30.ReactiveFormsModule }, { kind: "ngmodule", type: i31.CommonModule }, { kind: "directive", type: i31.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: i32.DragDropModule }, { kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] });
4426
4432
  }
@@ -5644,7 +5650,7 @@ class StandardListViewComponent {
5644
5650
  this.items.update(items => items.map(item => item.id === updatedItem.id ? updatedItem : item).sort(dataSource.sortingFunction));
5645
5651
  });
5646
5652
  dataControl.itemPartiallyUpdated$.pipe(takeUntilDestroyed(destroyRef)).subscribe((partialUpdate) => {
5647
- this.items.update(items => items.map(item => item.id === partialUpdate.id ? dataSource.prepareItem({ ...item, ...partialUpdate.update }) : item).sort(dataSource.sortingFunction));
5653
+ this.items.update(items => items.map(item => item.id === partialUpdate.id ? dataSource.prepareItem(partialUpdate.update(item.data)) : item).sort(dataSource.sortingFunction));
5648
5654
  });
5649
5655
  });
5650
5656
  afterRenderEffect(() => {
@@ -5704,14 +5710,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
5704
5710
  class StandardListDataControl {
5705
5711
  _changeSelection$ = new BehaviorSubject(null);
5706
5712
  _itemUpdated$ = new Subject();
5713
+ _itemPartiallyUpdated$ = new Subject();
5707
5714
  _itemAdded$ = new Subject();
5708
5715
  _itemRemoved$ = new Subject();
5709
- _itemPartiallyUpdated$ = new Subject();
5710
5716
  selectItem = (id) => this._changeSelection$.next(id);
5711
5717
  updateItem = (item) => this._itemUpdated$.next(item);
5718
+ updateItemPartially = (id, update) => this._itemPartiallyUpdated$.next({ id, update });
5712
5719
  addItem = (item) => this._itemAdded$.next(item);
5713
5720
  removeItem = (id) => this._itemRemoved$.next(id);
5714
- updateItemPartially = (id, update) => this._itemPartiallyUpdated$.next({ id, update });
5715
5721
  /**
5716
5722
  * Internal event hook. Do not use outside the Standard List Component
5717
5723
  */