import { Component, OnInit, Input, Output, EventEmitter, ElementRef, ViewChild } from '@angular/core';
import { CfCoreComponent } from '../core/core.component';
import { CfCheckboxComponent } from '../checkbox/checkbox.component';
import { ItemStylingModel } from '../../models/item/item-styling.model';
@Component({
selector: 'cf-item',
template: "
The item component can be used anywhere as a general item or inside cf-list component as a list item.
*The item component consists of 2 tabs: Default template (always shown) and the details template.
*/ export class CfItemComponent extends CfCoreComponent implements OnInit { @Input() styling: ItemStylingModel; /** *True if the item will contain a details tab.
*/ @Input() details:boolean = false; selectedValue: boolean = false; /** *If the item is selectable, then show a checkbox
*/ @Input() selectable: boolean = false; @Input() withCheckbox: boolean = true; @Input() get selected() { return this.selectedValue; } @Output() selectedChange: EventEmitterSet to true when the user presses on the details icon.
*/ showDetails: boolean = false; constructor(public elementRef: ElementRef) { super(elementRef); } ngOnInit() { if(this.styling==null) this.styling = new ItemStylingModel(); } ngOnChanges(changes: any){ } @ViewChild(CfCheckboxComponent) checkbox: CfCheckboxComponent; selectMe() { if(this.selectable==true) { this.selected = !this.selected; this.itemClicked.emit({"id":this.internalId, "value": this.selectedValue}); } } notifyList(){ if(this.selectable==true) { this.itemClicked.emit({"id":this.internalId, "value": !this.selectedValue}); } } }