Skip to main content

Overview

The DatalinkListComponent is a standalone Angular component that displays all datalinks associated with an Alfresco node. It provides functionality for viewing, adding, and removing datalink entries through a tabbed interface.

Import

import { DatalinkListComponent } from 'venzia-datalink';

Selector

'aqua-datalink-list'

Standalone Component

@Component({
  standalone: true,
  imports: [
    CommonModule,
    DataTableComponent,
    MatProgressBarModule,
    MatTabsModule,
    DataColumnListComponent,
    DataColumnComponent,
    EmptyListComponent,
    TranslateModule,
    ArraySortPipe
  ],
  // ...
})

Inputs

nodeId
string
default:"''"
ID of the Alfresco node whose datalinks you want to display
node
Node
Optional Node object (alternative to nodeId)

Outputs

select
EventEmitter<any>
Emitted when datalink rows are selected. Emits array of selected items.
error
EventEmitter<any>
Emitted when an error occurs during datalink operations.
reloadDialog
EventEmitter<any>
Emitted when the parent dialog should reload.

Properties

rows
object
Object containing datalink rows organized by aspect property name
Array of all available datalink configurations
Index of the currently active datalink tab
isLoading
boolean
Loading state indicator
displayNode
Node | SiteEntry
The current node being displayed
selectedItems
any[]
Currently selected datalink rows

Methods

ngOnChanges

Lifecycle hook that loads datalink configurations and node data.
ngOnChanges(): void

onChangeTabIndex

Handles tab change events and clears selection.
onChangeTabIndex(index: number): void
index
number
Index of the newly selected tab

elementClicked / elementUnClicked

Handles row selection/deselection events.
elementClicked(event: any): void
elementUnClicked(event: any): void

reload

Reloads the component data from the server.
public reload(): void

onRemoveRow

Removes a single row from the datalink.
public onRemoveRow(dataRow: any, dataLink: any): void
dataRow
any
Row object containing the data to remove
Datalink configuration object

deleteSelectRows

Deletes all currently selected rows.
public deleteSelectRows(event: Event): void

openAddDatalinkDialog

Opens the dialog to add new datalink entries.
public openAddDatalinkDialog(event: Event): void

onError

Handles and displays error messages.
onError(errorMessage: string): void

Example Usage

import { Component } from '@angular/core';
import { DatalinkListComponent } from 'venzia-datalink';

@Component({
  selector: 'app-document-details',
  standalone: true,
  imports: [DatalinkListComponent],
  template: `
    <aqua-datalink-list
      [nodeId]="documentId"
      (select)="onSelectionChange($event)"
      (error)="handleError($event)">
    </aqua-datalink-list>
  `
})
export class DocumentDetailsComponent {
  documentId = 'workspace://SpacesStore/abc-123';

  onSelectionChange(selectedItems: any[]) {
    console.log('Selected items:', selectedItems);
  }

  handleError(error: any) {
    console.error('Datalink error:', error);
  }
}

Features

Displays multiple datalink types in separate tabs:
  • Each tab represents one datalink configuration
  • Tab switching clears selection
  • Active tab index is tracked

Data Table

Uses ADF DataTable component:
  • Configurable columns from datalink configuration
  • Multi-select support
  • Row click/unclick events
  • Empty state handling

CRUD Operations

  • Read: Loads datalinks from node properties
  • Create: Opens dialog to add new entries
  • Delete: Removes individual or multiple rows
  • Update: Automatically updates node properties

Loading States

Provides loading indicators:
  • Progress bar during data fetch
  • Loading flag for conditional rendering
  • Automatic state management

Implementation Details

import { Component, Input, OnChanges, Output, EventEmitter, ViewEncapsulation } from '@angular/core';
import { Node, SiteEntry } from '@alfresco/js-api';
import { VenziaDatalinkApiService } from '../../services/venzia-datalink-api.service';
import { VenziaDatalinkSearchDialogService } from '../../services/venzia-datalink-search-dialog.service';
import { ContentApiService } from '@alfresco/aca-shared';
import { NodesApiService } from '@alfresco/adf-content-services';
import { Store } from '@ngrx/store';
import { SnackbarErrorAction, AppStore } from '@alfresco/aca-shared/store';

@Component({
  standalone: true,
  selector: 'aqua-datalink-list',
  templateUrl: './datalink-list.component.html',
  styleUrls: ['./datalink-list.component.scss'],
  encapsulation: ViewEncapsulation.None
})
export class DatalinkListComponent implements OnChanges {
  @Input() nodeId = '';
  @Input() node: Node;
  @Output() select: EventEmitter<any> = new EventEmitter();
  @Output() error: EventEmitter<any> = new EventEmitter();
  @Output() reloadDialog: EventEmitter<any> = new EventEmitter();

  rows: any = {};
  datalinkList: any;
  datalinkActiveIndex = 0;
  isLoading = false;
  displayNode: Node | SiteEntry;
  selectedItems: any[] = [];

  constructor(
    private store: Store<AppStore>,
    private contentApi: ContentApiService,
    private nodesApiService: NodesApiService,
    private dlnkApiService: VenziaDatalinkApiService,
    private datalinkSearchDialogService: VenziaDatalinkSearchDialogService,
    private logger: LogService
  ) {}

  ngOnChanges() {
    this.isLoading = true;
    this.dlnkApiService.loadDataLink().subscribe((data) => {
      this.datalinkList = data;
      this.loadNodeInfo(this.nodeId);
    });
  }

  public reload() {
    this.loadNodeInfo(this.nodeId);
  }

  public deleteSelectRows(_: Event) {
    this.datalinkSearchDialogService
      .deleteSelectRows(
        this.nodeId,
        this.selectedItems,
        this.datalinkList[this.datalinkActiveIndex]
      )
      .subscribe(
        () => this.reloadDialog.emit(),
        (error) => this.store.dispatch(new SnackbarErrorAction(error))
      );
  }

  openAddDatalinkDialog(_: Event) {
    this.datalinkSearchDialogService
      .updateNodeDatalinkByDialog(
        this.nodeId,
        this.datalinkList[this.datalinkActiveIndex]
      )
      .subscribe(
        () => {},
        (error) => this.store.dispatch(new SnackbarErrorAction(error))
      );
  }
}

Data Storage

Datalink data is stored in Alfresco node properties:
  • Property name: dataLink.aspectPropertyName
  • Format: JSON string containing array of row objects
  • Example: [{"id": "123", "name": "Customer A"}, ...]

Error Handling

Errors are handled through:
  • Event emission to parent components
  • NgRx store actions for snackbar notifications
  • Console logging for debugging

Styling

The component includes:
  • SCSS stylesheet for custom styling
  • ViewEncapsulation.None for global styles
  • Material Design integration
  • Responsive layout support

Dependencies

  • @angular/core: Angular framework
  • @angular/material: Material tabs and progress bar
  • @alfresco/adf-core: ADF data table components
  • @alfresco/adf-content-services: Alfresco API services
  • @alfresco/aca-shared: Content App shared library
  • @ngrx/store: State management
  • rxjs: Reactive programming

See Also

Build docs developers (and LLMs) love