Files
alfresco-ng2-components/ng2-components/ng2-alfresco-documentlist/README.md
Eugenio Romano b15ab3b988 1.6.0 (#2029)
* fix upload area snackbar behaviour

* SASS support for components

ability to use '.scss' files from within components

* [ADF-610] Upload button and DnD area should not upload hidden files and folders (#1908)

[ADF-610]  upload cleanup
- more strongly typing
- api improvements

* Upload cleanup and api improvements

- remove old unused settings (formFields variable)
- individual options for uploaded files (i.e. versioning)
- upload button and drag-and-drop area now set individual settings for file versioning

* exclude hidden files from upload

* [ADF-640] reload document list on folder upload (#1895)

* reload document list on folder upload

- extend UploadService with 'folderCreated' event to be able reacting on folder uploads globally
- extend Demo Shell to reload document list on UploadService events (folderCreated)

* readme updates

* [ADF-621] show drop effect on folders only (#1897)

* show drop effect on folders only

- fix `hasValue` api for data rows (avoid 'false' value to be evaluated as missing value)
- support for evaluating drop support for rows
- document list enables upload zones for folders only

* api improvements as per code review

* [ADF-242] Fixed behaviour for saving/deleting reports (#1905)

* [ADF-242] - fix for deleting - saving a report

* [ADF - 242] added test for fixed feature on reports save - delete

* Added translation key

* [ADF-604] Upgrade @angular/material to latest version (#1909)

* update dependencies and module imports

* fix template warnings and fix import issues

* migrate Activiti Form to MdTabsModule

* fix unit tests

* fix tests

* fix unit tests

* fix unit tests

* disable test that fails only on travis

* upgrade activiti form component to angular/material

* fix test (remove MDL class check)

* [ADF-613] Add plain text viewer (#1873)

* add plain text viewer

* different devices optimizations

* returns types

* [ADF-573] support for toggling enabled state (#1912)

* [ADF-602] Accordion component - Add basic documentation (#1913)

* Add basic documentation Accordion component

* Update README.md

* [ADF-680] Added previous page check when page has no more elements (#1911)

* [ADF-242] - fix for deleting - saving a report

* [ADF - 242] added test for fixed feature on reports save - delete

* [ADF-680] - Fixed behaviour when deleting all files on last page of document list

* Start adding test for documentlist check

* Added test for check double page load

* [ADF-680] - removed commented test code

* [ADF-680] Added changes from peer review

* [ADF-680] added return type

* [ADF-667] selection mode and row styles (#1914)

* selection mode and row styles

- single/multiple/none selection modes for DataTable component (and Document List)
- support for custom row styles (inline and classname values)
- fix karma config (material themes)
- readme updates
- package-lock.json files for NPM5 support
- updated DataTable demo to demonstrate selection modes and row styles

* remove package lock files

* move demo projects to webpack (#1915)

* wav and Mp3 enabling viewer (#1916)

* add option only demo shell version change for update version script

* ADF-402 add the show diagram button (#1917)

* [ADF-707] Ability to select a row on a dynamic table (#1921)

* [ADF-710] Create an Process Attachment List component (#1919)

* added new component to list the process attachments with view, download and delete functionality

* added unit test cases for activit-process-attachment-list component

* exported new process attachment list component

* added documentation for process-attachment-list component

* [ADF-712] Task Attachment - Provide a way to attach a new content (#1898)

* create button, download, view functionality added in task attachment list component

* created sevice to attach document to task

* added new component to create/uplaod attachment to task

* added new component to create/uplaod attachment to task

* added test case for create task attachment component

* added test case for create task attachment component

* added input to block upload document  to ECM

* fixed create task attachment spec file issue

* changed alfresco-upload to alfresco-core upload directive

* removed attachCreate button and emitter from task-attachment-list

* removed uploadToEcm input and checkValidity method from alfresco-upload

* added documentation for task-attachment-list and create-task-attachment components

* [ADF-696] Entire accordion group header should be clickable (#1918)

* #ADF-696 Added new input to show/hide expand icon, click event is activated for the complete heading

* #ADF-696 tslint fix

* #ADF-696 Added documentation for new input and removed unwanted div

* [ADF-721] Fix translation reference for dev task (#1923)

* move translation files in the bundles folder

* fix after review
ripristinate tslint and remove override tsconfig

* [ADF-709] add autofocus when a new row is added on dynamic table widget (#1927)

* [ADF-709] add autofocus when a new row is added on dynamic table widget

* [ADF-709] removed wrong reference for template

* [ADF-713] Process Attachment - Provide a way to attach a new content (#1920)

* added service to get all the related content of the process instance

* added new component to create/upload attachment for process instance

* added unit test cases for create-process-attachment component

* exported create-process-attachment component

* added documentation for create-process-attachment component

* Add data-automation-id to multi select checkbox (#1924)

* [ADF-571] upload feature rework (#1922)

* upload feature rework

lots of improvements for upload dialog and underlying services

* readme update

- readme cleanup
- remove some old comments from code
- update readme with new events for Upload Service

* restore prerequisites section in readme

* fix i18n issue with webpack

* exported report and chart models (#1925)

* fix file upload bug (#1928)

- proper extraction of File objects from the FileList

* lock files for npm 5 (#1930)

add lock files for npm v5; does nothing for earlier versions, so is not harmful

* Source Mapping is not working on test debugging (#1931)

* coverage single components run fix

* remove spec.ts from coverage

* make the coverage and the istanbul-instrumenter-loader works only over the console test because a problem on the remapping for the browser test

* move tslint on the main folder of any component

* remove build:w from readme

* stop build tslint error also in spec files

* clear karma file from unnecessary files

* add set -f for build all script in order to accept *

* fix lint problem and failing tests

* fix failing test search component

* add loader test for viewer

* fix tslint error userinfo

* --max_old_space_size=2048 remove

* fix tslint error uploader unused EventEmitter

* remove spec|index|.*mock|.*model|.*event from coverage

* move coverage separate file and get component to calculate coverage as input

* remove old 'banned' demo from login screen (#1929)

* add sleep time flag in publish script

* rollback demo tag

* fix pacakge.json tag

* [ADF-686] add blobFile as input (#1933)

* coverage fix (#1934)

* [ADF-702] Task/Process Filter - Provide a way to change the default filter (#1932)

* [ADF-702] Task/Process Filter - Provide a way to change the default filter

* Provide a way to select a custom menu filter

* Improve activiti process filter

* Add internal link

* Change link name

* add link

* [ADF-744] Attachment List is not displayed within Processes. (#1937)

* Use the adf process attachment list indise demo shell

* Change documentation

* support for healdess chrome (#1939)

* #ADF-696 Now accordion opens/closes on click of group header along with emitting heading click event (#1936)

* add info and link on current last git commit (#1940)

* [ADF-754] toolbar component (#1938)

* toolbar component

- simple toolbar component (core lib)
- readme updates (core lib)
- update demo shell with toolbar component demo (document list)

* update unit tests

* [ADF-763] Add Chrome default browser for karma chrome launcher for Chrome versi… (#1941)

* Add Chrome default browser for karma chrome launcher for Chrome version<59

* Fixing intermittently failing test in ng2-activiti-analytics component

* Adding new icon (sent) for Bootstrap to Material icon mapping (#1943)

* fix blob input in text viewer (#1942)

* GitHub issue & pull request template change (#1945)

* Update ISSUE_TEMPLATE.md

* Update PULL_REQUEST_TEMPLATE.md

* [ADF-689] Fix alfresco-document-menu-action styling (z-index) (#1944)

* fix translation wrong folder creation issue

* [ADF-773] Fix datatable custom template render (#1947)

* [ADF-780] centralised call for process filters api (#1950)

* [ADF-780] centralised call for process filters api

* [ADF-780] updated conversion to string

* [ADF-741] Add the create task attachment component to the demo shell (#1946)

* Add the create task attachment component to the demo shell

* Add translation keys

* Add return to methods

* fix thumbnail task process list (#1951)

* [ADF-643] upload enhancements (#1949)

* rework folder uploading

- flatterns hierarchy on folder upload
- performs a single traversal for the entire folder heirarchy and ends with a comple file list
- allows now dropping folders on existing folders
- overall code improvements

* fix unit tests

* readme updates

* clean old and unused code

* code cleanup

* limit concurrent uploads

* update code as per review

* fix upload button for Safari

* fixes for Safari

- Safari compatibility
- code updates based on review

* fix code

* fix unit tests

* [ADF-589] Login component different bug fixes (#1953)

* Basic style changes

* Further design changes

* Responsive design fixes

* Different sign in button style for the different login steps

* #ADF-780 Fixed getProcessFilterByName to get the correct filter for the given appId and name (#1952)

* fix issues with the require keyword (angular cli) (#1954)

* [ADF-799] add HappyPack to webpack conf (#1956)

* update npm5 lock files

* [ADF-740] Add button for process attachment list (#1955)

* [ADF-740] adding button to allow user to upload related content on process instance

* [ADF-740] add button for attachment content list for process

* changed locatin for translation

* [ADF-740] added test for add button for process attach

* [ADF-740] added PR request changes

* [ADF-802] fix error on uploading file to attachment list (#1957)

* [ADF-802] fix error on uploading file to attachment list

* [ADF-802] improved for loop

* [ADF-797] remove dist folder from npm distributed package , leave src and bundles (#1961)

* [ADF-804] webpack proxy setup to avoid CORS problem (#1960)

* package lock update

* update travis to node 8 (#1965)

* upload service exposes created nodes (#1964)

* [ADF-591] documentation refinements (#1959)

* refine ng2-activiti-analytics

* refine ng2-activiti-diagrams docs

* refine ng2-activiti-form

* refine ng2-activiti-processlist

* refine ng2-activiti-tasklist

* refine ng2-alfresco-core

* refine ng2-alfresco-datatable

* refine ng2-alfresco-datatable

* refine gn2-alfresco-login

* refine ng2-alfresco-search

* refine ng2-alfresco-social

* refine ng2-alfresco-tag

* refine ng2-alfresco-upload

* refine ng2-alfresco-userinfo

* refine ng2-alfresco-viewer

* refine ng2-alfresco-webscript

* various readme cleanups

* fix builds related to node-sass library (#1966)

* update dependencies and remove old lock files

* update sass loader

* updated lock files

* [ADF-578] Remember me functionality (#1962)

* Remember me functionality

* Happy pack to ng2-components' package.json

* Build fix

* Adding tabindices to viewer control elements (#1968)

* karma conf all single browser

* Fix current page number issue (#1970)

* [ADF-524] Datatable loading state (#1958)

* loading state datatable

* modify readme after review

* [ADF-78]  Update CORS help (#1973)

* Fix host configuration in demo-shell when no port is present (#1971)

* remove brachet

* [ADF-494] fixed readonly rendering for forms (#1972)

* [ADF-494] improved disabling for form

* [ADF-494] fixed readonly rendering for forms

* [ADF-814] application configuration service (#1969)

* app configuration service

* api improvements and readme update

* extend readme and add defaults

* unit tests for app config service

* [ADF-716] Task Header - Use a custom view inside the component (#1967)

* Use a generic custom view inside the task header

* Move the component into core component and change name

* Missing file

* Fix unit test

* fix unit test component name

* fix issue with shared Code settings

- remove obsolete rules for .js/.ts
- hide .happypack folder in the project tree

* [ADF-810] fix default value radio button (#1975)

* [ADF-510] Drag&Drop check permission to allow user to upload a file (#1948)

* [ADF-510] added permission check for drag&drop

* Improved code for drag and drop side

* Added test for drag and drop upload area changes

* Added test for document list permissions check

* [ADF-510] rebased branch after changes applied to upload

* [ADF-510] rebased branch and fixed tests

* [ADF-717] upgrade i18n and charting dependencies (#1976)

* remove app-specific polyfill dependencies

remove polyfill dependencies never used by component libraries

* upgrade i18n dependencies

* upgrade ng2-charts dependency

* fix unit tests

* update demo projects

* [ADF-524] Fix empty state after the loading introduction (#1980)

* fix empty state after the loading introduction

* Update document-list.component.spec.ts

remove typo

* [ADF-838] Table of content automatic creation (#1981)

* readonly value set

* Table of content automatic creation (#1982)

* add missing intl dependency for demo shell (#1984)

* [ADF-833] DataTable -  improve the single and double click event (#1979)

* Improve the single and double click event

* Fix unit test

* Task header basic documentation (#1985)

* Disable upload attachment when the task is completed (#1987)

* [ADF-847] upgrade to use application configuration service (#1986)

* migrate core lib to use server-side app config

* fix unit tests

* update Search tests

- update tests
- upgrade tests to use TestBed

* update UserInfo tests

* update Social tests

* update tests

* update unit tests

* cleanup old code

* update about page

* update demo shell readme

* dev and prod configurations

* updated package-lock file and removed duplicates in package.json

* [ADF-851] execute-outcome event for form service (#1989)

* execute-outcome event for form service

* readme updates

* fix loading state excluding other state during the loading (#1991)

* Fix compilation error (#1993)

* [ADF-883] Fix build errors (#1992)

* [ADF-793] Ability to create PDF renditions in case of non supported formats (#1994)

* Style changes and button

* Convert to PDF button

* Convert to PDF button part II.

* Convert within the Not Supported Format component

* Rendition loading skeleton

* Conversion is working.

* Convert button behaviour tests

* Rebasing fix.

* app settings page (#1997)

- custom app setttings service to use isolated storage (demo shell)
- restore settings UI
- redirect angular and rxjs to the same version as components use.

* [ADF-822] Added the npm-prepublish script (#1978)

* added the npm prepublish script

* changed permissions to prepublish script

* changed to npm run prepublish

* prepare the pr

* removed useless code to the script

* remove flags lib from demo shell (#1983)

* remove flags lib from demo shell

greatly reduce demo shell webpack resources by switching off flags (only 3 icons were displayed in the past)

* merge package.json

* add icons

* Fix typo error

* [ADF-794] Add people assignment component (#1977)

* Add people component

* exported people service

* added people-list component to show the involved user list

* changed people-search component layout

* changed people-list usage in people component

* changed people-list data table from custom template to data adapter

* changes people-search component related to people-list

* changes in activiti-people related to people-list and people-search component

* changed data adapter to direct data column setting to data-table

* removed ngChanges and added User and UserEvent models

* added User and UserEvent model in emitter and other emitter handler

* added user event model

* changed activiti-people component with latest UX changes

* addedand changed translate keys to the components

* added hasUser method to check the condition in html

* fixed tslint issue and test case issue in activiti-people component

* added test case for actviti-people-list component

* test case added for activiti-people-search component

* changed activiti-people test cases according to latest UX changes

* added description for activiti-people component

* changed test case to fix component.upgradeElement issue

* changes requested by Vito Albano #1

* splitted getDisplayUser into getDisplayUser and getInitialUsername

* introduce check type definition

* [ADF-897] - ActivitiPeopleList - use the adf prefix (#2001)

* Use the adf as prexif instead of activiti

* Fix typo

* Fix wrong import

* support binding [form] data directly (#1996)

- ability to bind [form] data directly inside `<activiti-form>` component
- ability to parse forms with FormService
- demo of the custom form in demo shell

* [ADF-778] cancel window for upload dialog shows only on complete (#2003)

* [ADF-778] Added new behaviour to upload dialog

* [ADF-778] cancel window for upload dialog shows only on complete

* [ADF-778] changed variable name to showCloseButton

* Create task/process attachment Compilation error (#2004)

* fix tslint errors

minor fix for "Unnecessary semicolon" TSLint rule

* [ADF-842] Fixed type for taskdetails (#2009)

* fix type definition (#2002)

* Use the activiti people with the new look and feel inside the demo shell (#2008)

* add rxjs and @angular in tsconfig.json

* [ADF-843] Form events bus (#1990)

* form events bus

* event test bus fix

* fix test after code review

* fix types errors

* change to public formservice

* make optional formservice

* [ADF-915] Add option to change the JS-API with different version in the update package

* Missing keys (#2011)

* [ADF-845] breadcrumb root option added and style review (#1999)

* breadcrumb root option added and style review

* new breadcrumbs

* split onchange in a method

* update readme with a note for old pefix tag

* fix tslint errors

* fix breadcrumb test

* [ADF-922] Regenerate package-lock.json files for every package and create script for doing that in the future (#2012)

* Updated package-lock.json files

* npm-relock-pkgs.sh

* Update README.md

* Fix ng2-alfresco-search sass problem

* SASS version update (#2013)

* sass update

* update sass loader

* vjsapi option prepublish

* prepublish script deprecation in favour of prepublishOnly node 8 (#2010)

* modify prePublish script with preoPublishOnly

* install rimraf globally

* fix clean scripts demo folders

* move appveyor to node 8

* Appveyor test (#1998)

* reduce memory

* remove max-old-space

* remove increase memory

* create new TaskDetailsModel in loadNextTask (#2017)

* Fix readme document list

* [ADF-907] - Form reacts to data added in input (#2016)

* [ADF-907] Enable activiti form to react on value data changes

* [ADF-907] - Form reacts to data added in input]

* [ADF - 907] added mock json for form

* [ADF-907] added new event of the form to the event list

* [ADF - 907] Added return column to README

* [ADF - 907] Added return column to README

* Script add pkg and clean update

* install globally pkg pre build

* Fix upload related content (#2019)

* regeneration TOC and add automatic list component generator (#2022)

* Fix upload process attachment (#2024)

* update typescript (#2026)

* update viewer readme

* fix type definition variables

* NgZone type passed parameter

* fix tslint error in tasklist

* Add screenshot (#2028)

* fix search miss typing

* bump version 1.6.0 (#2027)
2017-06-29 15:57:37 +01:00

33 KiB

DocumentList Component

Prerequisites

Before you start using this development framework, make sure you have installed all required software and done all the necessary configuration prerequisites.

If you plan using this component with projects generated by Angular CLI, please refer to the following article: Using ADF with Angular CLI

See also

Install

npm install ng2-alfresco-documentlist

Document List

<alfresco-document-list
    #documentList
    [currentFolderId]="'-my-'"
    [contextMenuActions]="true"
    [contentActions]="true"
    [creationMenuActions]="true">
</alfresco-document-list>

Properties

The properties currentFolderId, folderNode and node are the entry initialization properties of the document list. They can not be used together, choose the one that suites more your use case.

Name Type Default Description
selectionMode string 'single' Row selection mode. Can be none, single or multiple. For multiple mode you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows.
rowStyle string The inline style to apply to every row, see NgStyle docs for more details and usage examples
rowStyleClass string The CSS class to apply to every row
currentFolderId string null Initial node ID of displayed folder. Can be -root-, -shared-, -my-, or a fixed node ID
folderNode MinimalNodeEntryEntity null Currently displayed folder node
node NodePaging null Document list will show all the node contained in the NodePaging entity
navigate boolean true Toggles navigation to folder content or file preview
navigationMode string (click,dblclick) dblclick User interaction for folder navigation or file preview
thumbnails boolean false Show document thumbnails rather than icons
fallbackThumbnail string Path to fallback image to use if the row thumbnail is missing
multiselect boolean false Toggles multiselect mode
contentActions boolean false Toggles content actions for each row
contentActionsPosition string (left|right) right Position of the content actions dropdown menu.
contextMenuActions boolean false Toggles context menus for each row
enablePagination boolean true Shows pagination
creationMenuActions boolean true Toggles the creation menu actions
rowFilter RowFilter Custom row filter, see more.
imageResolver ImageResolver Custom image resolver, see more.
allowDropFiles boolean false Toggle file drop support for rows (see ng2-alfresco-core/UploadDirective for more details)
sorting string[] Defines default sorting. The format is an array of 2 strings [key, direction] i.e. ['name', 'desc'] or ['name', 'asc']. Set this value only if you want to override default sorting detected by the component based on columns.

Events

Name Description
nodeClick Emitted when user clicks the node
nodeDblClick Emitted when user double-clicks the node
folderChange Emitted upon display folder changed
preview Emitted when document preview is requested either with single or double click

For a complete example source code please refer to DocumentList Demo repository.

DOM Events

Below are the DOM events the DocumentList component emits. All of them are bubbling, meaning you can handle them in any component up the parent hierarchy, even if DocumentList is wrapped by another component(s).

Name Description
node-click Raised when user clicks the node
node-dblclick Raised when user double-clicks the node

Every event is represented by a CustomEvent instance, having at least the following properties as part of the Event.detail property value:

{
    sender: DocumentListComponent,
    node: MinimalNodeEntity
}

Handling DOM events

Here's a basic example on handling DOM events in the parent elements:

<div (node-click)="onNodeClicked($event)" 
     (node-dblclick)="onNodeDblClicked($event)">
    <div>
        <alfresco-upload-drag-area ...>
             <alfresco-document-list ...>
                ...
             </alfresco-document-list>
        </alfresco-upload-drag-area>
    </div>
</div>

Setting default folder

You can set current folder path by assigning a value for currentFolderId property. It can be either one of the well-known locations as -root-, -shared- or -my- or a node ID (guid).

There may be scenarios when it is needed to set default path based on relative string value rather than node ID. For example when folder name or path is static but it's underlying ID is not (i.e. created manually by admin). In this case you can use alfresco-js-api to get node details based on it's relative path.

Let's try setting default folder to /Sites/swsdp/documentLibrary without knowing it's ID beforehand. For the sake of simplicity example below shows only main points you may need paying attention to:

import { ChangeDetectorRef } from '@angular/core';
import { AlfrescoApiService } from 'ng2-alfresco-core';

export class FilesComponent implements OnInit {

    currentFolderId: string = '-my-';

    constructor(private apiService: AlfrescoApiService,
                private changeDetector: ChangeDetectorRef) {
        // ...
    }

    ngOnInit() {
        let nodes: any = this.apiService.getInstance().nodes;
        nodes.getNodeInfo('-root-', {
            includeSource: true,
            include: ['path', 'properties'],
            relativePath: '/Sites/swsdp/documentLibrary'
        })
        .then(node => {
            console.log(node);
            this.currentFolderId = node.id;
            this.changeDetector.detectChanges();
        });
    }
}

We've added console.log(node) for the getNodeInfo callback just for study and debug purposes. It helps examining other valuable information you can have access to if needed:

documentLibrary

Important note: for this particular scenario you must also trigger changeDetector.detectChanges() as in the example above.

Calling DocumentList api directly

Typically you will be binding DocumentList properties to your application/component class properties:

<alfresco-document-list 
    [currentFolderId]="myStartFolder">
</alfresco-document-list>

with the underlying class being implemented similar to the following one:

@Component(...)
export class MyAppComponent {

    myStartFolder: string = '-my-';
    
}

However there may scenarios that require you direct access to DocumentList apis. You can get reference to the DocumentList instance by means of Angular Component Interaction API. See more details in Parent calls a ViewChild section of the official docs.

Here's an example of getting reference:

<alfresco-document-list 
    #documentList
    [currentFolderId]="myStartFolder">
</alfresco-document-list>

Note the #documentList ID we've just added to be able referencing this component later on.

import { ViewChild, AfterViewInit } from '@angular/core';
import { DocumentListComponent } from 'ng2-alfresco-documentlist';

@Component(...)
export class MyAppComponent implements AfterViewInit {

    myStartFolder: string = '-my-';
    
    @ViewChild(DocumentListComponent)
    documentList: DocumentListComponent;

    ngAfterViewInit() {
        console.log(this.documentList);
    }
}

Example above should produce the following browser console output:

view-child

Now you are able accessing DocumentList properties or calling methods directly.

// print currently displayed folder node object to console
console.log(documentList.folderNode);

Important note:
It is important accessing child components at least at the AfterViewInit state. Any UI click (buttons, links, etc.) event handlers are absolutely fine. This cannot be ngOnInit event though. You can get more details in Component lifecycle hooks article.

Breadcrumb Component

DocumentList provides simple breadcrumb element to indicate the current position within a navigation hierarchy.

<adf-breadcrumb
    [target]="documentList"
    [folderNode]="documentList.folderNode">
</adf-breadcrumb>

Note: the <alfresco-document-list-breadcrumb> and <adf-breadcrumb> are the same component you can still use the old tag name

Breadcrumb

Properties

Name Type Description
target DocumentListComponent (optional) DocumentList component to operate with. Upon clicks will instruct the given component to update.
folderNode MinimalNodeEntryEntity Active node, builds UI based on folderNode.path.elements collection.
root String (optional) Name of the folder where you want start the breadcrumb. Note the root will always be showed as first element and it will continue to be displayed until you are not in a subfolder of it.

Events

Name Returned Type Description
navigate PathElementEntity emitted when user clicks on a breadcrumb

Menu Actions

DocumentList provides simple creation menu actions that provide the action to create a new folder.

<alfresco-document-menu-action 
    [folderId]="folderId">
</alfresco-document-menu-action>

Creation Menu Action

When the "New Folder" button is pressed the dialog appears.

Creation Menu Action

Custom columns

It is possible to reorder, extend or completely redefine data columns displayed by the component. By default special $thumbnail and displayName columns are rendered.

A custom set of columns can look like the following:

<alfresco-document-list ...>
    <content-columns>
        <content-column key="$thumbnail" type="image"></content-column>
        <content-column 
            title="Name" 
            key="name" 
            sortable="true"
            class="full-width ellipsis-cell">
        </content-column>
        <content-column 
            title="Created By" 
            key="createdByUser.displayName"
            sortable="true"
            class="desktop-only">
        </content-column>
        <content-column 
            title="Created On" 
            key="createdAt" 
            type="date" 
            format="medium"
            sortable="true"
            class="desktop-only">
        </content-column>
    </content-columns>
</alfresco-document-list>

Custom columns

You can also use HTML-based schema declaration used by DataTable, TaskList and other components:

<alfresco-datatable [data]="data" ...>
    <data-columns>
        <data-column type="image" key="icon" [sortable]="false"></data-column>
        <data-column key="id" title="Id"></data-column>
        <data-column key="createdOn" title="Created"></data-column>
        <data-column key="name" title="Name" class="full-width name-column"></data-column>
        <data-column key="createdBy.name" title="Created By"></data-column>
    </data-columns>
</alfresco-datatable>

DataColumn Properties

Here's the list of available properties you can define for a Data Column definition.

Name Type Default Description
key string Data source key, can be either column/property key like title or property path like createdBy.name
type string (text|image|date) text Value type
format string Value format (if supported by components), for example format of the date
sortable boolean true Toggles ability to sort by this column, for example by clicking the column header
title string Display title of the column, typically used for column headers
template TemplateRef Custom column template
sr-title string Screen reader title, used for accessibility purposes
class string Additional CSS class to be applied to column (header and cells)

DocumentList component assigns an instance of MinimalNode type (alfresco-js-api) as a data context of each row.

export interface MinimalNode {
    id: string;
    parentId: string;
    name: string;
    nodeType: string;
    isFolder: boolean;
    isFile: boolean;
    modifiedAt: Date;
    modifiedByUser: UserInfo;
    createdAt: Date;
    createdByUser: UserInfo;
    content: ContentInfo;
    path: PathInfoEntity;
    properties: NodeProperties;
}

See more details in alfresco-js-api repository.

Binding to nested properties is also supported. You can define a column key as a property path similar to the following:

createdByUser.displayName

Here's a short example:

<alfresco-document-list ...>
    <content-columns>
        <content-column key="$thumbnail" type="image"></content-column>
        <content-column title="Name" key="name" class="full-width ellipsis-cell"></content-column>
        <content-column 
            title="Created By" 
            key="createdByUser.displayName">
        </content-column>
    </content-columns>
</alfresco-document-list>

Column definition

Properties:

Name Type Default Description
title string Column title
sr-title string Screen reader title, used only when title is empty
key string Column source key, example: createdByUser.displayName
sortable boolean false Toggle sorting ability via column header clicks
class string CSS class list, example: full-width ellipsis-cell
type string text Column type, text|date|number
format string Value format pattern
template TemplateRef<any> Column template

For date column type the DatePipe formatting is used. For a full list of available format values please refer to DatePipe documentation.

Column Template

It is possible providing custom column/cell template that may contain other Angular components or HTML elmements:

Every cell in the DataTable component is bound to the dynamic data context containing the following properties:

Name Type Description
data DataTableAdapter Data adapter instance.
row DataRow Current data row instance.
col DataColumn Current data column instance.

You can use all three properties to gain full access to underlying data from within your custom templates. In order to wire HTML templates with the data context you will need defining a variable that is bound to $implicit like shown below:

<template let-context="$implicit">
    <!-- template body -->
</template>

The format of naming is let-VARIABLE_NAME="$implicit" where VARIABLE_NAME is the name of the variable you want binding template data context to.

Getting a cell value from the underlying DataTableAdapter:

context.data.getValue(entry.row, entry.col);

You can retrieve all property values for underlying node, including nested properties (via property paths):

context.row.getValue('name')
context.row.getValue('createdByUser.displayName')

You may want using row api to get raw value access.

<content-column title="Name" key="name" sortable="true" class="full-width ellipsis-cell">
    <template let-context="$implicit">
        <span>Hi! {{context.row.getValue('createdByUser.displayName')}}</span>
        <span>Hi! {{context.row.getValue('name')}}</span>
    </template>
</content-column>

Use data api to get values with post-processing, like datetime/icon conversion._

In the Example below will prepend Hi! to each file and folder name in the list:

<content-column title="Name" key="name" sortable="true" class="full-width ellipsis-cell">
    <template let-entry="$implicit">
        <span>Hi! {{entry.data.getValue(entry.row, entry.col)}}</span>
    </template>
</content-column>

In the Example below will add the ng2-alfresco-tag component is integrate in the document list.

<content-column
    title="{{'DOCUMENT_LIST.COLUMNS.TAG' | translate}}"
    key="id"
    sortable="true"
    class="full-width ellipsis-cell">
    <template let-entry="$implicit">
        <alfresco-tag-node-list  [nodeId]="entry.data.getValue(entry.row, entry.col)"></alfresco-tag-node-list>
    </template>
</content-column>

Tag component in document List

Actions

DocumentList supports declarative actions for Documents and Folders. Each action can be bound to either default out-of-box handler or a custom behavior. You can define both folder and document actions at the same time.

Menu actions

<alfresco-document-list ...>
    <content-actions>

        <content-action
            target="document"
            title="System action"
            handler="system2">
        </content-action>

        <content-action
            target="document"
            title="Custom action"
            (execute)="myCustomAction1($event)">
        </content-action>

    </content-actions>
</alfresco-document-list>
export class MyView {
    // ...

    myCustomAction1(event) {
        let entry = event.value.entry;
        alert(`Custom document action for ${entry.name}`);
    }
}

All document actions are rendered as a dropdown menu as on the picture below:

Document Actions

Default action handlers

The following action handlers are provided out-of-box:

  • Download (document)
  • Delete (document, folder)

All system handler names are case-insensitive, handler="download" and handler="DOWNLOAD" will trigger the same download action.

Delete - Show notification message with no permission

You can show a notification error when the user don't have the right permission to perform the action. The ContentActionComponent provides the event permissionEvent that is raised when the permission specified in the permission property is missing You can subscribe to this event from your component and use the NotificationService to show a message.

<alfresco-document-list ...>
    <content-actions>

        <content-action
            target="document"
            title="Delete"
            permission="delete"
            (permissionEvent)="onPermissionsFailed($event)"
            handler="delete">
        </content-action>

    </content-actions>
</alfresco-document-list>
export class MyComponent {

    onPermissionsFailed(event: any) {
        this.notificationService.openSnackMessage(`you don't have the ${event.permission} permission to ${event.action} the ${event.type} `, 4000);
    }

}

Delete show notification message

Delete - Disable button checking the permission

You can easily disable a button when the user doesn't own the permission to perform the action related to the button. The ContentActionComponent provides the property permission that must contain the permission to check and a property disableWithNoPermission that can be true if you want see the button disabled.

<alfresco-document-list ...>
    <content-actions>

        <content-action
            target="document"
            title="Delete"
            permission="delete"
            disableWithNoPermission="true"
            handler="delete">
        </content-action>

    </content-actions>
</alfresco-document-list>

Delete disable action button

Download

Initiates download of the corresponding document file.

<alfresco-document-list ...>
    <content-actions>

        <content-action
            target="document"
            title="Download"
            handler="download">
        </content-action>

    </content-actions>
</alfresco-document-list>

Download document action

Folder actions

Folder actions have the same declaration as document actions except taget="folder" attribute value.

<alfresco-document-list ...>
    <content-actions>

        <content-action
            target="folder"
            title="Default folder action 1"
            handler="system1">
        </content-action>

        <content-action
            target="folder"
            title="Custom folder action"
            (execute)="myFolderAction1($event)">
        </content-action>

    </content-actions>
</alfresco-document-list>
export class MyView {
    // ...

    myFolderAction1(event) {
        let entry = event.value.entry;
        alert(`Custom folder action for ${entry.name}`);
    }
}

Folder Actions

Context Menu

DocumentList also provide integration for 'Context Menu Service' from the ng2-alfresco-core library.

You can automatically turn all menu actions (for the files and folders) into context menu items like shown below:

Folder context menu

Enabling context menu is very simple:

@Component({
    selector: 'my-view',
    template: `
        <alfresco-document-list>...</alfresco-document-list>
        <context-menu-holder></context-menu-holder>
    `
})
export class MyView {
}

This enables context menu items for documents and folders.

Navigation mode

By default DocumentList component uses 'double-click' mode for navigation. That means user will see the contents of the folder by double-clicking its name or icon (similar to Google Drive behaviour). However it is possible switching to other modes, like single-click navigation for example.

The following navigation modes are supported:

  • click
  • dblclick

The following example switches navigation to single clicks:

<alfresco-document-list 
    [navigationMode]="'click'">
</alfresco-document-list>

Events

DocumentList emits the following events:

Name Description
nodeClick emitted when user clicks a list node
nodeDblClick emitted when user double-clicks list node
folderChange emitted once current display folder has changed
preview emitted when user acts upon files with either single or double click (depends on navigation-mode), recommended for Viewer components integration
permissionError emitted when user is attempting to create a folder via action menu but it doesn't have the permission to do it
ready emitted when the documentList is ready and load all the elements

Advanced usage and customization

Custom row filter

You can create a custom row filter implementation that returns true if row should be displayed or false to hide it. Typical row filter implementation is a function that receives ShareDataRow as parameter:

myFilter(row: ShareDataRow): boolean {
    return true;
}

Note that for the sake of simplicity the example code below was reduced to the main points of interest only.

View1.component.html

<alfresco-document-list 
    [rowFilter]="folderFilter">
</alfresco-document-list>

View1.component.ts


import { RowFilter, ShareDataRow } from 'ng2-alfresco-documentlist';

export class View1 {

    folderFilter: RowFilter;

    constructor() {
    
        // This filter will make document list show only folders
        
        this.folderFilter = (row: ShareDataRow) => {
            let node = row.node.entry;
            
            if (node && node.isFolder) {
                return true;
            }
            
            return false;
        };
    }
}

Custom image resolver

You can create a custom image resolver implementation and take full control over how folder/file icons and thumbnails are resolved and what document list should display.

Image resolvers are executed only for columns of the image type.

Typical image resolver implementation is a function that receives DataRow and DataColumn as parameters:

myImageResolver(row: DataRow, col: DataColumn): string {
    return '/path/to/image';
}

Your function can return null or false values to fallback to default image resolving behavior.

Note that for the sake of simplicity the example code below was reduced to the main points of interest only.

View1.component.html

<alfresco-document-list 
    [imageResolver]="folderImageResolver">
    
    <content-columns>
        <content-column key="name" type="image"></content-column>
    </content-columns>
    
    
</alfresco-document-list>

View1.component.ts

import { DataColumn, DataRow } from 'ng2-alfresco-datatable';
import { ImageResolver } from 'ng2-alfresco-documentlist';

export class View1 {

    folderImageResolver: ImageResolver;
    
    constructor() {
        
        // Customize folder icons, leave file icons untouched
        
        this.folderImageResolver = (row: DataRow, col: DataColumn) => {
            let isFolder = <boolean> row.getValue('isFolder');
            if (isFolder) {
                
                // (optional) You may want dynamically getting the column value
                let name = row.getValue(col.key);
                
                // Format image url
                return `http://<my custom path to folder icon>/${name}`;
            }
            
            // For the rest of the cases just fallback to default behaviour.
            return null;
        };
        
    }

}

Hiding columns on small screens

You can hide columns on small screens by means of custom CSS rules:

@media all and (max-width: 768px) {

    alfresco-document-list >>> th.desktop-only .cell-value {
        display: none;
    }

    alfresco-document-list >>> td.desktop-only .cell-value {
        display: none;
    }
}

Now you can declare columns and assign desktop-only class where needed:

<alfresco-document-list ...>
    <content-columns>
        
        <!-- always visible columns -->
        
        <content-column key="$thumbnail" type="image"></content-column>
        <content-column 
                title="Name" 
                key="name" 
                class="full-width ellipsis-cell">
        </content-column>
        
        <!-- desktop-only columns -->
        
        <content-column
                title="Created by"
                key="createdByUser.displayName"
                class="desktop-only">
        </content-column>
        <content-column
                title="Created on"
                key="createdAt"
                type="date"
                format="medium"
                class="desktop-only">
        </content-column>
    </content-columns>
</alfresco-document-list>

Desktop View

Responsive Desktop

Mobile View

Responsive Mobile

Custom 'empty folder' template

By default DocumentList provides the following content for the empty folder:

Default empty folder

This can be changed by means of the custom html template:

<alfresco-document-list ...>
    <empty-folder-content>
        <template>
            <h1>Sorry, no content here</h1>
        </template>
    </empty-folder-content>
</alfresco-document-list>

That will give the following output:

Custom empty folder

Customizing default actions

It is possible extending or replacing the list of available system actions for documents and folders. Actions for the documents and folders can be accessed via the following services:

  • DocumentActionsService, document action menu and quick document actions
  • FolderActionsService, folder action menu and quick folder actions

Example below demonstrates how a new action handler can be registered with the DocumentActionsService.

<alfresco-document-list ...>
    <content-actions>

        <content-action
            target="document"
            title="My action"
            handler="my-handler">
        </content-action>

    </content-actions>
</alfresco-document-list>

You register custom handler called my-handler that will be executing myDocumentActionHandler function each time upon being invoked.

import { DocumentActionsService } from 'ng2-alfresco-documentlist';

export class MyView {

    constructor(documentActions: DocumentActionsService) {
        documentActions.setHandler(
            'my-handler',
            this.myDocumentActionHandler.bind(this)
        );
    }

    myDocumentActionHandler(obj: any) {
        window.alert('my custom action handler');
    }
}

The same approach allows changing the way out-of-box action handlers behave. Registering custom action with the name download replaces default one:

export class MyView {

    constructor(documentActions: DocumentActionsService) {
        documentActions.setHandler(
            'download',
            this.customDownloadBehavior.bind(this)
        );
    }

    customDownloadBehavior(obj: any) {
        window.alert('my custom download behavior');
    }
}

Typically you may want populating all your custom actions at the application root level or by means of custom application service.

Build from sources

You can build component from sources with the following commands:

npm install
npm run build

The build task rebuilds all the code, runs tslint, license checks and other quality check tools before performing unit testing.

NPM scripts

Command Description
npm run build Build component
npm run test Run unit tests in the console
npm run test-browser Run unit tests in the browser
npm run coverage Run unit tests and display code coverage report

Demo

Please check the demo folder for a demo project

cd demo
npm install
npm start

License

Apache Version 2.0