import { Component, Input, Output, EventEmitter } from '@angular/core';

/**
 * 分组可收缩列表
 *
 * @export
 * @class AppShrinkableGroupingList
 */
@Component({
    selector: 'app-shrinkable-grouping-list',
    templateUrl: 'app-shrinkable-grouping-list.html',
    styleUrls: ['app-shrinkable-grouping-list.scss']
})
export class AppShrinkableGroupingList {
    /**
     * 列表信息
     *
     * @type {any[]}
     * @memberof AppShrinkableGroupingList
     */
    @Input()
    items: any[];
    /**
     * 列表项点击
     *
     * @type {EventEmitter<any>}
     * @memberof AppShrinkableGroupingList
     */
    @Output()
    itemClick: EventEmitter<any> = new EventEmitter();

    /**
     * 列表点击
     *
     * @param {*} item
     * @memberof AppShrinkableGroupingList
     */
    public onClick(item: any): void {
        this.itemClick.emit(item);
    }

    /**
     * 改变展示全部功能
     *
     * @param {*} item
     * @memberof AppShrinkableGroupingList
     */
    public openChange(item: any): void {
        item.isOpen = !item.isOpen;
    }
}