alfresco-ng2-components/docs/core/interfaces/card-view-item.interface.md
Denys Vuika cd2b489100
[ADF-5146] Upgrade to Angular 10 (#5834)
* remove useless module

* upgrade to angular 8

* upgrade material to v8

* upgrade adf libs

* migrate demo shell to v8

* upgrade to angular 9

* upgrade material to v9

* remove hammer

* upgrade nx

* upgrade datetime picker

* upgrade flex layout

* update core api

* remove entry components

* code fixes

* upgrade testbed usage

* code fixes

* remove unnecessary core-js from tests

* upgrade CLI

* ts config fixes

* fix builds

* fix testing config

* compile fixes

* fix demo shell dev setup

* fix core tests

* fix card view import

* upgrade nx

* disable smart builds for now

* remove fdescribe

* restore smart builds

* fix issues

* unify tsconfigs and fix newly found issues

* fix configuration and cleanup package scripts

* improved production build from the same config

* use ADF libs directly instead of node_modules

* disable smart build

* single app configuration (angular)

* fix core build

* fix build scripts

* lint fixes

* fix linting setup

* fix linting rules

* various fixes

* disable affected libs for unit tests

* cleanup insights package.json

* simplify smart-build

* fix content tests

* fix tests

* test fixes

* fix tests

* fix test

* fix tests

* disable AppExtensionsModule (monaco example)

* remove monaco extension module

* upgrade bundle check rules

* fix insights tests and karma config

* fix protractor config

* e2e workaround

* upgrade puppeteer and split linting and build

* reusable resources config

* update protractor config

* fix after rebase

* fix protractor config

* fix e2e tsconfig

* update e2e setup

* Save demoshell artifact on S3 and remove travis cache

* Push the libs on S3 and fetch before releasing it

* Add deps

* Add dependencies among libs and run only affected unit test and build

* fix the travis stage name

* fix after renaming dev to demoshell

* force the order of the projects

* remove unused dependencies

* fix content e2e script

* exit codes fix

* add extra exit codes to core e2e

* postinstall hook and package cleanup

* cleanup packages

* remove deprecated code and dependency on router

* improve bundle analyzer script

* minor code fixes

* update spec

* fix code after rebase

* upgrade protractor after rebase

* fix e2e mapping lib

* Update tsconfig.e2e.json

* update e2e tsconfig

* fix angular config

* fix protractor runs

* cache dist folder for libs

* update material selectors for dropdowns

* selector fixes

* remove duplicated e2e that have unit tests already

* fix login selector

* fix e2e

* fix test

* fix import issues

* fix selector

* cleanup old monaco extension files

* cleanup demo shell login

* add protractor max retries

* disable customisations of protractor

* fix login validation

* fix after rebase

* fix after rebase, disable latest versions of libs

* Hide the report tab and rollback the localstorage

* rename protractor config back to js

* restore lint as part of build

* cleanup code

* do not copy anything to node_modules on dist test

* fix unit tests

* config fixes

* fix code

* fix code after rebase

* fix tests

* remove existing words from spellcheck

* remove useless directive decorators

* update package.json after rebase

* add js-api back

* code fixes

* add missing export

* update configs

* fix code

* try fix the sso login test

* fix

* remove puppeteer unit

* fix e2e script

* fix

* make provider easy

* fix routes module before upgrade

* fix unit tests

* upgrade angular cli

* upgrade to angular 10

Co-authored-by: maurizio vitale <maurizio.vitale@alfresco.com>
Co-authored-by: Eugenio Romano <eugenio.romano@alfresco.com>
Co-authored-by: Eugenio Romano <eromano@users.noreply.github.com>
2020-07-03 13:01:05 +01:00

4.9 KiB

Title, Added, Status, Last reviewed
Title Added Status Last reviewed
Card View Item interface v2.0.0 Active 2018-05-08

Card View Item interface

Defines the implementation of an item in a Card View component.

Definition

export interface CardViewItem {
    label: string;
    value: any;
    key: string;
    default?: any;
    type: string;
    displayValue: string;
    editable?: boolean;
    icon?: string;
    data?: any;
}

Properties

Name Type Default Description
label string "" Item label
value any The original data value for the item
key string "" Identifying key (important when editing the item)
default any The default value to display if the value is empty
displayValue string "" The value to display
editable boolean false Toggles whether the item is editable
clickable boolean false Toggles whether the item is clickable
icon string The material icon to show beside clickable items
data any null Any custom data which is needed to be provided and stored in the model for any reason. During an update or a click event this can be a container of any custom data which can be useful for 3rd party codes.

Details

Card item components are loaded dynamically by the main Card View component. This allows you to define your own component for a custom item type.

For example, follow the steps given below to add a stardate type to display Captain Picard's birthday (47457.1):

  1. Define the model for the custom type.

    Your model must extend the CardViewBaseItemModel class and implement the CardViewItem and DynamicComponentModel interfaces. See the Card View Text Item model source for an example of how to do this.

    import { CardViewBaseItemModel, CardViewItem, DynamicComponentModel } from '@alfresco/adf-core';
    
    export class CardViewStarDateItemModel extends CardViewBaseItemModel implements CardViewItem, DynamicComponentModel {
        type: string = 'star-date';
    
        get displayValue() {
            return this.convertToStarDate(this.value) || this.default;
        }
    
        private convertToStarDate(starTimeStamp: number): string {
            // Do the magic
        }
    }
    
  2. Define the component for the custom type.

    The selector is not important given that this is a dynamically loaded component. You can choose any name for the selector, but it makes sense to follow the Angular standards.

    @Component({
        selector: 'card-view-stardateitem' /* For example */
        ...
    })
    export class CardViewStarDateItemComponent {
        @Input()
        property: CardViewStarDateItemModel;
    
        @Input()
        editable: boolean;
    
        constructor(private cardViewUpdateService: CardViewUpdateService) {}
    
        isEditable() {
            return this.editable && this.property.editable;
        }
    
        showStarDatePicker() {
            ...
        }
    }
    

    See the Card View Text Item component source or the Card View Date Item component source for examples of how to make the field editable.

  3. Bind your custom component to the custom model type so that Angular's dynamic component loader can find it.

    @Component({
        ...
        providers: [ CardItemTypeService ] /* If you don't want to pollute the main instance of the CardItemTypeService service */
        ...
    })
    export class SomeParentComponent {
    
        constructor(private cardItemTypeService: CardItemTypeService) {
            cardItemTypeService.setComponentTypeResolver('star-date', () => CardViewStarDateItemComponent);
        }
    }
    

    The Card Item Type service maps each item type to the corresponding component. See its doc page for further details.

See also