File

assets-navigator/asset-selector/asset-selector-node.component.ts

Implements

OnInit

Metadata

Index

Properties
Methods
Inputs
Outputs

Inputs

active
Type : GroupNode

Sets the active node.

disabled
Type : boolean
Default value : false
handleNextMillerViewColumn
Type : function

A function that should verify the need to add a column when a node is clicked.

index
Type : any

Used only for miller-view, displays the column level for the current node. E.g if the index is one, this will be second column.

multi
Type : boolean
Default value : false

Can the user select multiple assets.

node
Type : GroupNode

The current node.

preselected
Type : IIdentified | IIdentified[]
Default value : []

All preselected items.

rootNode
Type : GroupNode

Root node. Node found at the top of the hierarchy.

showPath
Type : boolean
Default value : false

Should the path be shown.

view
Type : "tree" | "miller"
Default value : 'tree'

The current path to the node.

Outputs

isLoadingState
Type : EventEmitter<boolean>

Event, which indicates whether the loading of the node has completed.

onDeselect
Type : EventEmitter<literal type>

Event that emits when a node is deselected.

onSelect
Type : EventEmitter<IManagedObject>

Event that emits when a node is selected.

Methods

click
click()

Opens a node.

Returns : void
isActive
isActive()
Returns : boolean
isSelected
isSelected()
Returns : boolean
millerViewClick
millerViewClick(node: GroupNode)

Handles clicks on a item in Miller View.

Parameters :
Name Type Optional Description
node GroupNode No

The node that was clicked.

Returns : void
selected
selected(node: GroupNode)

Selects the node and emits a change on the parent component.

Parameters :
Name Type Optional Description
node GroupNode No

The node to select.

Returns : void
setupBreadcrumbsAndLevel
setupBreadcrumbsAndLevel(node: GroupNode)
Parameters :
Name Type Optional
node GroupNode No
Returns : void

Properties

breadcrumb
Type : string
isLoading
Default value : false

sets the btn-pending class in the load more button

<!-- Hierarchy tree -->
<div
  class="c8y-asset-selector__item"
  [ngStyle]="{
    'margin-left': level > 1 ? 16 + 'px' : '0'
  }"
  *ngIf="view === 'tree'"
  [attr.role]="view === 'tree' ? 'tree' : 'list'"
  [ngClass]="{
    'c8y-asset-selector__item--more': node?.icon === 'plus',
    'c8y-asset-selector__item--start': level === 0
  }"
>
  <div
    class="c8y-asset-selector__node"
    title="{{ breadcrumb | translate }}"
    *ngIf="node && !node.root && !node.hidden"
    [attr.role]="view === 'tree' ? 'treeitem' : 'listitem'"
    [ngClass]="{ 'c8y-asset-selector__node--open': node?.open }"
  >
   <!-- expand button -->
    <div class="c8y-asset-selector__node__btn-spacer">
      <button
        [title]="expandTitle"
        class="collapse-btn btn-dot"
        (click)="click()"
        *ngIf="node.isGroup() || node.hasChildDevices()"
        [attr.aria-expanded]="node.open"
      >
        <i c8yIcon="angle-right"></i>
      </button>
    </div>
    <div class="d-flex a-i-center p-t-4 p-b-4 " *ngIf="node.toString() !== 'LoadMoreNode'">
      <label [ngClass]="{ 'c8y-checkbox': multi, 'c8y-radio': !multi }">
        <input
          id="nodeLabel"
          [type]="multi ? 'checkbox' : 'radio'"
          (change)="selected(node)"
          [checked]="isSelected()"
          [disabled]="disabled || !node.groupsSelectable && node.isGroup()"
        />
        <span></span>
        <span
          class="sr-only"
          for="nodeLabel"
          translate
        >
          Node label
        </span>
      </label>
    </div>

    <!-- group button -->
    <button
      class="c8y-asset-selector__btn text-truncate"
      [attr.aria-expanded]="!node.open"
      *ngIf="node.isGroup() || node.hasChildDevices()"
      (click)="click()"
    >
      <i
        class="c8y-icon c8y-icon-duocolor m-r-4 text-16"
        [c8yIcon]="node.icon"
        [title]="'Smart group' | translate"
        *ngIf="node.icon === 'c8y-group-smart'"
      ></i>
      <i
        class="c8y-icon c8y-icon-duocolor m-r-4 text-16"
        [c8yIcon]="node.icon"
        [title]="'Group' | translate"
        *ngIf="node.icon !== 'c8y-group-smart'"
      ></i>
      <span title="{{ breadcrumb }}">
        {{ node.translateLabel ? (node.label | translate) : node.label }}
        <!-- use just for search results to display the path -->
        <p
          class="text-truncate"
          *ngIf="showPath"
        >
          <small
            class="text-muted"
            title="{{ breadcrumb }}"
          >
            <em>{{ breadcrumb }}</em>
          </small>
        </p>
        <!-- up to here -->
      </span>
    </button>
    <!-- not a group button -->
    <button
      class="flex-grow"
      title="{{ breadcrumb }}"
      type="button"
      *ngIf="!node.isGroup() && !node.hasChildDevices()"
      [ngClass]="{
        'btn btn-default btn-sm m-b-8 m-r-8 d-flex j-c-center': node.icon === 'plus',
        'c8y-asset-selector__btn text-truncate': node.icon != 'plus'
      }"
      (click)="selected(node)"
    >
      <i
        class="c8y-icon c8y-icon-duocolor m-r-4 text-16"
        [c8yIcon]="node.icon"
        [title]="'Smart group' | translate"
        *ngIf="node.icon === 'c8y-group-smart'"
      ></i>
      <i
        class="c8y-icon m-r-4"
        [c8yIcon]="node.icon"
        [title]="'Group' | translate"
        *ngIf="node.icon !== 'c8y-group-smart'"
        [ngClass]="{ 'c8y-icon-duocolor text-16 ': node.icon != 'plus' }"
      ></i>
      <span title="{{ breadcrumb }}">
        {{ node.translateLabel ? (node.label | translate) : node.label }}
        <!-- use just for search results to display the path -->
        <p
          class="text-truncate text-muted small"
          *ngIf="showPath"
        >
          <em>{{ breadcrumb }}</em>
        </p>
        <!-- up to here -->
      </span>
    </button>
   
  </div>
  <div
    class="collapse"
    *ngIf="node.countChildren()"
    [collapse]="!node.open"
    [isAnimated]="true"
    [attr.role]="'group'"
  >
    <c8y-asset-selector-node
      *ngFor="let childNode of node.children"
      [node]="childNode"
      [preselected]="preselected || []"
      [disabled]="disabled"
      [multi]="multi"
      [active]="active"
      [attr.role]="view === 'tree' ? 'treeitem' : 'listitem'"
      (onSelect)="onSelect.emit($event)"
      (onDeselect)="onDeselect.emit($event)"
    ></c8y-asset-selector-node>
  </div>
