Charlie Tran 5072ef013c
feat(frontend): Module consolidation - clean up for OS logic - init virtual assistant (#1821)
* Module consolidation on datahub-web - clean up to some OS logic from previous update - initial implementation of virtual assistant

* Fix accidental change to datahub user module license
2020-08-28 10:31:15 -07:00

54 lines
1.6 KiB
TypeScript

import WithEntityLists from '@datahub/shared/components/lists/with-entity-lists';
// @ts-ignore: Ignore import of compiled template
import template from '../../templates/components/lists/list-count';
import { layout, classNames, className } from '@ember-decorators/component';
import { DataModelEntity } from '@datahub/data-models/constants/entity';
import { computed } from '@ember/object';
import { singularize } from 'ember-inflector';
import { alias } from '@ember/object/computed';
import { capitalize } from '@ember/string';
export const baseComponentClass = `entity-list-count`;
/**
* ListCount is a bug for displaying the number of items in a list
* The bug should be displayed when there are items in the list and hidden or dismissed otherwise
* @export
* @class ListCount
* @extends {WithEntityLists}
*/
@layout(template)
@classNames(baseComponentClass)
export default class ListCount extends WithEntityLists {
baseComponentClass = baseComponentClass;
/**
* The type of DataModel entity being rendered
*/
entityType?: DataModelEntity;
/**
* Reference to the entity class
* Required for entity list trampoline
*/
@alias('entityType')
entity?: DataModelEntity;
/**
* Display value for the current list item
* @readonly
*/
@computed('entityType')
get displayName(): string {
const { entityType } = this;
return entityType ? `${capitalize(singularize(entityType.displayName))} List` : '';
}
/**
* The number of items in the list
*/
@className(`${baseComponentClass}--display`, `${baseComponentClass}--dismiss`)
@alias('entityListTrampoline.list.length')
count?: number;
}