import ngModule from '../module';
import Section from 'salix/components/section';

class Controller extends Section {
    constructor($element, $) {
        super($element, $);
        this.filter = {
            include: [
                {
                    relation: 'item'
                }, {
                    relation: 'isChecked',
                    scope: {
                        fields: ['isChecked']
                    }
                }
            ]
        };
    }
    showDescriptor(event, sale) {
        this.quicklinks = {
            btnThree: {
                icon: 'icon-transaction',
                state: `item.card.diary({
                    id: ${sale.itemFk}, 
                    warehouseFk: ${this.ticket.warehouseFk},
                    lineFk: ${sale.id}
                })`,
                tooltip: 'Item diary'
            }
        };
        this.$.descriptor.show(event.target, sale.itemFk);
    }
}

ngModule.vnComponent('vnTicketSaleChecked', {
    template: require('./index.html'),
    controller: Controller,
    bindings: {
        ticket: '<'
    }
});