</div>

<!-- Miller columns -->
<div *ngIf="view === 'miller'">
  <div
    class="miller-column__item bg-inherit"
    title="{{ breadcrumb | translate }}"
    *ngIf="node && !node.root && !node.hidden && node !== rootNode"
    [ngClass]="{
      active: isActive(),
      'miller-column__item--more': node.toString() === 'LoadMoreNode'
    }"
  >
    <div
      class="m-l-4 m-r-4 miller-column__item__checkbox"
      *ngIf="node.toString() !== 'LoadMoreNode'"
    >
      <label [ngClass]="{ 'c8y-radio': !multi, 'c8y-checkbox': multi }">
        <input
          id="nodeLabel2"
          [type]="multi ? 'checkbox' : 'radio'"
          (change)="selected(node)"
          [checked]="isSelected()"
          [disabled]="disabled || !node.groupsSelectable && node.isGroup()"
        />
        <span></span>
        <span
          class="sr-only"
          for="nodeLabel2"
          translate
        >
          Node label
        </span>
      </label>
    </div>

    <button
      title="{{ breadcrumb | translate }}"
      type="button"
      [ngClass]="{
        'btn btn-default btn-sm d-flex flex-grow j-c-center m-l-16 m-r-16 m-b-4 m-t-4':
          node.toString() === 'LoadMoreNode',
        'miller-column__item__btn': node.toString() !== 'LoadMoreNode',
        'btn-pending': node.loading && node.toString() === 'LoadMoreNode'
      }"
      (click)="millerViewClick(node)"
    >
      <i
        class="c8y-icon m-r-4"
        [c8yIcon]="node.icon"
        [ngClass]="{ 'c8y-icon-duocolor text-16': node.toString() !== 'LoadMoreNode' }"
      ></i>
      <div class="text-left text-truncate">
        <p
          class="text-truncate"
          title="{{ node.translateLabel ? (node.label | translate) : node.label }}"
        >
          {{ node.translateLabel ? (node.label | translate) : node.label }}
        </p>
        <!-- use just for search results to display the path -->
        <small
          class="text-muted text-truncate"
          title="{{ breadcrumb }}"
          *ngIf="showPath"
        >
          <em>{{ breadcrumb }}</em>
        </small>
        <!-- up to here -->
      </div>
      <span
        class="p-l-4 m-l-auto"
        *ngIf="node.isGroup() || node.hasChildDevices()"
      >
        <i c8yIcon="angle-right"></i>
      </span>
    </button>
  </div>

  <div
    role="list"
    *ngIf="node"
    [ngClass]="{ hidden: node !== rootNode }"
  >
    <c8y-asset-selector-node
      role="listitem"
      *ngFor="let childNode of node.children"
      [node]="childNode"
      [rootNode]="rootNode"
      [preselected]="preselected || []"
      [multi]="multi"
      [view]="view"
      [index]="index"
      [active]="active"
      [disabled]="disabled"
      [handleNextMillerViewColumn]="handleNextMillerViewColumn"
      (onSelect)="onSelect.emit($event)"
      (onDeselect)="onDeselect.emit($event)"
    ></c8y-asset-selector-node>
  </div>
</div>

results matching ""

    No results matching ""