import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ListViewEventData } from 'nativescript-ui-listview';
import { WarehouseItemAllBorrowableOutput } from '../../entities/output/warehouseItemAllBorrowableOutput';

@Component({
    selector: 'ReservationList',
    moduleId: module.id,
    templateUrl: './reservation-list-view.component.html',
    styleUrls: ['./reservation-list-view.component.scss']
})

export class ReservationListComponent {
    @Input() items: WarehouseItemAllBorrowableOutput[];
    @Output() tapItem = new EventEmitter<WarehouseItemAllBorrowableOutput>();

    templateSelector(item: any, index: number, items: any): string {
        return item.expanded ? 'expanded' : 'default';
    }

    onTap(item: WarehouseItemAllBorrowableOutput) {
        this.tapItem.emit(item);
    }

    onTapItem(event: ListViewEventData) {
        this.items[event.index].expanded = !this.items[event.index].expanded;
    }

    get downIcon() {
        return String.fromCharCode(0xf107);
    }

    get rightIcon() {
        return String.fromCharCode(0xf105);
    }
}
