File

feature-libs/organization/administration/components/shared/table/cell.component.ts

Metadata

changeDetection ChangeDetectionStrategy.OnPush
selector cx-org-cell
templateUrl ./cell.component.html

Index

Accessors

Constructor

constructor(outlet: OutletContextData<TableDataOutletContext>)
Parameters :
Name Type Optional
outlet OutletContextData<TableDataOutletContext> No

Accessors

tabIndex
gettabIndex()
model
getmodel()
property
getproperty()
linkable
getlinkable()

Indicates wether the cell is linkable.

If the cells is linkable, an anchor link is created to the detailed route of the given _type.

Defaults to true.

Returns : boolean
cellOptions
getcellOptions()

Helper method to access the cell options.

Returns : TableFieldOptions
route
getroute()

Generates the configurable route to the detail page of the given context item.

Returns : string
routeModel
getrouteModel()
type
gettype()
hasItem
gethasItem()

Indicates whether the item is loaded.

Returns : boolean
item
getitem()
import { ChangeDetectionStrategy, Component } from '@angular/core';
import {
  OutletContextData,
  TableDataOutletContext,
  TableFieldOptions,
} from '@spartacus/storefront';

@Component({
  selector: 'cx-org-cell',
  templateUrl: './cell.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CellComponent {
  constructor(protected outlet: OutletContextData<TableDataOutletContext>) {}

  get tabIndex(): number {
    return -1;
  }

  get model(): TableDataOutletContext {
    return this.outlet.context;
  }

  get property(): string {
    return this.model?.[this.outlet?.context?._field];
  }

  /**
   * Indicates wether the cell is linkable.
   *
   * If the cells is linkable, an anchor link is created to the detailed route
   * of the given `_type`.
   *
   * Defaults to `true`.
   */
  get linkable(): boolean {
    return this.property !== undefined && (this.cellOptions.linkable ?? true);
  }

  /**
   * Helper method to access the cell options.
   */
  get cellOptions(): TableFieldOptions {
    return (
      this.outlet.context?._options?.cells?.[this.outlet.context?._field] ?? {}
    );
  }

  /**
   * Generates the configurable route to the detail page of the given context item.
   */
  get route(): string {
    return this.outlet.context._type + 'Details';
  }

  get routeModel(): any {
    return this.outlet.context;
  }

  get type(): string {
    return this.model._type;
  }

  /**
   * Indicates whether the item is loaded.
   */
  get hasItem(): boolean {
    return !!this.item && Object.keys(this.item).length > 0;
  }

  protected get item(): any {
    if (!this.outlet.context) {
      return null;
    }
    const { _field, _options, _type, _i18nRoot, ...all } = this.outlet.context;
    return all;
  }
}
<a
  *ngIf="linkable; else text"
  [routerLink]="{ cxRoute: route, params: routeModel } | cxUrl"
  [tabIndex]="tabIndex"
>
  <ng-container *ngTemplateOutlet="text"></ng-container>
</a>

<ng-template #text>
  <span class="text" title="{{ property }}">{{ property }}</span>
</ng-template>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""